Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Predict

Model Predictions


Description

Predict is a generic function with, at present, a single method for "lm" objects, Predict.lm, which is a modification of the standard predict.lm method in the stats package, but with an additional vcov. argument for a user-specified covariance matrix for intreval estimation.

Usage

Predict(object, ...)

## S3 method for class 'lm'
Predict(object, newdata, se.fit = FALSE, 
  scale = NULL, df = Inf, 
  interval = c("none", "confidence", "prediction"), 
  level = 0.95, type = c("response", "terms"), 
  terms = NULL, na.action = na.pass,
  pred.var = res.var/weights, weights = 1, vcov., ...)

Arguments

object

a model object for which predictions are desired.

newdata, se.fit, scale, df, interval, level, type, terms, na.action, pred.var, weights

see predict.lm.

vcov.

optional, either a function to compute the coefficient covariance matrix of object (e.g., hccm) or a coefficient covariance matrix (as returned, e.g., by hccm).

...

arguments to pass down to Predict or predict methods.

Details

If there is no appropriate method for Predict, then a predict method is invoked. If there is a specific predict method for the primary class of object but only an inherited Predict method, then the predict method is invoked. Thus an object of class c("glm", "lm") will invoke method predict.glm rather than Predict.lm, but an object of class c("aov", "lm") will invoke Predict.lm rather than predict.lm.

Value

Author(s)

References

Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.

See Also

Examples

mod <- lm(interlocks ~ log(assets), data=Ornstein)
newd <- data.frame(assets=exp(4:12))
(p1 <- predict(mod, newd, interval="prediction"))
p2 <- Predict(mod, newd, interval="prediction", vcov.=vcov)
all.equal(p1, p2) # the same

(predict(mod, newd, se=TRUE))
(p3 <- Predict(mod, newd, se=TRUE, vcov.=hccm)) # larger SEs
p4 <- Predict(mod, newd, se=TRUE, vcov.=hccm(mod, type="hc3"))
all.equal(p3, p4) # the same

car

Companion to Applied Regression

v3.0-10
GPL (>= 2)
Authors
John Fox [aut, cre], Sanford Weisberg [aut], Brad Price [aut], Daniel Adler [ctb], Douglas Bates [ctb], Gabriel Baud-Bovy [ctb], Ben Bolker [ctb], Steve Ellison [ctb], David Firth [ctb], Michael Friendly [ctb], Gregor Gorjanc [ctb], Spencer Graves [ctb], Richard Heiberger [ctb], Pavel Krivitsky [ctb], Rafael Laboissiere [ctb], Martin Maechler [ctb], Georges Monette [ctb], Duncan Murdoch [ctb], Henric Nilsson [ctb], Derek Ogle [ctb], Brian Ripley [ctb], William Venables [ctb], Steve Walker [ctb], David Winsemius [ctb], Achim Zeileis [ctb], R-Core [ctb]
Initial release
2020-09-23

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.