Sie sind hier: Startseite Competing Risks and … R Code R code for chapter 11

R code for chapter 11

Section 11.1.3

Subsection: Impact of hospital-acquired pneumonia (HAP) on length of stay in intensive care unit

Cox model with pneumonia as a time-dependent covariate:

cox.hap.tdp <- coxph(Surv(start, stop, status) ~ pneu, 
                     icu.pneu)
summary(cox.hap.tdp)

With some further covariates:

cox.hap.tdp <- coxph(Surv(start, stop, status) ~ pneu
                     + age + sex, icu.pneu)
summary(cox.hap.tdp)


Section 11.2.3

Subsection: Impact of hospital-acquired pneumonia (HAP) on intensive care unit mortality

Creation of a new variable which encodes both observed competing event status and censoring status:

icu.pneu$outcome <- with(icu.pneu, status * event)

Proportional cause-specific hazards models including HAP as the time-dependent variable:

cox.hap.death <- coxph(Surv(start, stop, outcome == 2) ~ pneu, 
                       icu.pneu)
cox.hap.disch <- coxph(Surv(start, stop, outcome == 3) ~ pneu, 
                       icu.pneu)
summary(cox.hap.death)
summary(cox.hap.disch)

Proportional subdistribution hazards model with HAP as a time-dependent covariate using the kmi package.

## Computation of the imputed data sets:
set.seed(4284)
imp.dat <- kmi(Surv(start, stop, outcome != 0) ~ 1, 
               data = icu.pneu, etype = outcome, 
               id = id, failcode = 2, nimp = 10)

## Cox models on the imputed data sets:
kmi.sh.hap <- cox.kmi(Surv(start, stop, outcome == 2) ~ pneu, 
                      imp.dat)
summary(kmi.sh.hap)