X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FselectVariables.R;h=bab45cccee4f7bf1d39aa48dc8f13a33d04eaae9;hb=17b9fa5f6004bb55e915d8916f1c9a1f128a65ce;hp=cdc0ec00f672d534d65c8a9b5dfb951b79a5e468;hpb=ca277ac5ab51fef149014eb5e4610403fdb3227b;p=valse.git diff --git a/pkg/R/selectVariables.R b/pkg/R/selectVariables.R index cdc0ec0..bab45cc 100644 --- a/pkg/R/selectVariables.R +++ b/pkg/R/selectVariables.R @@ -37,15 +37,22 @@ selectVariables <- function(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma params <- EMGLLF(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda, X, Y, eps, fast) - p <- dim(phiInit)[1] - m <- dim(phiInit)[2] + p <- ncol(X) + m <- ncol(Y) # selectedVariables: list where element j contains vector of selected variables # in [1,m] selectedVariables <- lapply(1:p, function(j) { # from boolean matrix mxk of selected variables obtain the corresponding boolean # m-vector, and finally return the corresponding indices - seq_len(m)[apply(abs(params$phi[j, , ]) > thresh, 1, any)] + if (m>1) { + seq_len(m)[apply(abs(params$phi[j, , ]) > thresh, 1, any)] + } else { + if (any(params$phi[j, , ] > thresh)) + 1 + else + numeric(0) + } }) list(selected = selectedVariables, Rho = params$rho, Pi = params$pi) @@ -60,6 +67,8 @@ selectVariables <- function(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma } if (ncores > 1) parallel::stopCluster(cl) + + print(out) # Suppress models which are computed twice En fait, ca ca fait la comparaison de # tous les parametres On veut juste supprimer ceux qui ont les memes variables # sélectionnées