coef.cv.plasso {plasso}R Documentation

Extract coefficients from a cv.plasso object

Description

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

Usage

## S3 method for class 'cv.plasso'
coef(object, ..., s = c("optimal", "all"), se_rule = 0)

Arguments

object

cv.plasso object

...

Pass generic coef options

s

Determines whether coefficients are extracted for all values of lambda ("all") or only for the optimal lambda ("optimal") according to the specified standard error-rule.

se_rule

If equal to 0, predictions from cross-validated MSE minimum (default). Negative values go in the direction of smaller models, positive values go in the direction of larger models (e.g. se_rule=-1 creates the standard 1SE rule). This argument is not used for s="all".

Value

List object containing coefficients for both the Lasso and Post-Lasso models respectively.

lasso

Sparse dgCMatrix with Lasso coefficients

plasso

Sparse dgCMatrix with Post-Lasso coefficients

Examples


# load toeplitz data
data(toeplitz)
# extract target and features from data
y = as.matrix(toeplitz[,1])
X = toeplitz[,-1]
# fit cv.plasso to the data
p.cv = plasso::cv.plasso(X,y)
# get estimated coefficients along whole lambda sequence
coefs = coef(p.cv, s="all")
head(coefs$plasso)
# get estimated coefficients for optimal lambda value according to 1-standard-error rule
coef(p.cv, s="optimal", se_rule=-1)


[Package plasso version 0.1.2 Index]