add_term: Add info about term effects to data set

Description Usage Arguments See Also Examples

Description

Adds the contribution (plus confidence intervals) of a specific term to the linear predictor to the provided data. Largely a wrapper to predict.gam, with type="terms". Thus most arguments and their documentation below is from predict.gam.

Usage

1
2
add_term(newdata, object, term, se.fit = TRUE, type = "terms",
  se.mult = 2, relative = FALSE, ...)

Arguments

newdata

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}.

object

a fitted gam object as produced by gam().

term

A character (vector) or regular expression indicating for which term(s) information should be extracted and added to data set.

se.fit

when this is TRUE (not default) standard error estimates are returned for each prediction.

type

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).

se.mult

The factor by which standard errors are multiplied to form confidence intervals.

relative

If TRUE, calculates relative risk contribution, that is (X-\bar{X})'β and respective confidence intervals if se.fit = TRUE. Defaults to FALSE.

...

Further arguments passed to predict.gam

See Also

predict.gam, add_hazard

Examples

1
2
3
4
5
6
7
library(mgcv)
data("veteran", package="survival")
ped <- split_data(Surv(time, status)~ age, data=veteran, id="id")
pam <- gam(ped_status ~ s(tend),
	data = ped, family=poisson(), offset=offset)
pinf <- ped_info(ped)
add_term(pinf, pam, term="tend")

adibender/pamm documentation built on May 14, 2019, 5:22 p.m.