predict.cv.plasso {plasso} | R Documentation |
Predict after cross-validated (Post-) Lasso
Description
Prediction for cross-validated (Post-) Lasso.
Usage
## S3 method for class 'cv.plasso'
predict(
object,
...,
newx = NULL,
type = c("response", "coefficients"),
s = c("optimal", "all"),
se_rule = 0
)
Arguments
object |
Fitted |
... |
Pass generic |
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 |
Type of prediction required. |
s |
Determines whether prediction is done for all values of lambda ( |
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. |
Value
List object containing either fitted values or coefficients for both the Lasso and Post-Lasso models respectively.
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 cv.plasso to the data
p.cv = plasso::cv.plasso(X,y)
# predict fitted values along whole lambda sequence
pred = predict(p.cv, s="all")
head(pred$plasso)
# predict fitted values for optimal lambda value (according to cross-validation)
pred_optimal = predict(p.cv, s="optimal")
head(pred_optimal$plasso)
# predict fitted values for new feature set X
X_new = head(X, 10)
pred_new = predict(p.cv, newx=X_new, s="optimal")
pred_new$plasso
# get estimated coefficients along whole lambda sequence
coefs = predict(p.cv, type="coefficients", s="all")
head(coefs$plasso)
# get estimated coefficients for optimal lambda value according to 1-standard-error rule
predict(p.cv, type="coefficients", s="optimal", se_rule=-1)