1### R code from vignette source 'etmCIF_tutorial.Rnw' 2 3################################################### 4### code chunk number 1: etmCIF_tutorial.Rnw:34-37 5################################################### 6library(etm) 7library(survival) 8data(abortion) 9 10 11################################################### 12### code chunk number 2: etmCIF_tutorial.Rnw:51-52 13################################################### 14head(abortion) 15 16 17################################################### 18### code chunk number 3: etmCIF_tutorial.Rnw:96-99 19################################################### 20cif.abortion <- etmCIF(Surv(entry, exit, cause != 0) ~ group, 21 abortion, etype = cause, failcode = 3) 22cif.abortion 23 24 25################################################### 26### code chunk number 4: etmCIF_tutorial.Rnw:108-109 27################################################### 28s.cif.ab <- summary(cif.abortion) 29 30 31################################################### 32### code chunk number 5: etmCIF_tutorial.Rnw:116-117 33################################################### 34s.cif.ab 35 36 37################################################### 38### code chunk number 6: etmCIF_tutorial.Rnw:129-130 39################################################### 40plot(cif.abortion) 41 42 43################################################### 44### code chunk number 7: etmCIF_tutorial.Rnw:145-148 45################################################### 46plot(cif.abortion, curvlab = c("Control", "Exposed"), ylim = c(0, 0.6), 47 ci.type = "bars", pos.ci = 27, col = c(1, 2), ci.lwd = 6, 48 lwd = 2, lty = 1, cex = 1.3) 49 50 51################################################### 52### code chunk number 8: etmCIF_tutorial.Rnw:167-170 53################################################### 54plot(cif.abortion, curvlab = c("Control", "Exposed"), ylim = c(0, 0.6), 55 ci.type = "bars", pos.ci = c(27, 28), col = c(1, 1), ci.lwd = 6, 56 lwd = 2, lty = c(2, 1), cex = 1.3) 57 58 59################################################### 60### code chunk number 9: etmCIF_tutorial.Rnw:183-185 61################################################### 62plot(cif.abortion, curvlab = c("Control", "Exposed"), ylim = c(0, 0.5), 63 ci.type = "pointwise", col = c(1, 2), lwd = 2, lty = 1, cex = 1.3) 64 65 66################################################### 67### code chunk number 10: etmCIF_tutorial.Rnw:200-206 68################################################### 69plot(cif.abortion, which.cif = c(1, 2), ylim = c(0, 0.8), lwd = 2, 70 col = c(1, 1, 2, 2), lty = c(1, 2, 1, 2), legend = FALSE) 71legend(0, 0.8, c("Control", "Exposed"), col = c(1, 2), lty = 1, 72 bty = "n", lwd = 2) 73legend(0, 0.7, c("ETOP", "Life Birth"), col = 1, lty = c(1, 2), 74 bty = "n", lwd = 2) 75 76 77################################################### 78### code chunk number 11: etmCIF_tutorial.Rnw:226-232 79################################################### 80abortion$status <- with(abortion, ifelse(cause == 2, "life birth", 81 ifelse(cause == 1, "ETOP", "spontaneous abortion"))) 82abortion$status <- factor(abortion$status) 83 84abortion$treat <- with(abortion, ifelse(group == 0, "control", "exposed")) 85abortion$treat <- factor(abortion$treat) 86 87 88################################################### 89### code chunk number 12: etmCIF_tutorial.Rnw:237-240 90################################################### 91new.cif <- etmCIF(Surv(entry, exit, status != 0) ~ treat, abortion, 92 etype = status, failcode = "spontaneous abortion") 93new.cif 94 95 96################################################### 97### code chunk number 13: etmCIF_tutorial.Rnw:261-262 98################################################### 99trprob(new.cif[[1]], "0 spontaneous abortion", c(1, 10, 27)) 100 101 102################################################### 103### code chunk number 14: etmCIF_tutorial.Rnw:276-277 (eval = FALSE) 104################################################### 105## lines(cif.abortion[[2]], tr.choice = "0 1", col = 2, lwd = 2) 106 107 108################################################### 109### code chunk number 15: etmCIF_tutorial.Rnw:282-286 110################################################### 111plot(cif.abortion, curvlab = c("Control", "Exposed"), ylim = c(0, 0.6), 112 ci.type = "bars", pos.ci = c(27, 28), col = c(1, 1), ci.lwd = 6, 113 lwd = 2, lty = c(2, 1), cex = 1.3) 114lines(cif.abortion[[2]], tr.choice = "0 1", col = 2, lwd = 2) 115 116 117