R/soft.R

Defines functions soft

Documented in soft

#' Soft thresholding for elnet_coord
#'
#' @param rx rx object from elnet_coord function, product of partial residual
#' and a column of x
#' @param lambda lambda value specified in elnet_coord
#' @param alpha alpha value specified in elnet_coord
#'
#' @return Soft thresholded rx value
#'
#'
soft <- function(rx, lambda, alpha){
  return(sign(rx)* max(0, (abs(rx) - lambda * alpha /2)))
}
stevebroll/stsci6520hw2 documentation built on Dec. 23, 2021, 5:32 a.m.