sim.idmModel: Simulate illness-death model data

Description Usage Arguments Details Value Author(s) Examples

View source: R/simulateIDM.R

Description

Function to simulate illness-death model data

Usage

1
2
3
## S3 method for class 'idmModel'
sim(x, n, illness.known.at.death = TRUE, compliance = 1,
  latent = FALSE, keep.inspectiontimes = FALSE, ...)

Arguments

x

An idmModel object as obtained with idmModel

n

Number of observations

illness.known.at.death

Affects the value of variable seen.ill

compliance

Probability of missing an inspection time.

latent

if TRUE keep the latent event times

keep.inspectiontimes

if TRUE keep the inspection times.

...

Extra arguments given to sim

Details

Based on the functionality of the lava PACKAGE

Value

A data set with interval censored observations from an illness-death model

Author(s)

Thomas Alexander Gerds

Examples

1
2

Example output

Loading required package: prodlim

idmMdl> ## Not run: 
idmMdl> ##D library(lava)
idmMdl> ##D library(prodlim)
idmMdl> ##D # generate illness-death model based on exponentially
idmMdl> ##D # distributed times
idmMdl> ##D m <- idmModel(scale.illtime=1/70,
idmMdl> ##D               shape.illtime=1.8,
idmMdl> ##D               scale.lifetime=1/50,
idmMdl> ##D               shape.lifetime=0.7,
idmMdl> ##D               scale.waittime=1/30,
idmMdl> ##D               shape.waittime=0.7)
idmMdl> ##D round(sim(m,6),1)
idmMdl> ##D 
idmMdl> ##D # Estimate the parameters of the Weibull models
idmMdl> ##D # based on the uncensored exact event times
idmMdl> ##D # and the uncensored illstatus.
idmMdl> ##D set.seed(18)
idmMdl> ##D d <- sim(m,100,latent=FALSE)
idmMdl> ##D d$uncensored.status <- 1
idmMdl> ##D f <- idm(formula01=Hist(time=illtime,event=illstatus)~1,
idmMdl> ##D          formula02=Hist(time=lifetime,event=uncensored.status)~1,
idmMdl> ##D          data=d,
idmMdl> ##D          conf.int=FALSE)
idmMdl> ##D print(f)
idmMdl> ##D 
idmMdl> ##D # Change the rate of the 0->2 and 0->1 transitions
idmMdl> ##D # also the rate of the 1->2 transition
idmMdl> ##D # and also lower the censoring rate
idmMdl> ##D m <- idmModel(scale.lifetime=1/2000,
idmMdl> ##D               scale.waittime=1/30,
idmMdl> ##D               scale.illtime=1/1000,
idmMdl> ##D               scale.censtime=1/1000)
idmMdl> ##D set.seed(18)
idmMdl> ##D d <- sim(m,50,latent=TRUE)
idmMdl> ##D d$uncensored.status <- 1
idmMdl> ##D 
idmMdl> ##D f <- idm(formula01=Hist(time=observed.illtime,event=illstatus)~1,
idmMdl> ##D          formula02=Hist(time=observed.lifetime,event=uncensored.status)~1,
idmMdl> ##D          data=d,
idmMdl> ##D          conf.int=FALSE)
idmMdl> ##D print(f)
idmMdl> ##D 
idmMdl> ##D # Estimate based on the right censored observations
idmMdl> ##D fc <- idm(formula01=Hist(time=illtime,event=seen.ill)~1,
idmMdl> ##D           formula02=Hist(time=observed.lifetime,event=seen.exit)~1,
idmMdl> ##D           data=d,
idmMdl> ##D           conf.int=FALSE)
idmMdl> ##D print(fc)
idmMdl> ##D 
idmMdl> ##D # Estimate based on interval censored and right censored observations
idmMdl> ##D fi <- idm(formula01=Hist(time=list(L,R),event=seen.ill)~1,
idmMdl> ##D           formula02=Hist(time=observed.lifetime,event=seen.exit)~1,
idmMdl> ##D           data=d,
idmMdl> ##D           conf.int=FALSE)
idmMdl> ##D print(fi)
idmMdl> ##D 
idmMdl> ##D # Estimation of covariate effects:
idmMdl> ##D # X1, X2, X3
idmMdl> ##D m <- idmModel(shape.waittime=2,
idmMdl> ##D               scale.lifetime=1/2000,
idmMdl> ##D               scale.waittime=1/300,
idmMdl> ##D               scale.illtime=1/10000,
idmMdl> ##D               scale.censtime=1/10000)
idmMdl> ##D distribution(m,"X1") <- binomial.lvm(p=0.3)
idmMdl> ##D distribution(m,"X2") <- normal.lvm(mean=120,sd=20)
idmMdl> ##D distribution(m,"X3") <- normal.lvm(mean=50,sd=20)
idmMdl> ##D regression(m,to="latent.illtime",from="X1") <- 1.7
idmMdl> ##D regression(m,to="latent.illtime",from="X2") <- 0.07
idmMdl> ##D regression(m,to="latent.illtime",from="X3") <- -0.1
idmMdl> ##D regression(m,to="latent.waittime",from="X1") <- 1.8
idmMdl> ##D regression(m,to="latent.lifetime",from="X1") <- 0.7
idmMdl> ##D set.seed(28)
idmMdl> ##D d <- sim(m,100,latent=TRUE)
idmMdl> ##D head(d)
idmMdl> ##D table(ill=d$seen.ill,death=d$seen.exit)
idmMdl> ##D 
idmMdl> ##D # Estimation based on uncensored data
idmMdl> ##D d$uncensored.status <- 1
idmMdl> ##D # uncensored data
idmMdl> ##D F1 <- idm(formula01=Hist(time=illtime,event=illstatus)~X1+X2+X3,
idmMdl> ##D           formula02=Hist(time=lifetime,event=uncensored.status)~X1+X2+X3,
idmMdl> ##D           data=d,conf.int=FALSE)
idmMdl> ##D print(F1)
idmMdl> ##D 
idmMdl> ##D # Estimation based on right censored data
idmMdl> ##D F2 <- idm(formula01=Hist(time=illtime,event=seen.ill)~X1+X2+X3,
idmMdl> ##D           formula02=Hist(time=observed.lifetime,event=seen.exit)~X1+X2+X3,
idmMdl> ##D           data=d,conf.int=FALSE)
idmMdl> ##D print(F2)
idmMdl> ##D 
idmMdl> ##D # Estimation based on interval censored and right censored data
idmMdl> ##D F3 <- idm(formula01=Hist(time=list(L,R),event=seen.ill)~X1+X2+X3,
idmMdl> ##D           formula02=Hist(time=observed.lifetime,event=seen.exit)~X1+X2+X3,
idmMdl> ##D           data=d,conf.int=FALSE)
idmMdl> ##D print(F3)
idmMdl> ##D cbind(uncensored=F1$coef,right.censored=F2$coef,interval.censored=F3$coef)
idmMdl> ## End(Not run)
idmMdl> 
idmMdl> 
idmMdl> 
idmModel             package:SmoothHazard              R Documentation

