Simulates data that looks like fit from Cox model. Censor data automatically for highest value of the event times by using cumulative hazard.

sim.cox(cox,n,data=NULL,cens=NULL,rrc=NULL,entry=NULL,...)

Arguments

cox

output form coxph or cox.aalen model fitting cox model.

n

number of simulations.

data

to extract covariates for simulations (draws from observed covariates).

cens

specifies censoring model, if "is.matrix" then uses cumulative hazard given, if "is.scalar" then uses rate for exponential, and if not given then takes average rate of in simulated data from cox model.

rrc

possible vector of relative risk for cox-type censoring.

entry

delayed entry variable for simulation.

...

arguments for rchaz, for example entry-time

Author

Thomas Scheike

Examples


data(sTRACE)
cox <-  coxph(Surv(time,status==9)~vf+chf+wmi,data=sTRACE)
sim1 <- sim.cox(cox,1000,data=sTRACE)
cc <- coxph(Surv(time,status)~vf+chf+wmi,data=sim1)
cbind(cox$coef,cc$coef)
#>           [,1]       [,2]
#> vf   0.2970218  0.4662516
#> chf  0.8018334  0.7656359
#> wmi -0.8920005 -0.6820267

cor(sim1[,c("vf","chf","wmi")])
#>             vf        chf        wmi
#> vf   1.0000000  0.1467306 -0.1267284
#> chf  0.1467306  1.0000000 -0.4059362
#> wmi -0.1267284 -0.4059362  1.0000000
cor(sTRACE[,c("vf","chf","wmi")])
#>              vf        chf         wmi
#> vf   1.00000000  0.1346711 -0.08966805
#> chf  0.13467109  1.0000000 -0.37464791
#> wmi -0.08966805 -0.3746479  1.00000000

cox <-  phreg(Surv(time, status==9)~vf+chf+wmi,data=sTRACE)
sim3 <- sim.cox(cox,1000,data=sTRACE)
cc <-  phreg(Surv(time, status)~vf+chf+wmi,data=sim3)
cbind(cox$coef,cc$coef)
#>           [,1]       [,2]
#> vf   0.2970218  0.3234739
#> chf  0.8018334  0.7634755
#> wmi -0.8920005 -0.7312587
plot(cox,se=TRUE)
plot(cc,add=TRUE,col=2)


cox <-  phreg(Surv(time,status==9)~strata(chf)+vf+wmi,data=sTRACE)
sim3 <- sim.cox(cox,100,data=sTRACE)
cc <-   phreg(Surv(time, status)~strata(chf)+vf+wmi,data=sim3)
cbind(cox$coef,cc$coef)
#>           [,1]       [,2]
#> vf   0.2907750 -0.8705529
#> wmi -0.8905339 -0.7120919
plot(cox)
plot(cc,add=TRUE,col=2)