1 #Return a list of outputs, for each lambda in grid: selected,Rho,Pi
2 selectiontotale = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,X,Y,thresh,tau){
4 cl = parallel::makeCluster( parallel::detectCores() / 4 ) # <-- ça devrait être un argument
5 parallel::clusterExport(cl=cl,
6 varlist=c("phiInit","rhoInit","gamInit","mini","maxi","glambda","X","Y","thresh","tau"),
8 #Pour chaque lambda de la grille, on calcule les coefficients
9 out = parLapply( 1:length(glambda), function(lambdaindex)
12 EMGLLF(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda[lambdaIndex],X,Y,tau)
16 #selectedVariables: list where element j contains vector of selected variables in [1,m]
17 selectedVariables = lapply(1:p, function(j) {
18 #from boolean matrix mxk of selected variables obtain the corresponding boolean m-vector,
19 #and finally return the corresponding indices
20 seq_len(m)[ apply( abs(params$phi[j,,]) > thresh, 1, any ) ]
23 list("selected"=selectedVariables,"Rho"=params$Rho,"Pi"=params$Pi)
25 parallel::stopCluster(cl)