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

Description Usage Arguments Details Value See Also Examples

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

Description

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

Usage

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

Arguments

object

Fitted "cv.fwelnet" 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.

...

Other arguments to be passed to predict.fwelnet.

Details

This function makes it easier to use the results of cross-validation to make a prediction.

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.

See Also

cv.fwelnet and predict.fwelnet.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(1)
n <- 100; p <- 20
x <- matrix(rnorm(n * p), n, p)
beta <- matrix(c(rep(2, 5), rep(0, 15)), ncol = 1)
y <- x %*% beta + rnorm(n)
z <- cbind(1, abs(beta) + rnorm(p))

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

kjytay/fwelnet documentation built on June 9, 2020, 1:39 p.m.