Learn R Programming

plasso (version 0.1.3)

coef.plasso: Extract coefficients from a plasso object

Description

Extract coefficients for both Lasso and Post-Lasso from a plasso object.

Usage

# S3 method for plasso
coef(object, ..., s = NULL)

Value

List object containing coefficients that are associated with either all values along the lambda input sequence or for one specifically given lambda value for both the Lasso and Post-Lasso models respectively.

lasso

Sparse dgCMatrix-class object with Lasso coefficients

plasso

Sparse dgCMatrix-class object with Post-Lasso coefficients

Arguments

object

plasso object

...

Pass generic coef options

s

If Null, coefficients are returned for all lambda values. If a value is provided, the closest lambda value of the plasso object is used.

Examples

Run this code

# load toeplitz data
data(toeplitz)
# extract target and features from data
y = as.matrix(toeplitz[,1])
X = toeplitz[,-1]
# fit plasso to the data
p = plasso::plasso(X,y)
# get estimated coefficients along whole lambda sequence 
coefs = coef(p)
head(coefs$plasso)
# get estimated coefficients for specific lambda approximation
coef(p, s=0.05)

Run the code above in your browser using DataLab