predict.hdqr {hdqr}R Documentation

Make Predictions from a 'hdqr' Object

Description

Produces fitted values for new predictor data using a fitted 'hdqr()' object.

Usage

## S3 method for class 'hdqr'
predict(object, newx, s = NULL, ...)

Arguments

object

Fitted 'hdqr()' object from which predictions are to be derived.

newx

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

s

Values of the penalty parameter 'lambda' for which predictions are requested. Defaults to the entire sequence used during the model fit.

...

Not used.

Details

This function generates predictions at specified 'lambda' values from a fitted 'hdqr()' object. It is essential to provide a new matrix of predictor values ('newx') at which these predictions are to be made.

Value

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

See Also

hdqr, coef.hdqr

Examples

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
fit <- hdqr(x = x, y = y, tau = tau, lam2 = lam2)
preds <- predict(fit, newx = tail(x), s = fit$lambda[3:5])

[Package hdqr version 1.0.1 Index]