X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=pkg%2FR%2FconstructionModelesLassoRank.R;h=85685e951930044feec2486f99a1ed1e8ae557b8;hp=dc6bcc1efe1331771dd4eb7d1555b29b35a8f797;hb=a3cbbaea1cc3c107e5ca62ed1ffe7b9499de0a91;hpb=95dc88bfe8495527cebe7f64db4e75a69773f2e5 diff --git a/pkg/R/constructionModelesLassoRank.R b/pkg/R/constructionModelesLassoRank.R index dc6bcc1..85685e9 100644 --- a/pkg/R/constructionModelesLassoRank.R +++ b/pkg/R/constructionModelesLassoRank.R @@ -1,7 +1,7 @@ #' constructionModelesLassoRank #' #' Construct a collection of models with the Lasso-Rank procedure. -#' +#' #' @param S output of selectVariables.R #' @param k number of components #' @param mini integer, minimum number of iterations in the EM algorithm, by default = 10 @@ -14,12 +14,12 @@ #' @param ncores Number of cores, by default = 3 #' @param fast TRUE to use compiled C code, FALSE for R code only #' @param verbose TRUE to show some execution traces -#' +#' #' @return a list with several models, defined by phi, rho, pi, llh #' #' @export constructionModelesLassoRank <- function(S, k, mini, maxi, X, Y, eps, rank.min, rank.max, - ncores, fast = TRUE, verbose = FALSE) + ncores, fast, verbose) { n <- dim(X)[1] p <- dim(X)[2] @@ -64,9 +64,7 @@ constructionModelesLassoRank <- function(S, k, mini, maxi, X, Y, eps, rank.min, for (j in 1:p) { if (length(selected[[j]]) > 0) - { relevant <- c(relevant, j) - } } if (max(rankIndex) < length(relevant)) { @@ -75,19 +73,20 @@ constructionModelesLassoRank <- function(S, k, mini, maxi, X, Y, eps, rank.min, { res <- EMGrank(S[[lambdaIndex]]$Pi, S[[lambdaIndex]]$Rho, mini, maxi, X[, relevant], Y, eps, rankIndex, fast) - llh <- c(res$LLF, sum(rankIndex * (length(relevant) - rankIndex + - m))) + llh <- c(res$LLF, sum(rankIndex * (length(relevant) - rankIndex + m))) phi[relevant, , ] <- res$phi } list(llh = llh, phi = phi, pi = S[[lambdaIndex]]$Pi, rho = S[[lambdaIndex]]$Rho) - } } # For each lambda in the grid we compute the estimators - out <- if (ncores > 1) { - parLapply(cl, seq_len(length(S) * Size), computeAtLambda) } else { - lapply(seq_len(length(S) * Size), computeAtLambda) + out <- + if (ncores > 1) { + parLapply(cl, seq_len(length(S) * Size), computeAtLambda) + } else { + lapply(seq_len(length(S) * Size), computeAtLambda) + } if (ncores > 1) parallel::stopCluster(cl)