R/GiveLambdas.R

Defines functions give.lambdas

Documented in give.lambdas

#' Regularization parameter generator for spams.fistaTree
#'
#' @description Provides regularization parameters used for cross validation in the estimation stage.
#'
#' @details Caution: the suggested values for i is between -14 to 14, but I have not found any paper for the reason. Also, the
#' SPAMS paper use the model error as the input vector \eqn{\sigma} instead of the original response vector \eqn{y}, but in practice
#' the current choice works better to achieve the wanted sparsity. Reasons unknown, function to be included.
#'
#'
#'
#' @param i a number. (Its true interpretation is unknown, but the purpose is to set the starting and end points for grid search)
#' @param Y a vector. The response vector.
#'
#' @return value of lambda
#' @export
#'
#' @examples
#' lam <- map_dbl(seq(-12,12), ~ give.lambdas.inter(.x, Y = Y.single))




give.lambdas <- function(i, Y){
  Y <- scale(Y)
  lam <- 2**(i/4) * sqrt(log(length(Y)))   # replace var Y by 1
  return(lam)
}
yymmhaha/PackPaper1 documentation built on May 24, 2019, 8:55 a.m.