_G_e_n_e_r_a_t_e _i_l_l_n_e_s_s-_d_e_a_t_h _m_o_d_e_l _o_b_j_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Function to generate an illness-death model for simulation.

_U_s_a_g_e:

     idmModel(scale.illtime = 1/100, shape.illtime = 1, scale.lifetime = 1/100,
       shape.lifetime = 1, scale.waittime = 1/100, shape.waittime = 1,
       scale.censtime = 1/100, shape.censtime = 1, n.inspections = 5,
       schedule = 10, punctuality = 5)
     
_A_r_g_u_m_e_n_t_s:

scale.illtime: Weilbull scale for latent illness time

shape.illtime: Weilbull shape for latent illness time

scale.lifetime: Weilbull scale for latent life time

shape.lifetime: Weilbull shape for latent life time

scale.waittime: Weilbull scale for latent life time

shape.waittime: Weilbull shape for latent life time

scale.censtime: Weilbull scale for censoring time

shape.censtime: Weilbull shape for censoring time

n.inspections: Number of inspection times

schedule: Mean of the waiting time between adjacent inspections.

punctuality: Standard deviation of waiting time between inspections.

_D_e_t_a_i_l_s:

     Based on the functionality of the lava PACKAGE the function
     generates a latent variable model (latent illtime, waittime and
     lifetime) and censoring mechanism (censtime,
     inspection1,inspection2,...,inspectionK).

     The function 'sim.idmModel' then simulates right censored
     lifetimes and interval censored illness times.

_V_a_l_u_e:

     A latent variable model object 'lvm'

