coxed.gam.tvc: Predict expected durations using the GAM method with...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/coxed.gam.tvc.R

Description

This function is called by coxed and is not intended to be used by itself.

Usage

1
2
coxed.gam.tvc(cox.model, newdata = NULL, k = -1, coef = NULL,
  b.ind = NULL, warn = TRUE)

Arguments

cox.model

The output from a Cox proportional hazards model estimated with the coxph function in the survival package or with the cph function in the rms package

newdata

An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used

k

The number of knots in the GAM smoother. The default is -1, which employs the choose.k function from the mgcv package to choose the number of knots

coef

A vector of new coefficients to replace the coefficients attribute of the cox.model. Used primarily for bootstrapping, to recalculate durations using new coefficients derived from a bootstrapped sample. If NULL, the original coefficients are employed

b.ind

A vector of observation numbers to pass to the estimation sample to construct the a bootstrapped sample with replacement

warn

If TRUE, displays warnings, and if FALSE suppresses them

Details

This function employs the GAM method of generating expected durations described in Kropko and Harden (2018). See coxed.gam for details. This code replicates the code for cox.gam, but works with data whose structure allows time-varying covariates, and requires using the time2 argument of the Surv function. This function requires the data to be reported as cumulative durations. The GAM model is fit using the ending times for each interval and using only the non-censored observations. Expected durations are drawn from this GAM as with coxed.gam.

Value

Returns a list containing the following components:

exp.dur A vector of predicted mean durations for the estimation sample if newdata is omitted, or else for the specified new data.
gam.model Output from the gam function in which the durations are fit against the exponentiated linear predictors from the Cox model.
gam.data Fitted values and confidence intervals from the GAM model.

Author(s)

Jonathan Kropko <jkropko@virginia.edu> and Jeffrey J. Harden <jharden2@nd.edu>

References

Kropko, J. and Harden, J. J. (2018). Beyond the Hazard Ratio: Generating Expected Durations from the Cox Proportional Hazards Model. British Journal of Political Science https://doi.org/10.1017/S000712341700045X

See Also

gam, coxed, coxed.gam

Examples

1
2
3
4
5
6
7
bs.surv <- Surv(time = boxsteffensmeier$start, time2 = boxsteffensmeier$te,
     event = boxsteffensmeier$cut_hi)
bs.cox <- coxph(bs.surv ~ ec + dem + south + iv, data = boxsteffensmeier, method = "breslow")
summary(bs.cox)

ed <- coxed.gam.tvc(bs.cox)
ed$exp.dur

coxed documentation built on Aug. 2, 2020, 9:07 a.m.