X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=R%2FgridLambda.R;h=855b4a6f8fa0ea5d9d0354eae97f0bf94b89689c;hp=87e92997a2bc1c4c2d99f0a0786737d98d30a9bb;hb=31463ab809c0195273ff2760606ea65361d721ab;hpb=493a35bfea6d1210c94ced8fbfe3e572f0389ea5 diff --git a/R/gridLambda.R b/R/gridLambda.R index 87e9299..855b4a6 100644 --- a/R/gridLambda.R +++ b/R/gridLambda.R @@ -1,29 +1,31 @@ -gridLambda = function(phiInit, rhoInit, piInit, gamInit, X, Y, gamma, mini, maxi, tau){ - n = nrow(X) - p = dimension(phiInit)[1] - m = dimension(phiInit)[2] - k = dimension(phiInit)[3] - list_EMG = EMGLLF(phiInit,rhoInit,piInit,gamInit,mini,maxi,1,0,X,Y,tau) - #.C("EMGLLF", phiInit = phiInit, rhoInit = rhoInit, ...) - phi = list_EMG[[1]] - rho = list_EMG[[2]] - pi = list_EMG[[3]] - S = list_EMG[[5]] - - grid = array(0, dim=c(p,m,k)) - for(i in 1:p){ - for(j in 1:m){ - grid[i,j,] = abs(S[i,j,]) / (n*pi^gamma) - } - } - grid = unique(grid) - grid = grid[grid <=1 ] - - return(grid) -} +#' Construct the data-driven grid for the regularization parameters used for the Lasso estimator +#' @param phiInit value for phi +#' @param rhoInt value for rho +#' @param piInit value for pi +#' @param gamInit value for gamma +#' @param mini minimum number of iterations in EM algorithm +#' @param maxi maximum number of iterations in EM algorithm +#' @param tau threshold to stop EM algorithm +#' @return the grid of regularization parameters +#' @export +#----------------------------------------------------------------------- +gridLambda = function(phiInit, rhoInit, piInit, gamInit, X, Y, gamma, mini, maxi, tau) +{ + n = nrow(X) + p = dim(phiInit)[1] + m = dim(phiInit)[2] + k = dim(phiInit)[3] + + list_EMG = .Call("EMGLLF_core",phiInit,rhoInit,piInit,gamInit,mini,maxi,1,0,X,Y,tau) + grid = array(0, dim=c(p,m,k)) + for (i in 1:p) + { + for (j in 1:m) + grid[i,j,] = abs(list_EMG$S[i,j,]) / (n*list_EMG$pi^gamma) + } + grid = unique(grid) + grid = grid[grid <=1] -#test pour voir si formatage à la fin de grid ok -grid= array(mvrnorm(5*5*2,1,1), dim=c(5,5,2)) -grid = unique(grid) -grid = grid[grid<= 1 ] + return(grid) +}