_A_u_t_h_o_r(_s):

     Thomas Alexander Gerds

_E_x_a_m_p_l_e_s:

     ## Not run:
     
     library(lava)
     library(prodlim)
     # generate illness-death model based on exponentially
     # distributed times
     m <- idmModel(scale.illtime=1/70,
                   shape.illtime=1.8,
                   scale.lifetime=1/50,
                   shape.lifetime=0.7,
                   scale.waittime=1/30,
                   shape.waittime=0.7)
     round(sim(m,6),1)
     
     # Estimate the parameters of the Weibull models
     # based on the uncensored exact event times
     # and the uncensored illstatus.
     set.seed(18)
     d <- sim(m,100,latent=FALSE)
     d$uncensored.status <- 1
     f <- idm(formula01=Hist(time=illtime,event=illstatus)~1,
              formula02=Hist(time=lifetime,event=uncensored.status)~1,
              data=d,
              conf.int=FALSE)
     print(f)
     
     # Change the rate of the 0->2 and 0->1 transitions
     # also the rate of the 1->2 transition
     # and also lower the censoring rate
     m <- idmModel(scale.lifetime=1/2000,
                   scale.waittime=1/30,
                   scale.illtime=1/1000,
                   scale.censtime=1/1000)
     set.seed(18)
     d <- sim(m,50,latent=TRUE)
     d$uncensored.status <- 1
     
     f <- idm(formula01=Hist(time=observed.illtime,event=illstatus)~1,
              formula02=Hist(time=observed.lifetime,event=uncensored.status)~1,
              data=d,
              conf.int=FALSE)
     print(f)
     
     # Estimate based on the right censored observations
     fc <- idm(formula01=Hist(time=illtime,event=seen.ill)~1,
               formula02=Hist(time=observed.lifetime,event=seen.exit)~1,
               data=d,
               conf.int=FALSE)
     print(fc)
     
     # Estimate based on interval censored and right censored observations
     fi <- idm(formula01=Hist(time=list(L,R),event=seen.ill)~1,
               formula02=Hist(time=observed.lifetime,event=seen.exit)~1,
               data=d,
               conf.int=FALSE)
     print(fi)
     
     # Estimation of covariate effects:
     # X1, X2, X3
     m <- idmModel(shape.waittime=2,
                   scale.lifetime=1/2000,
                   scale.waittime=1/300,
                   scale.illtime=1/10000,
                   scale.censtime=1/10000)
     distribution(m,"X1") <- binomial.lvm(p=0.3)
     distribution(m,"X2") <- normal.lvm(mean=120,sd=20)
     distribution(m,"X3") <- normal.lvm(mean=50,sd=20)
     regression(m,to="latent.illtime",from="X1") <- 1.7
     regression(m,to="latent.illtime",from="X2") <- 0.07
     regression(m,to="latent.illtime",from="X3") <- -0.1
     regression(m,to="latent.waittime",from="X1") <- 1.8
     regression(m,to="latent.lifetime",from="X1") <- 0.7
     set.seed(28)
     d <- sim(m,100,latent=TRUE)
     head(d)
     table(ill=d$seen.ill,death=d$seen.exit)
     
     # Estimation based on uncensored data
     d$uncensored.status <- 1
     # uncensored data
     F1 <- idm(formula01=Hist(time=illtime,event=illstatus)~X1+X2+X3,
               formula02=Hist(time=lifetime,event=uncensored.status)~X1+X2+X3,
               data=d,conf.int=FALSE)
     print(F1)
     
     # Estimation based on right censored data
     F2 <- idm(formula01=Hist(time=illtime,event=seen.ill)~X1+X2+X3,
               formula02=Hist(time=observed.lifetime,event=seen.exit)~X1+X2+X3,
               data=d,conf.int=FALSE)
     print(F2)
     
     # Estimation based on interval censored and right censored data
     F3 <- idm(formula01=Hist(time=list(L,R),event=seen.ill)~X1+X2+X3,
               formula02=Hist(time=observed.lifetime,event=seen.exit)~X1+X2+X3,
               data=d,conf.int=FALSE)
     print(F3)
     cbind(uncensored=F1$coef,right.censored=F2$coef,interval.censored=F3$coef)
     ## End(Not run)
     

SmoothHazard documentation built on May 2, 2019, 4:43 p.m.