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

Description Usage Arguments Details Value See Also Examples

View source: R/predict.cv.pcLasso.R

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

1
2
3
## S3 method for class '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.

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.

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.

See Also

cv.pcLasso and predict.pcLasso.

Examples

1
2
3
4
5
6
7
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")

pcLasso documentation built on Sept. 4, 2020, 1:08 a.m.