View source: R/recurrent.marginal.R
simRecurrentII | R Documentation |
Simulation of recurrent events data based on cumulative hazards
simRecurrentII(
n,
cumhaz,
cumhaz2,
death.cumhaz = NULL,
r1 = NULL,
r2 = NULL,
rd = NULL,
rc = NULL,
dependence = 0,
var.z = 1,
cor.mat = NULL,
cens = NULL,
gap.time = FALSE,
max.recurrent = 100,
...
)
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 |
r1 |
potential relative risk adjustment of rate |
r2 |
potential relative risk adjustment of rate |
rd |
potential relative risk adjustment of rate |
rc |
potential relative risk adjustment of rate |
dependence |
0:independence; 1:all share same random effect with variance var.z; 2:random effect exp(normal) with correlation structure from cor.mat; 3:additive gamma distributed random effects, z1= (z11+ z12)/2 such that mean is 1 , z2= (z11^cor.mat(1,2)+ z13)/2, z3= (z12^(cor.mat(2,3)+z13^cor.mat(1,3))/2, with z11 z12 z13 are gamma with mean and variance 1 , 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 |
cens |
rate of censoring exponential distribution |
gap.time |
if true simulates gap-times with specified cumulative hazard |
max.recurrent |
limits number recurrent events to 100 |
... |
Additional arguments to lower level funtions |
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
Thomas Scheike
########################################
## getting some rates to mimick
########################################
data(CPH_HPN_CRBSI)
dr <- CPH_HPN_CRBSI$terminal
base1 <- CPH_HPN_CRBSI$crbsi
base4 <- CPH_HPN_CRBSI$mechanical
######################################################################
### simulating simple model that mimicks data
######################################################################
rr <- simRecurrent(5,base1)
dlist(rr,.~id,n=0)
rr <- simRecurrent(5,base1,death.cumhaz=dr)
dlist(rr,.~id,n=0)
rr <- simRecurrent(100,base1,death.cumhaz=dr)
par(mfrow=c(1,3))
showfitsim(causes=1,rr,dr,base1,base1)
######################################################################
### simulating simple model
### random effect for all causes (Z shared for death and recurrent)
######################################################################
rr <- simRecurrent(100,base1,death.cumhaz=dr,dependence=1,var.gamma=0.4)
dtable(rr,~death+status)
######################################################################
### simulating simple model that mimicks data
### now with two event types and second type has same rate as death rate
######################################################################
set.seed(100)
rr <- simRecurrentII(100,base1,base4,death.cumhaz=dr)
dtable(rr,~death+status)
par(mfrow=c(2,2))
showfitsim(causes=2,rr,dr,base1,base4)
## general case, 3 recurrent events and 2 causes of death
set.seed(100)
cumhaz <- list(base1,base1,base4)
drl <- list(dr,base4)
rr <- simRecurrentList(100,cumhaz,death.cumhaz=drl,dependence=0)
dtable(rr,~death+status)
showfitsimList(rr,cumhaz,drl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.