Learn R Programming

mets (version 1.2.3.1)

simRecurrentII: Simulation of recurrent events data based on cumulative hazards

Description

Simulation of recurrent events data based on cumulative hazards

Usage

simRecurrentII(n, cumhaz, cumhaz2, death.cumhaz = NULL, gap.time = FALSE,
  max.recurrent = 100, dhaz = NULL, haz2 = NULL, dependence = 0,
  var.z = 0.22, cor.mat = NULL, ...)

Arguments

n

number of id's

cumhaz

cumulative hazard of recurrent events

cumhaz2

cumulative hazard of recurrent events of type 2

death.cumhaz

cumulative hazard of death

gap.time

if true simulates gap-times with specified cumulative hazard

max.recurrent

limits number recurrent events to 100

dhaz

rate for death hazard if it is extended to time-range of first event

haz2

rate of second cause if it is extended to time-range of first event

dependence

=0 independence, =1 all share same random effect with variance var.z =2 random effect exp(normal) with correlation structure from cor.mat, first random effect is z1 and for N1 second random effect is z2 and for N2 third random effect is for death

var.z

variance of random effects

cor.mat

correlation matrix for var.z variance of random effects

...

Additional arguments to lower level funtions

Details

Must give hazard of death and two recurrent events. Possible with two event types and their dependence can be specified but the two recurrent events need to share random effect. Based on drawing the from cumhaz and cumhaz2 and taking the first event rather the cumulative and then distributing it out. Key advantage of this is that there is more flexibility wrt random effects

Examples

Run this code
# NOT RUN {
########################################
## getting some rates to mimick 
########################################

data(base1cumhaz)
data(base4cumhaz)
data(drcumhaz)
dr <- drcumhaz
base1 <- base1cumhaz
base4 <- base4cumhaz

 cor.mat <- corM <- rbind(c(1.0, 0.6, 0.9), c(0.6, 1.0, 0.5), c(0.9, 0.5, 1.0))

######################################################################
### simulating simple model that mimicks data 
### now with two event types and second type has same rate as death rate
######################################################################

rr <- simRecurrentII(1000,base1,dr,death.cumhaz=base4)
dtable(rr,~death+status)
par(mfrow=c(2,2))
showfitsim(causes=2,rr,dr,base1,base4)

# }

Run the code above in your browser using DataLab