predict.plasso {plasso}R Documentation

Predict for (Post-) Lasso models

Description

Prediction for (Post-) Lasso models.

Usage

## S3 method for class 'plasso'
predict(
  object,
  ...,
  newx = NULL,
  type = c("response", "coefficients"),
  s = NULL
)

Arguments

object

Fitted plasso model object

...

Pass generic predict options

newx

Matrix of new values for x at which predictions are to be made. If no value is supplied, x from fitting procedure is used. This argument is not used for type="coefficients".

type

Type of prediction required. "response" returns fitted values, "coefficients" returns beta estimates.

s

If Null, prediction is done for all lambda values. If a value is provided, the closest lambda value of the plasso object is used.

Value

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

lasso

Matrix with Lasso predictions or coefficients

plasso

Matrix with Post-Lasso predictions or coefficients

Examples


# 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)
# predict fitted values along whole lambda sequence 
pred = predict(p)
head(pred$plasso)
# get estimated coefficients for specific lambda approximation
predict(p, type="coefficients", s=0.05)


[Package plasso version 0.1.2 Index]