Adds the contribution of a specific term to the
linear predictor to the data specified by newdata.
Essentially a wrapper to predict.gam, with type="terms".
Thus most arguments and their documentation below is from predict.gam.
add_term(newdata, object, term, se.fit = TRUE, type = "terms",
se_mult = 2, relative = FALSE, ...)A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If newdata is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with link{linear.functional.terms}.
a fitted gam object as produced by gam().
A character (vector) or regular expression indicating for which term(s) information should be extracted and added to data set.
when this is TRUE (not default) standard error estimates are returned for each prediction.
When this has the value "link" (default) the linear predictor (possibly with
associated standard errors) is returned. When type="terms" each component of the
linear predictor is returned seperately (possibly with standard errors): this includes
parametric model components, followed by each smooth component, but excludes
any offset and any intercept. type="iterms" is the same, except that any standard errors
returned for smooth components will include the uncertainty about the intercept/overall mean. When
type="response" predictions
on the scale of the response are returned (possibly with approximate
standard errors). When type="lpmatrix" then a matrix is returned
which yields the values of the linear predictor (minus any offset) when
postmultiplied by the
parameter vector (in this case se.fit is ignored). The latter
option is most useful for getting variance estimates for quantities derived from
the model: for example integrated quantities, or derivatives of smooths. A
linear predictor matrix can also be used to implement approximate prediction
outside R (see example code, below).
The factor by which standard errors are multiplied to form confidence intervals.
If TRUE, calculates relative risk contribution,
that is \((X-\bar{X})'\beta\) and respective confidence intervals
if se.fit = TRUE. Defaults to FALSE.
Further arguments passed to predict.gam
# NOT RUN {
ped <- tumor[1:50,] %>% as_ped(Surv(days, status)~ age)
pam <- mgcv::gam(ped_status ~ s(tend)+age, data = ped, family=poisson(), offset=offset)
ped_info(ped) %>% add_term(pam, term="tend")
# }
Run the code above in your browser using DataLab