predict.lm {base} | R Documentation |
predict.lm
produces predicted values, obtained by evaluating
the regression function in the frame newdata
(which defaults to
model.frame(object)
. 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
.
predict[.lm](object, newdata, se.fit = FALSE, scale = NULL, df = Inf, interval = c("none", "confidence", "prediction"), level = 0.95, type = c("response", "terms"), terms = NULL, ...)
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 |
The model fitting function lm
, predict
.
## 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)