pcLasso (version 1.1)

predict.cv.pcLasso: Make predictions from a "cv.pcLasso" object

Description

This function returns the predictions for a new data matrix from a cross-validated pcLasso model by using the stored "glmfit" object and the optimal value chosen for lambda.

Usage

# S3 method for cv.pcLasso
predict(object, xnew, s = c("lambda.1se",
  "lambda.min"), ...)

Arguments

object

Fitted "cv.pcLasso" object.

xnew

Matrix of new values for x at which predictions are to be made.

s

Value of the penalty parameter lambda at which predictions are required. Default is the value s="lambda.1se" stored in the CV fit. Alternatively, s="lambda.min" can be used.

...

Potentially other arguments to be passed to and from methods; currently not in use.

Value

Predictions which the cross-validated model makes for xnew at the optimal value of lambda. Note that the default is the "lambda.1se" for lambda, to make this function consistent with cv.glmnet in the glmnet package. The output is predictions of \(E(y|xnew)\): these are probabilities for the binomial family.

Details

This function makes it easier to use the results of cross-validation to make a prediction. Note that xnew should have the same number of columns as the original feature space, regardless of whether the groups are overlapping or not.

See Also

cv.pcLasso and predict.pcLasso.

Examples

Run this code
# NOT RUN {
set.seed(1)
x <- matrix(rnorm(100 * 20), 100, 20)
y <- rnorm(100)

cvfit <- cv.pcLasso(x, y, ratio = 0.8)
predict(cvfit, xnew = x[1:5, ])
predict(cvfit, xnew = x[1:5, ], s = "lambda.min")

# }

Run the code above in your browser using DataLab