R/soft.R

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 2, 2019, 12:40 p.m.