# S3 method for gam
predict(object, newdata, type, dispersion, se.fit = FALSE,na.action, terms,…)
gam
object, or one of its inheritants, such as a glm
or lm
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 gam
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)
.
se.fit = TRUE
.
If 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.
See the documentation of predict
for more details on the components returned. When newdata
are supplied, predict.gam
simply invokes
inheritance and gets predict.glm
to produce the parametric part
of the predictions. For each nonparametric term, predict.gam
reconstructs the
partial residuals and weights from the final iteration of the local
scoring algorithm. The appropriate smoother is called for each term,
with the appropriate xeval
argument (see s
or
lo
), and the prediction for that term is produced. The standard errors are based on an approximation given in Hastie
(1992). Currently predict.gam
does not produce standard errors for
predictions at newdata
. Warning: naive use of the generic
predict
can produce incorrect predictions when the newdata
argument is used, if the formula in object
involves
transformations such as sqrt(Age - min(Age))
.predict.glm
,
fitted
, expand.grid
data(gam.data)
gam.object <- gam(y ~ s(x,6) + z, data=gam.data)
predict(gam.object) # extract the additive predictors
data(gam.newdata)
predict(gam.object, gam.newdata, type="terms")
Run the code above in your browser using DataLab