Lasso with glmnet

Description

Constructor function for estimating Lasso model terms using the glmnet package.

Usage

## Model term constructor function.
lasso(formula, ...)

Arguments

formula A formula specifying the covariates that should be estimated using the Lasso implementation in glmnet.
Control arguments to be passed to function glmnet.

Details

The formula is used to generate a model.matrix, which is then used for estimation. Note that the data is not scaled, so the user must scale the covariates manually. The function glmnet is employed within the backfitting algorithm implemented in RS. The optimal Lasso shrinkage parameter is selected based on an information criterion. Available options for the criterion are criterion = c(“gcv”, “aic”, “gaic”, “aicc”, “bic”).

Value

The lasso() function is used internally within gamlss2 and provides the necessary details for estimating Lasso-type model terms using function glmnet.

See Also

gamlss2, specials.

Examples

library("gamlss2")


data("rent", package = "gamlss.data")

## transform numeric to factor variables
rent$Flc <- cut(rent$Fl, breaks = seq(20, 160, by = 10),
  include.lowest = TRUE)
rent$Ac <- cut(rent$A, breaks = seq(1890, 1990, by = 10),
  include.lowest = TRUE)

## set up the model formula for a BCT model
f <- R ~ lasso(~Flc + Ac + loc) |
  lasso(~Flc + Ac + loc) |
  lasso(~Flc + Ac + loc) |
  lasso(~Flc + Ac + loc)

## estimation
b <- gamlss2(f, data = rent, family = BCT)

## summary, shows the estimated degrees of freedom
## for each model term
summary(b)

## extract fitted special lasso model term
st <- specials(b, model = "mu")

## plot coefficient paths
plot(st$model)

## same for sigma
plot(specials(b, model = "sigma", elements = "model"))