Learn R Programming

mets (version 1.3.11)

sim_cif: Simulation of Output from Cumulative Incidence Regression Model

Description

Simulates data that looks like fit from a fitted cumulative incidence model (Fine-Gray or logistic).

Usage

sim_cif(
  cif,
  n,
  data = NULL,
  Z = NULL,
  rr = NULL,
  strata = NULL,
  drawZ = TRUE,
  cens = NULL,
  rrc = NULL,
  entry = NULL,
  Sentry = NULL,
  cumstart = c(0, 0),
  U = NULL,
  pU = NULL,
  type = NULL,
  extend = NULL,
  ...
)

Value

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

Arguments

cif

Output from prop.odds.subdist or ccr (cmprsk), or call invsubdist with cumulative and linear predictor.

n

Number of simulations.

data

Data frame to extract covariates.

Z

Design matrix instead of data.

rr

Relative risks.

strata

Strata vector.

drawZ

Logical; randomly sample from Z.

cens

Censoring specification.

rrc

Relative risks for censoring.

entry

Delayed entry time.

Sentry

Survival related to delayed entry.

cumstart

Start cumulatives at time 0.

U

Uniforms for drawing timing.

pU

Uniforms for drawing event type.

type

Model type: "logistic", "cloglog", or "rr".

extend

Extend piecewise constant with constant rate.

...

Arguments for sim_subdist.

Author

Thomas Scheike

See Also

[simul_cifs()]

Examples

Run this code
data(bmt)
nsim <- 100

## logit cumulative incidence regression model 
cif <- cifreg(Event(time,cause)~platelet+age,data=bmt,cause=1)
estimate(cif)  
plot(cif,col=1)
simbmt <- sim_cif(cif,nsim,data=bmt)
dtable(simbmt,~cause)
scif <- cifreg(Event(time,cause)~platelet+age,data=simbmt,cause=1)
estimate(scif)
plot(scif,add=TRUE,col=2)

## Fine-Gray cloglog cumulative incidence regression model 
cif <- cifregFG(Event(time,cause)~strata(tcell)+age,data=bmt,cause=1)
estimate(cif)  
plot(cif,col=1)
simbmt <- sim_cif(cif,nsim,data=bmt)
scif <- cifregFG(Event(time,cause)~strata(tcell)+age,data=simbmt,cause=1)
estimate(scif)
plot(scif,add=TRUE,col=2)

################################################################
#  simulating several causes with specific cumulatives 
################################################################
cif1 <-  cifreg(Event(time,cause)~strata(tcell)+age,data=bmt,cause=1)
cif2 <-  cifreg(Event(time,cause)~strata(platelet)+tcell+age,data=bmt,cause=2)
cifss <-  list(cif1,cif2)
simbmt <- sim_cifs(list(cif1,cif2),nsim,data=bmt,extend=0.005)
scif1 <-  cifreg(Event(time,cause)~strata(tcell)+age,data=simbmt,cause=1)
scif2 <-  cifreg(Event(time,cause)~strata(platelet)+tcell+age,data=simbmt,cause=2)
cbind(cif1$coef,scif1$coef)   
## can be off due to restriction F1+F2<= 1    
cbind(cif2$coef,scif2$coef)   
    
par(mfrow=c(1,2))   
## Cause 1 follows the model    
plot(cif1); plot(scif1,add=TRUE,col=1:2,lwd=2)
# Cause 2:second cause is modified with restriction to satisfy F1+F2<= 1, so scaled down     
plot(cif2); plot(scif2,add=TRUE,col=1:2,lwd=2)

Run the code above in your browser using DataLab