R: Simulation of output from Cox model.

sim.cox {timereg} | R Documentation

## Simulation of output from Cox model.

### Description

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

### Usage

    ## S3 method for class 'cox'
    sim(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(s)

Thomas Scheike

### Examples

    data(TRACE)

    cox <-  coxph(Surv(time,status==9)~vf+chf+wmi,data=TRACE)
    sim1 <- sim.cox(cox,1000,data=TRACE)
    cc <- coxph(Surv(time,status)~vf+chf+wmi,data=sim1)
    cbind(cox$coef,cc$coef)

    cor(sim1[,c("vf","chf","wmi")])
    cor(TRACE[,c("vf","chf","wmi")])

    cox <-  cox.aalen(Surv(time, status==9) ~ prop(vf)+prop(chf)+prop(wmi),TRACE,robust=0)
    sim2 <- sim.cox(cox,1000,data=TRACE)
    cc <-  cox.aalen(Surv(time, status)~prop(vf)+prop(chf)+prop(wmi),data=sim2,robust=0)
    ###
    plot(cox)
    lines(cc$cum,type="s",col=2)
    cbind(cox$gamma,cc$gamma)

    ### do not test to avoid dependence on mets
    library(mets)
    cox <-  phreg(Surv(time, status==9)~vf+chf+wmi,data=TRACE)
    sim3 <- sim.cox(cox,1000,data=TRACE)
    cc <-  phreg(Surv(time, status)~vf+chf+wmi,data=sim3)
    cbind(cox$coef,cc$coef)
    basehazplot.phreg(cox,se=TRUE)
    lines(cc$cumhaz,col=2)

    cox <-  phreg(Surv(time,status==9)~strata(chf)+vf+wmi,data=TRACE)
    sim3 <- sim.cox(cox,1000,data=TRACE)
    cc <-   phreg(Surv(time, status)~strata(chf)+vf+wmi,data=sim3)
    cbind(cox$coef,cc$coef)
    basehazplot.phreg(cox)
    basehazplot.phreg(cc,add=TRUE)

[Package timereg version 1.9.4 Index]