Simulate quantities of interest for covariates from Cox Proportional Hazards models that are not interacted with time or nonlinearly transformed

Share:

Description

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

Usage

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

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 Rate" and the coxph model has strata, then hazard rates for each strata will also be calculated.

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. Note: EXPERIMENTAL. lines are not currently supported in simGG if means = TRUE.

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 1 may be used.

spin

logical, whether or not to keep only the shortest probability interval rather than the middle simulations. Currently not supported for Hazard Rates.

extremesDrop

logical whether or not to drop simulated quantity of interest values that are Inf, NA, NaN and > 1000000 for spin = FALSE or > 800 for spin = TRUE. These values are difficult to plot simGG and may prevent spin from finding the central interval.

Details

coxsimLinear simulates relative hazards, first differences, and hazard ratios for linear covariates that are not interacted with time or nonlinearly transformed from models estimated with coxph using the multivariate normal distribution. These can be plotted with simGG.

Value

a simlinear, coxsim object

References

Gandrud, Christopher. 2015. simPH: An R Package for Illustrating Estimates from Cox Proportional Hazard Models Including for Interactive and Nonlinear Effects. Journal of Statistical Software. 65(3)1-20.

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.simlinear, survival, strata, and coxph

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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),
                     qi = "Hazard Ratio",
                     spin = TRUE, ci = 0.99)

## Not run: 
# Simulate Hazard Rates
Sim2 <- coxsimLinear(M1, b = "stafcder",
                      Xj = 1237,
                      ci = 0.99)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.