coxed.gam.tvc {coxed}R Documentation

Predict expected durations using the GAM method with time-varying covariates

Description

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

Usage

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

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

[Package coxed version 0.3.3 Index]