Lasso with glmnet

Description

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

Usage

## Model term constructor function.
gnet(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”), default is “bic”.

The gnet() constructor differs from la. While la() implements a general framework for Lasso-type penalties (including group, ordinal, and nominal fusion constraints) and estimates the corresponding penalty matrices internally via iteratively reweighted least squares, gnet() delegates estimation entirely to glmnet. As a consequence, gnet() provides a standard Lasso model term based on a model.matrix representation, but does not support structured fusion penalties or custom penalty matrices. Instead, it offers a fast and robust interface to the glmnet algorithm and automatic selection of the shrinkage parameter using information criteria.

Value

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

References

Friedman J, Tibshirani R, Hastie T (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1-22. doi:10.18637/jss.v033.i01

Tay JK, Narasimhan B, Hastie T (2023). Elastic Net Regularization Paths for All Generalized Linear Models. Journal of Statistical Software, 106(1), 1-31. doi:10.18637/jss.v106.i01

See Also

la, 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 ~ gnet(~Flc + Ac + loc) |
  gnet(~Flc + Ac + loc) |
  gnet(~Flc + Ac + loc) |
  gnet(~Flc + Ac + loc)

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

## summary, shows the estimated degrees of freedom
## for each model term, note that for parameters nu
## and tau model terms where not included as
## the deviance would increase
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"))