coef.glmnet: Extract coefficients from a glmnet object

View source: R/glmnet.R

coef.glmnetR Documentation

Extract coefficients from a glmnet object

Description

Extract coefficients from a glmnet object

Usage

## S3 method for class 'glmnet'
coef(object, s = NULL, exact = FALSE, ...)

Arguments

object

Fitted "glmnet" model object or a "relaxed" model (which inherits from class "glmnet").

s

Value(s) of the penalty parameter lambda at which predictions are required. Default is the entire sequence used to create the model.

exact

This argument is relevant only when predictions are made at values of s (lambda) different from those used in the fitting of the original model. Not available for "relaxed" objects. If exact=FALSE (default), then the predict function uses linear interpolation to make predictions for values of s (lambda) that do not coincide with those used in the fitting algorithm. While this is often a good approximation, it can sometimes be a bit coarse. With exact=TRUE, these different values of s are merged (and sorted) with object$lambda, and the model is refit before predictions are made. In this case, it is required to supply the original data x= and y= as additional named arguments to predict() or coef(). The workhorse predict.glmnet() needs to update the model, and so needs the data used to create it. The same is true of weights, offset, penalty.factor, lower.limits, upper.limits if these were used in the original call. Failure to do so will result in an error.

...

additional arguments (ignored)

Value

a data.frame object

See Also

predict.glmnet, glmnet


the-mad-statter/washu documentation built on May 11, 2023, 7:24 p.m.