- # If no coefficients have been selected, we provide the zero matrix
- # We delete zero coefficients: vec = indices of zero values
- if (atLeastOneSelectedVariable)
- {
- vec <- c()
- for (j in c(1:p))
- {
- if (selectedVariables(j,1) != 0)
- vec <- c(vec,j)
- # Else ( NOTE: [auder] else ?! TODO: explain? )
- # we provide the indices of relevant coefficients
- A1[,1,lambdaIndex] <- c(vec,rep(0,p-length(vec)))
- A1[1:length(vec),2:(m+1),lambdaIndex] <- selectedVariables[vec,]
- A2[,1,lambdaIndex] <- 1:p
- A2[,2:(m+1),lambdaIndex] <- discardedVariables
- Rho[,,,lambdaIndex] <- rho
- Pi[,lambdaIndex] <- pi
- }
- }
- }
+ #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,,]) > seuil, 1, any ) ]
+ })