correction typo
[valse.git] / R / gridLambda.R
1 #' Construct the data-driven grid for the regularization parameters used for the Lasso estimator
2 #' @param phiInit value for phi
3 #' @param rhoInt value for rho
4 #' @param piInit value for pi
5 #' @param gamInit value for gamma
6 #' @param mini minimum number of iterations in EM algorithm
7 #' @param maxi maximum number of iterations in EM algorithm
8 #' @param tau threshold to stop EM algorithm
9 #' @return the grid of regularization parameters
10 #' @export
11 #-----------------------------------------------------------------------
12 gridLambda = function(phiInit, rhoInit, piInit, gamInit, X, Y, gamma, mini, maxi, tau)
13 {
14 n = nrow(X)
15 p = dim(phiInit)[1]
16 m = dim(phiInit)[2]
17 k = dim(phiInit)[3]
18
19 list_EMG = .Call("EMGLLF_core",phiInit,rhoInit,piInit,gamInit,mini,maxi,1,0,X,Y,tau)
20
21 grid = array(0, dim=c(p,m,k))
22 for (i in 1:p)
23 {
24 for (j in 1:m)
25 grid[i,j,] = abs(list_EMG$S[i,j,]) / (n*list_EMG$pi^gamma)
26 }
27 grid = unique(grid)
28 grid = grid[grid <=1]
29
30 return(grid)
31 }