Refresh package, suppress what we won't do right now. Focus on doc + debug
[valse.git] / pkg / R / computeGridLambda.R
CommitLineData
0ba1b11c 1#' computeGridLambda
3453829e
BA
2#'
3#' Construct the data-driven grid for the regularization parameters used for the Lasso estimator
4#'
5#' @param phiInit value for phi
6#' @param rhoInit for rho
7#' @param piInit for pi
8#' @param gamInit value for gamma
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
12#' @param mini minimum number of iterations in EM algorithm
13#' @param maxi maximum number of iterations in EM algorithm
14#' @param eps threshold to stop EM algorithm
15#'
16#' @return the grid of regularization parameters
17#'
18#' @export
0ba1b11c 19computeGridLambda <- function(phiInit, rhoInit, piInit, gamInit, X, Y, gamma, mini,
3453829e
BA
20 maxi, eps, fast)
21{
22 n <- nrow(X)
23 p <- ncol(X)
24 m <- ncol(Y)
25 k <- length(piInit)
26
0ba1b11c 27 list_EMG <- EMGLLF(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda = 0,
3453829e
BA
28 X, Y, eps, fast)
29
30 grid <- array(0, dim = c(p, m, k))
31 for (j in 1:p)
32 {
33 for (mm in 1:m)
34 grid[j, mm, ] <- abs(list_EMG$S[j, mm, ])/(n * list_EMG$pi^gamma)
35 }
36 sort(unique(grid))
37}