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