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