Load the data. |
|
Then, we perfom the transformation. |
- my.icu.pneu <- icu.pneu my.icu.pneu <- my.icu.pneu[order(my.icu.pneu$id, my.icu.pneu$start), ] masque <- diff(my.icu.pneu$id) my.icu.pneu$from <- 0 my.icu.pneu$from[c(1, masque) == 0] <- 1 my.icu.pneu$to2 <- my.icu.pneu$event my.icu.pneu$to2[my.icu.pneu$status == 0] <- "cens" my.icu.pneu$to2[c(masque, 1) == 0] <- 1
|
Event indicator variable to for a first event analysis: |
- my.icu.pneu$to <- ifelse(my.icu.pneu$to2 %in% c(2, 3), 2, my.icu.pneu$to2)
|
Keep the variables of interest |
- my.icu.pneu <- my.icu.pneu[, c("id", "start", "stop", "from", "to", "to2", "age", "sex")] names(my.icu.pneu)[c(2, 3)] <- c("entry", "exit")
|
Creation of a matrix with logical entries defining the possible transitions: |
- tra.idm <- matrix(FALSE, 3, 3, dimnames = list(c(0, 1, 2), c(0, 1, 2))) tra.idm[1, 2:3] <- TRUE tra.idm[2, 3] <- TRUE
|
Computation of the cumulative transition hazards using mvna: |
- mvna.idm <- mvna(my.icu.pneu, c("0", "1", "2"), tra.idm, "cens")
|
Figure 9.2 |
- xyplot(mvna.idm, tr.choice = c("0 1", "0 2", "1 2"), lwd = 3, strip=strip.custom(bg="white", factor.levels = c(expression(0 %->% 1), expression(0 %->% 2), expression(1 %->% 2)), par.strip.text = list(cex = 1.2)), ylim = c(0, 9), xlab = "Days", layout = c(3, 1), xlim = c(0, 100))
|
Estimation of the transition probabilities using the etm package: |
- etm.idm <- etm(my.icu.pneu, c("0", "1", "2"), tra.idm, "cens", s = 0)
|
Figure 9.3 |
- plot(etm.idm, tr.choice = "0 1", conf.int = TRUE, lwd = 2, legend = FALSE, ylim = c(0, 0.1), xlim = c(0, 100), xlab = "Days", ci.fun = "cloglog")
|
Landmark analysis Creation of the landmark time points: |
- time.points <- c(seq(3, 10, 1), 15)
|
Computation of transition probabilities with s = time.points |
- landmark.etm <- lapply(time.points, function(start.time) { etm(my.icu.pneu, c("0", "1", "2"), tra.idm, "cens", start.time) })
|
Figure 9.4 |
- nf <- layout(matrix(1:9, ncol = 3, byrow = TRUE), width = rep(1, 9), height = rep(1, 9)) for (i in seq_along(time.points)) { plot(landmark.etm[[i]], tr.choice = "0 2", lwd = 2, legend = FALSE, main = paste(expression("s ="), time.points[i], sep = " "), xlim = c(0, 100), lty = 2, ylab = "Probability of end-of-stay", xlab = "Days") lines(landmark.etm[[i]], tr.choice = "1 2", lwd = 2, col = 1, lty = 1, xlim = c(0, 100)) if (i == 1) { legend(45, 0.4, c(expression(P["02"](s, t)), expression(P["12"](s, t))), col = 1, lty = c(2, 1), lwd = 2, bty = "n", cex = 1.3) } }
|