Commit | Line | Data |
---|---|---|
d1531659 | 1 | #' Construct the data-driven grid for the regularization parameters used for the Lasso estimator |
2 | #' @param phiInit value for phi | |
e166ed4e BA |
3 | #' @param rhoInt value for rho |
4 | #' @param piInit value for pi | |
d1531659 | 5 | #' @param gamInit value for gamma |
e166ed4e BA |
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 | |
d1531659 | 9 | #' @return the grid of regularization parameters |
10 | #' @export | |
11 | #----------------------------------------------------------------------- | |
39046da6 BA |
12 | gridLambda = function(phiInit, rhoInit, piInit, gamInit, X, Y, gamma, mini, maxi, tau) |
13 | { | |
e166ed4e BA |
14 | n = nrow(X) |
15 | p = dim(phiInit)[1] | |
16 | m = dim(phiInit)[2] | |
17 | k = dim(phiInit)[3] | |
18 | ||
b4476024 | 19 | list_EMG = .Call("EMGLLF_core",phiInit,rhoInit,piInit,gamInit,mini,maxi,1,0,X,Y,tau) |
e166ed4e BA |
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) | |
39046da6 | 31 | } |