Learn R Programming

hdqr (version 1.0.2)

predict.cv.hdqr: Make Predictions from a `cv.hdqr` Object

Description

Generates predictions using a fitted `cv.hdqr()` object. This function utilizes the stored `hdqr.fit` object and an optimal value of `lambda` determined during the cross-validation process.

Usage

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

Value

Returns a matrix or vector of predicted values corresponding to the specified `lambda` values.

Arguments

object

A fitted `cv.hdqr()` object from which predictions are to be made.

newx

Matrix of new predictor values for which predictions are desired. This must be a matrix and is a required argument.

s

Specifies the value(s) of the penalty parameter `lambda` at which predictions are desired. The default is `s = "lambda.1se"`, representing the largest value of `lambda` such that the cross-validation error estimate is within one standard error of the minimum. Alternatively, `s = "lambda.min"` can be used, corresponding to the minimum of the cross-validation error estimate. If `s` is numeric, these are taken as the actual values of `lambda` to use for predictions.

...

Not used.

See Also

cv.hdqr, coef.cv.hdqr

Examples

Run this code
set.seed(315)
n <- 100
p <- 400
x <- matrix(data = rnorm(n * p, mean = 0, sd = 1), nrow = n, ncol = p)
beta_star <- c(c(2, 1.5, 0.8, 1, 1.75, 0.75, 0.3), rep(0, (p - 7)))
eps <- rnorm(n, mean = 0, sd = 1)
y <- x %*% beta_star + eps
tau <- 0.5
lam2 <- 0.01
cv.fit <- cv.hdqr(x = x, y = y, tau = tau, lam2 = lam2)
predict(cv.fit, newx = x[50:60, ], s = "lambda.min")

Run the code above in your browser using DataLab