simPH (version 0.8.4)

coxsimLinear: Simulate quantities of interest for linear time constant covariates from Cox Proportional Hazards models

Description

Simulates relative hazards, first differences, hazard ratios, and hazard rates for linear time-constant covariates from Cox Proportional Hazard models. These can be plotted with simGG.

Usage

coxsimLinear(obj, b, qi = "Relative Hazard", Xj = NULL,
    Xl = NULL, means = FALSE, nsim = 1000, ci = 0.95,
    spin = FALSE)

Arguments

obj
a coxph class fitted model object.
b
character string name of the coefficient you would like to simulate.
qi
quantity of interest to simulate. Values can be "Relative Hazard", "First Difference", "Hazard Ratio", and "Hazard Rate". The default is qi = "Relative Hazard". If qi = "Hazard
Xj
numeric vector of fitted values for b to simulate for.
Xl
numeric vector of values to compare Xj to. Note if code = "Relative Hazard" only Xj is relevant.
means
logical, whether or not to use the mean values to fit the hazard rate for covaraiates other than b.
nsim
the number of simulations to run per value of X. Default is nsim = 1000. Note: it does not currently support models that include polynomials created by I.
ci
the proportion of simulations to keep. The default is ci = 0.95, i.e. keep the middle 95 percent. If spin = TRUE then ci is the confidence level of the shortest probability interval. Any value from 0 through
spin
logical, whether or not to keep only the shortest probability interval rather than the middle simulations. Currently not supported for hazard rates.

Value

  • a simlinear object

Details

coxsimLinear simulates relative hazards, first differences, and hazard ratios for time-constant covariates from models estimated with coxph using the multivariate normal distribution. These can be plotted with simGG.

References

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.

Liu, Ying, Andrew Gelman, and Tian Zheng. 2013. ''Simulation-Efficient Shortest Probability Intervals.'' Arvix. http://arxiv.org/pdf/1302.2142v1.pdf.

See Also

simGG, survival, strata, and coxph

Examples

Run this code
# Load Carpenter (2002) data
data("CarpenterFdaData")

# Load survival package
library(survival)

# Run basic model
M1 <- coxph(Surv(acttime, censor) ~ prevgenx + lethal +
            deathrt1 + acutediz + hosp01  + hhosleng +
            mandiz01 + femdiz01 + peddiz01 + orphdum +
            vandavg3 + wpnoavg3 + condavg3 + orderent +
            stafcder, data = CarpenterFdaData)

# Simulate Hazard Ratios
Sim1 <- coxsimLinear(M1, b = "stafcder",
                       Xj = c(1237, 1600),
                       Xl = c(1000, 1000),
                       spin = TRUE, ci = 0.99)

## dontrun
# Simulate Hazard Rates
# Sim2 <- coxsimLinear(M1, b = "stafcder",
#                       qi = "Hazard Rate",
#                       Xj = 1237,
#                       ci = 0.99, means = TRUE)

Run the code above in your browser using DataLab