Learn R Programming

simPH (version 0.7.2)

coxsimPoly: Simulate quantities of interest for a range of values for a polynomial nonlinear effect from Cox Proportional Hazards models.

Description

Simulates quantities of interest for polynomial covariate effects.

Note, you must use I to create the polynomials.

Usage

coxsimPoly(obj, b, qi = "Relative Hazard", pow = 2,
    Xj = NULL, Xl = NULL, nsim = 1000, ci = 0.95,
    spin = FALSE)

Arguments

obj
a coxph fitted model object with a polynomial coefficient.
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
pow
numeric polynomial used in coxph.
Xj
numeric vector of values of X to simulate for.
Xl
numeric vector of values to compare Xj to. If NULL, then it is authomatically set to 0.
nsim
the number of simulations to run per value of Xj. Default is nsim = 1000.
ci
the proportion of middle simulations to keep. The default is ci = 0.95, i.e. keep the middle 95 percent. If spin = TRUE then ci is the convidence level of the shortest probability interval. Any value from 0 t
spin
logical, whether or not to keep only the shortest proability interval rather than the middle simulations.

Value

  • a simpoly class object.

Details

coxsimPoly simulates quantities of interest for polynomial covariate effects estimated from Cox Proportional Hazards models.

References

Keele, Luke. 2010. ''Proportionally Difficult: Testing for Nonproportional Hazards in Cox Models.'' Political Analysis 18(2): 189-205.

Carpenter, Daniel P. 2002. ''Groups, the Media, Agency Waiting Costs, and FDA Drug Approval.'' American Journal of Political Science 46(3): 490-505.

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 +
				natreg + I(natreg^2) + I(natreg^3) + vandavg3 + wpnoavg3 +
				condavg3 + orderent + stafcder, data = CarpenterFdaData)

# Simulate simpoly First Difference
Sim1 <- coxsimPoly(M1, b = "natreg", qi = "First Difference",
						pow = 3, Xj = seq(1, 150, by = 5))

# Simulate simpoly Hazard Ratio with spin probibility interval
Sim2 <- coxsimPoly(M1, b = "natreg", qi = "Hazard Ratio",
						pow = 3, Xj = seq(1, 150, by = 5), spin = TRUE)

Run the code above in your browser using DataLab