R/soft.R

Defines functions soft

soft <-
function(a,lam,penalize.diagonal){ # if last argument is FALSE, soft-threshold a matrix but don't penalize the diagonal
  out <- sign(a)*pmax(0, abs(a)-lam)
  if(!penalize.diagonal) diag(out) <- diag(a)
  return(out)
}

Try the JGL package in your browser

Any scripts or data that you put into this service are public.

JGL documentation built on May 29, 2024, 7:11 a.m.