predict()
on a
glm
object
glm
object and returns a matrix
of predictions.
predict.glm(object, newdata, type = c("link", "response", "terms"), se.fit = F, terms = labels(object), dispersion = NULL, ci.fit = F, pi.fit = F, conf.level = 0.95, conf.type = "p", ...)
glm
object.
newdata
.
"link"
(the default),
"response"
, or
"terms"
.
The default produces predictions on the scale of the additive
predictors, and with
newdata
missing,
predict()
is simply an
extractor function for this component of a
glm
object. If
"response"
is selected, the predictions are on the scale of the
response, and are monotone transformations of the additive predictors,
using the inverse link function. If
type="terms"
is selected, a
matrix of predictions is produced, one column for each term in the model.
TRUE
, pointwise standard errors are computed along with the predictions.
type="terms"
, the
terms=
argument can be used to specify which terms should be included; the default is
labels(object)
.
TRUE
, lower and upper confidence intervals are computed for the fit. Not available for
type="terms"
.
TRUE
, lower and upper prediction intervals are computed. These are confidence intervals for new observations, which will be wider than the confidence intervals for the fit. Not available for
type="terms"
.
conf.type="p"
, pointwise intervals are computed.
If
conf.type="s"
, simultaneous intervals are
computed. The simultaneous intervals adjust for the fact that we are
estimating a whole set of values, and hence are wider than the pointwise
intervals.
type="terms"
, a matrix of fitted terms is produced, with one column for each term in the model (or subset of these if the
terms=
argument is used). There is no column for the intercept, if present in the model, and each of the terms is centered so that their average over the original data is zero.
The matrix of fitted terms has a
"constant"
attribute which, when added to the sum of these centered terms, gives the additive predictor.
This function is a method for the generic function for class glm. It can be invoked by calling for an object x of the appropriate class, or directly by calling regardless of the class of the object.
predict.glm
can produce incorrect predictions when the
newdata
argument is used if the formula in
object
involves
data-dependenttransformations, such as
poly(Age, 3)
or
sqrt(Age - min(Age))
.
To overcome this for
glm
objects, use the
predict.gam
method explicitly.
Kyph.glm <- glm(kyphosis) predict(Kyph.glm, type = "terms")