Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/coxed.gam.tvc.R
This function is called by coxed
and is not intended to be used by itself.
1 2 |
cox.model |
The output from a Cox proportional hazards model estimated
with the |
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 |
coef |
A vector of new coefficients to replace the |
b.ind |
A vector of observation numbers to pass to the estimation sample to construct the a bootstrapped sample with replacement |
warn |
If |
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
.
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. |
Jonathan Kropko <jkropko@virginia.edu> and Jeffrey J. Harden <jharden2@nd.edu>
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
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.