X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=pkg%2FR%2FconstructionModelesLassoRank.R;h=dc88f676f1ed8ca11e0ec5b91013e304226df309;hp=5c742d14e2b0e3bf5270aaab57859894a4b1fe1f;hb=ea5860f1b4fc91f06e371a0b26915198474a849d;hpb=4464301b48c62cdbad7f1c9a67eaafd596655425 diff --git a/pkg/R/constructionModelesLassoRank.R b/pkg/R/constructionModelesLassoRank.R index 5c742d1..dc88f67 100644 --- a/pkg/R/constructionModelesLassoRank.R +++ b/pkg/R/constructionModelesLassoRank.R @@ -14,16 +14,16 @@ #' @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] - m <- dim(Y)[2] + n <- nrow(X) + p <- ncol(X) + m <- ncol(Y) L <- length(S) # Possible interesting ranks @@ -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)