predict.lqa: Prediction Method for lqa Fits

Description Usage Arguments Value Author(s) See Also Examples

View source: R/predict.lqa.R

Description

This function computes predictions based on an lqa object.

Usage

1
2
3
4
5
6
  ## 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 lqa. Usually this will be an object returned from the function lqa.

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.x must have the same number of entries as the estimated coefficient vectors has. That is it must include \hatĪ²_0 if your model includes an intercept.

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 pred.lqa as returned from predict.lqa.

...

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 predict.lqa.

tr.H

the trace of the hat matrix of the design matrix used to fit the model. This is just an extraction from the lqa.obj object that is used as argument of the internal loss functions.

n.newobs

the number of new observations.

eta.new

the estimated new predictors.

mu.new

the estimated new responses.

lqa.obj

the lqa.obj argument.

new.y

the new.y argument.

Author(s)

Jan Ulbricht

See Also

lqa, cv.lqa

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)))

lqa documentation built on May 30, 2017, 3:41 a.m.