add_hazard: Add predicted hazard to data set

Description Usage Arguments See Also Examples

Description

Add predicted hazard to data set

Add cumulative hazard estimate to data set

Usage

1
2
3
4
5
add_hazard(newdata, object, type = c("response", "link"), ci = TRUE,
  se.mult = 2, overwrite = FALSE, time_variable = NULL, ...)

add_cumhazard(newdata, object, ci = TRUE, se.mult = 2, overwrite = FALSE,
  time_variable = NULL, interval_length = quo(intlen), ...)

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.

object

a fitted gam object as produced by gam().

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

ci

Logical indicating whether to iclude confidence intervals. Defaults to TRUE

se.mult

Factor by which standard errors are multiplied for calculating the confidence intervals.

overwrite

Should hazard columns be overwritten if already present in the data set? Defaults to FALSE. If TRUE, columns with names c("hazard", "se", "lower", "upper") will be overwritten.

time_variable

Name of the variable used for the baseline hazard. If not given, defaults to "tend" for gam fits, else "interval". The latter is assumed to be a factor, the former numeric.

...

Further arguments passed to predict.gam and get_hazard

interval_length

quosure providing the name of the variable in newdata containing the interval lengths. Defaults to intlen.

See Also

predict.gam, add_cumhazard

predict.gam, add_hazard

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
library(mgcv)
data("veteran", package="survival")
ped <- split_data(Surv(time, status)~. cut=seq(0, 500, by=100), data=veteran, 
	id="id")
pam <- gam(ped_status ~ s(tend, k=5), data = ped, family=poisson(), offset=offset)
pinfo <- ped_info(ped)
add_hazard(pinfo, pam)

## End(Not run)

adibender/pam documentation built on May 10, 2019, 5:54 a.m.