From: emilie Date: Tue, 4 Apr 2017 08:57:21 +0000 (+0200) Subject: update main.R and fix some errors X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/user/doc/current/gitweb.css?a=commitdiff_plain;h=19041906b8d80eb9a7dac7bffebf3992bcec6ccf;p=valse.git update main.R and fix some errors --- diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index 8ec8b8a..eb71b76 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -19,7 +19,7 @@ Depends: R (>= 3.0.0) Imports: MASS, - parallel + parallel Suggests: capushe, roxygen2, @@ -27,3 +27,16 @@ Suggests: URL: http://git.auder.net/?p=valse.git License: MIT + file LICENSE RoxygenNote: 5.0.1 +Collate: + 'plot.R' + 'main.R' + 'selectVariables.R' + 'filterModels.R' + 'constructionModelesLassoRank.R' + 'constructionModelesLassoMLE.R' + 'computeGridLambda.R' + 'initSmallEM.R' + 'EMGrank.R' + 'EMGLLF.R' + 'generateXY.R' + 'A_NAMESPACE.R' diff --git a/pkg/R/computeGridLambda.R b/pkg/R/computeGridLambda.R index a051441..e2b6303 100644 --- a/pkg/R/computeGridLambda.R +++ b/pkg/R/computeGridLambda.R @@ -24,9 +24,8 @@ computeGridLambda = function(phiInit, rhoInit, piInit, gamInit, X, Y, m = dim(phiInit)[2] k = dim(phiInit)[3] - # TODO: explain why gamma=1 instad of just 'gamma'? - list_EMG = EMGLLF(phiInit, rhoInit, piInit, gamInit, mini, maxi, - gamma=1, lamba=0, X, Y, tau) + list_EMG = EMGLLF(phiInit, rhoInit, piInit, gamInit, mini, maxi, + gamma, lambda=0, X, Y, tau) grid = array(0, dim=c(p,m,k)) for (i in 1:p) { @@ -34,6 +33,5 @@ computeGridLambda = function(phiInit, rhoInit, piInit, gamInit, X, Y, grid[i,j,] = abs(list_EMG$S[i,j,]) / (n*list_EMG$pi^gamma) } grid = unique(grid) - grid = grid[grid <= 1] grid } diff --git a/pkg/R/main.R b/pkg/R/main.R index ab25daf..8f845f4 100644 --- a/pkg/R/main.R +++ b/pkg/R/main.R @@ -87,11 +87,13 @@ valse = function(X, Y, procedure='LassoMLE', selecMod='DDSE', gamma=1, mini=10, # List (index k) of lists (index lambda) of models models_list <- - if (ncores_k > 1) + #if (ncores_k > 1) + if (ncores_outer > 1) parLapply(cl, kmin:kmax, computeModels) else lapply(kmin:kmax, computeModels) - if (ncores_k > 1) + #if (ncores_k > 1) + if (ncores_outer > 1) parallel::stopCluster(cl) if (! requireNamespace("capushe", quietly=TRUE)) @@ -102,11 +104,11 @@ valse = function(X, Y, procedure='LassoMLE', selecMod='DDSE', gamma=1, mini=10, # Get summary "tableauRecap" from models ; TODO: jusqu'à ligne 114 à mon avis là c'est faux :/ tableauRecap = t( sapply( models_list, function(models) { - llh = do.call(rbind, lapply(models, function(model) model$llh) + llh = do.call(rbind, lapply(models, function(model) model$llh)) LLH = llh[-1,1] D = llh[-1,2] c(LLH, D, rep(k, length(model)), 1:length(model)) - ) } ) ) + } )) if (verbose) print('Model selection') tableauRecap = tableauRecap[rowSums(tableauRecap[, 2:4])!=0,]