Adjustments for CRAN upload
[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
1196a43d 15#' @param fast boolean to enable or not the C function call
3453829e 16#'
6af1d489
BA
17#' @return the grid of regularization parameters for the Lasso estimator. The output is a vector with nonnegative values that are relevant
18#' to be considered as regularization parameter as they are equivalent to a 0 in the regression parameter.
3453829e
BA
19#'
20#' @export
0ba1b11c 21computeGridLambda <- function(phiInit, rhoInit, piInit, gamInit, X, Y, gamma, mini,
3453829e
BA
22 maxi, eps, fast)
23{
24 n <- nrow(X)
25 p <- ncol(X)
26 m <- ncol(Y)
27 k <- length(piInit)
28
0ba1b11c 29 list_EMG <- EMGLLF(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda = 0,
3453829e
BA
30 X, Y, eps, fast)
31
32 grid <- array(0, dim = c(p, m, k))
33 for (j in 1:p)
34 {
35 for (mm in 1:m)
36 grid[j, mm, ] <- abs(list_EMG$S[j, mm, ])/(n * list_EMG$pi^gamma)
37 }
38 sort(unique(grid))
39}