Learn R Programming

mets (version 1.3.11)

sim_phregs: Simulation of Cause-Specific Cox Models

Description

Simulates data that looks like fit from cause-specific Cox models. Censors data automatically. When censoring is given in the list of causes, this provides censoring that looks like the data.

Usage

sim_phregs(
  coxs,
  n,
  data = NULL,
  rr = NULL,
  strata = NULL,
  entry = NULL,
  extend = TRUE,
  cens = NULL,
  rrc = NULL,
  ...
)

Value

Data frame with simulated event times, status, and covariates.

Arguments

coxs

List of Cox models.

n

Number of simulations.

data

Data frame to extract covariates.

rr

Relative risks.

strata

Strata vector.

entry

Delayed entry.

extend

Extend baselines to largest endpoint.

cens

Censoring specification.

rrc

Relative risks for censoring.

...

Arguments for rchaz.

Author

Thomas Scheike

Examples

Run this code
data(bmt)
nsim <- 100; 

cox1 <- phreg(Surv(time,cause==1)~strata(tcell)+platelet+age,data=bmt)
cox2 <- phreg(Surv(time,cause==2)~tcell+strata(platelet),data=bmt)
coxs <- list(cox1,cox2)
## just calls sim_phregs !
dd <- sim_phregs(coxs,nsim,data=bmt,extend=c(0.001))
scox1 <- phreg(Surv(time,cause==1)~strata(tcell)+platelet+age,data=dd)
scox2 <- phreg(Surv(time,cause==2)~tcell+strata(platelet),data=dd)

cbind(cox1$coef,scox1$coef)
cbind(cox2$coef,scox2$coef)
par(mfrow=c(1,2))
plot(cox1); plot(scox1,add=TRUE); 
plot(cox2); plot(scox2,add=TRUE); 

Run the code above in your browser using DataLab