Predicting from Linear Model Fits
Usage
predict[.lm](object, newdata = model.frame(object), se.fit = FALSE,
scale = NULL, df = Inf,
interval = c("none", "confidence", "prediction"), level = 0.95)
Description
predict.lm produces predicted values, obtained by evaluating
the regression function in the frame newdata. If the logical
se.fit is TRUE, standard errors of the predictions are
calculated. If the numeric argument scale is set (with optional
df), it is used as the residual standard deviation in the
computation of the standard errors, otherwise this is extracted from
the model fit. Setting intervals specifies computation of
confidence or prediction (tolerance) intervals at the specified
level.Value
predict.lm produces a vector of predictions or a matrix of
predictions and bounds with column names fit, lwr, and
upr if interval is set. If se.fit is
TRUE, a list with the following components is returned
fit
|
vector or matrix as above
|
se.fit
|
standard error of predictions
|
residual.scale
|
residual standard deviations
|
df
|
degrees of freedom for residual
|
See Also
The model fitting function lm, predict.Examples
## Predictions
x <- rnorm(15)
y <- x + rnorm(15)
predict(lm(y ~ x))
predict(lm(y ~ x), data.frame(x = seq(-3, 3, 0.1)), se = TRUE)