#' Soft threshold function.
#'
#' @param a Numeric vector of values to threshold.
#' @param b The soft thresholded value.
#'
#' @return Numeric vector of the soft-thresholded values of a.
#'
#' @author Taylor Arnold, Michael Kane, Bryan Lewis.
#'
#' @references
#'
#' Taylor Arnold, Michael Kane, and Bryan Lewis.
#' \emph{A Computational Approach to Statistical Learning}.
#' Chapman & Hall/CRC Texts in Statistical Science, 2019.
#'
#' @export
casl_util_soft_thresh <-
function(a, b)
{
a[abs(a) <= b] <- 0
a[a > 0] <- a[a > 0] - b
a[a < 0] <- a[a < 0] + b
a
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.