R/lasso_d.R

Defines functions lasso_d

lasso_d <- function(x,lambda,a=3){

  ## -----------------------------------------------------------------------------------------------------------------
  ## The name of the function: lasso_d
  ## -----------------------------------------------------------------------------------------------------------------
  ## Description:
  ##            Calculating the derivative of the lasso
  ## -----------------------------------------------------------------------------------------------------------------
  ## Required preceding functions or packages: No
  ## -----------------------------------------------------------------------------------------------------------------
  ## Input:
  ## @ x: a float value or a vector, the independent variable in the lasso.
  ## @ lambda: a float value, the tuning parameter in the MCP.
  ## -----------------------------------------------------------------------------------------------------------------
  ## Output:
  ## @ rho: the derivative of the lasso.
  ## -----------------------------------------------------------------------------------------------------------------

  if(lambda!=0){
    rho <- a/a * lambda * (abs(x) > 0)
  } else{
    rho=0
  }
  return(rho)
}

Try the HeteroGGM package in your browser

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

HeteroGGM documentation built on Feb. 11, 2021, 5:09 p.m.