Predict

0th

Percentile

Model Predictions

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.

Keywords
models
Usage
Predict(object, ...)# S3 method for 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

See predict and predict.lm.

References

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

predict, predict.lm

• Predict
• Predict.lm
Examples
# NOT RUN {
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
# }

Documentation reproduced from package car, version 3.0-0, License: GPL (>= 2)

Community examples

hariehkr045@gmail.com at Apr 5, 2020 car v3.0-7

## example data$y=c(1000, 1125, 1087, 1070, 1100, 1150, 1250, 1150, 1100, 1350, 1275, 1375, 1175, 1200, 1175, 1300, 1260, 1330, 1325, 1200, 1225, 1090, 1075, 1080, 1080, 1180, 1225, 1175, 1250, 1250, 750, 1125, 700, 900, 900, 850) data$x=c(1050, 1150, 1213, 1275, 1300, 1300, 1400, 1400, 1250, 1830, 1350, 1450, 1300, 1300, 1275, 1375, 1285, 1400, 1400, 1285, 1275, 1135, 1250, 1275, 1150, 1250, 1275, 1225, 1280, 1300, 1250, 1175, 1300, 1250, 1300, 1200) model_lm<-lm(Y~X,data = data) summary(model_lm) ## Predict data$pred<-predict(model_lm,newdata = data)# These are the predicted values #predict(model_lm,newdata = data.frame(X = c(1,2,3))) ## Evaluate library(DMwR) regr.eval(data$Y,data$pred) #Plotting the residuals and checking the assumptions plot(model_lm$residuals)