| predict.lqa {lqa} | R Documentation |
Prediction Method for lqa Fits
Description
This function computes predictions based on an lqa object.
Usage
## S3 method for class 'lqa'
predict(object, new.x = NULL, new.y = NULL,
weights = rep(1, n.newobs), ...)
## S3 method for class 'pred.lqa'
print(x, ...)
Arguments
object |
a fitted object of class |
new.x |
Optionally, a new data frame from which to make the predictions. If omitted, the fitted linear predictors are used.
Note, if given |
new.y |
Optionally, a vector of new responses. If given, the deviance can be computed. |
weights |
an optional vector including weights of the new observations. |
x |
an object of class |
... |
additional arguments. |
Value
predict.lqa returns an object of class pred.lqa, i.e. this is a list with the following elements
deviance |
the deviance based on the new observations. This element is NULL if new.y = NULL, i.e. no new responses are used in |
tr.H |
the trace of the hat matrix of the design matrix used to fit the model. This is just an extraction from the |
n.newobs |
the number of new observations. |
eta.new |
the estimated new predictors. |
mu.new |
the estimated new responses. |
lqa.obj |
the |
new.y |
the |
Author(s)
Jan Ulbricht
See Also
Examples
set.seed (1111)
n <- 200
p <- 5
X <- matrix (rnorm (n * p), ncol = p)
X[,2] <- X[,1] + rnorm (n, sd = 0.1)
X[,3] <- X[,1] + rnorm (n, sd = 0.1)
true.beta <- c (1, 2, 0, 0, -1)
y <- drop (X %*% true.beta) + rnorm (n)
cv.obj1 <- cv.lqa (y, X, intercept = TRUE, lambda.candidates =
list (c (0.001, 0.05, 1, 5, 10), c (0.1, 0.5, 1)), family = gaussian (),
penalty.family = fused.lasso, loss.func = "gcv.loss")
cv.obj1
beta0.hat <- coef (cv.obj1$best.obj)[1] # extracts the estimated intercept
pred.obj <- predict.lqa (cv.obj1$best.obj, new.x = c (beta0.hat, 1, 2, 3, 4, 5))
pred.obj
cv.obj2 <- cv.lqa (y, X, intercept = TRUE, lambda.candidates =
list (c (0.001, 0.05, 1, 5, 10), c (0.1, 0.5, 1)), family = gaussian (),
penalty.family = fused.lasso, n.fold = 5, loss.func = "squared.loss")
cv.obj2
beta0.hat <- coef (cv.obj2$best.obj)[1] # extracts the estimated intercept
predict.lqa (cv.obj2$best.obj, new.x = cbind (beta0.hat, matrix (1 : 10, nrow = 2)))