An R package for simulating and graphing non-proportional hazards (relative hazards, first differences, and hazard ratios) from Cox Proportional Hazard (PH) models. It can also simulate and graph stratified non-proportional hazard rates from Cox models.
The package includes four functions:
tvc: a function for creating time interactions. Currently supports
'log', and exponentiation (
coxsimtvc: a function for simulating time-varying hazards (relative hazards, first differences, and hazard ratios) from a Cox PH model estimated using
coxph from the survival package. For more information see this blog post. If
strata = TRUE the function will calculate time-varying hazard ratios for multiple strata estimated from a stratified Cox PH model.
ggtvc: uses ggplot2 to graph the simulated relative hazards, first differences, hazard ratios or stratified hazard rates.
ggfitStrata: a function to plot fitted stratified survival curves estimated from
survfit using ggplot2. This function builds on the survival package's
plot.survfit command. One major advantage is the ability to split the survival curves into multiple plots and arrange them in a grid. This makes it easier to examine many strata at once. Otherwise they can be very bunched up.
Use the devtools command
install_github to install simtvc in R. Here is the exact code for installing the most recent stable version:
devtools::install_github("simtvc", "christophergandrud", ref = "v0.04")
For more information about simulating parameter estimates to make interpretation of results easier see:
Licht, Amanda A. 2011. “Change Comes with Time: Substantive Interpretation of Nonproportional Hazards in Event History Analysis.” Political Analysis 19: 227–43.
King, Gary, Michael Tomz, and Jason Wittenberg. 2000. “Making the Most of Statistical Analyses: Improving Interpretation and Presentation.” American Journal of Political Science 44(2): 347–61.
For more information about stratified Cox PH models (and frailties, which I am working to incorporate in future versions) see:
Box-Steffensmeier, Janet M, and Suzanna De Boef. 2006. “Repeated Events Survival Models: the Conditional Frailty Model.” Statistics in Medicine 25(20): 3518–33.
For an example of how non-proportional hazard results were often presented before
simtvc see (some of the problems I encountered in this paper were a major part of why I'm developing this package):
Gandrud, Christopher. 2012. “The Diffusion of Financial Supervisory Governance Ideas.” Review of International Political Economy.
This package is in the early stages of development. I intend to expand the quantities of interest that can be simulated and graphed for Cox PH models. I am also currently working on functions that can simulate and graph hazard ratios estimated from Fine and Gray competing risks models.
I am also working on a way to graph hazard ratios with frailties.