Last updated on 2018-08-13 15:51:20 CEST.
Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
---|---|---|---|---|---|---|
r-devel-linux-x86_64-debian-clang | 0.2 | 4.82 | 58.22 | 63.04 | ERROR | |
r-devel-linux-x86_64-debian-gcc | 0.2 | 4.03 | 46.67 | 50.70 | ERROR | |
r-devel-linux-x86_64-fedora-clang | 0.2 | 72.12 | ERROR | |||
r-devel-linux-x86_64-fedora-gcc | 0.2 | 70.74 | ERROR | |||
r-devel-windows-ix86+x86_64 | 0.2 | 11.00 | 85.00 | 96.00 | ERROR | |
r-patched-linux-x86_64 | 0.2 | 3.04 | 47.60 | 50.64 | ERROR | |
r-patched-solaris-x86 | 0.2 | 99.40 | ERROR | |||
r-release-linux-x86_64 | 0.2 | 3.28 | 48.11 | 51.39 | ERROR | |
r-release-windows-ix86+x86_64 | 0.2 | 9.00 | 77.00 | 86.00 | ERROR | |
r-release-osx-x86_64 | 0.2 | NOTE | ||||
r-oldrel-windows-ix86+x86_64 | 0.2 | 10.00 | 75.00 | 85.00 | ERROR | |
r-oldrel-osx-x86_64 | 0.2 | NOTE |
Version: 0.2
Check: dependencies in R code
Result: NOTE
Package in Depends field not imported from: ‘KMsurv’
These packages need to be imported from (in the NAMESPACE file)
for when this namespace is loaded but not attached.
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-ix86+x86_64, r-patched-linux-x86_64, r-patched-solaris-x86, r-release-linux-x86_64, r-release-windows-ix86+x86_64, r-release-osx-x86_64, r-oldrel-windows-ix86+x86_64, r-oldrel-osx-x86_64
Version: 0.2
Check: examples
Result: ERROR
Running examples in ‘OIsurv-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: OIsurv-package
> ### Title: Survival analysis tutorial, a supplement to the OpenIntro guide
> ### Aliases: OIsurv-package OIsurv
>
> ### ** Examples
>
> #=====> 2. Three packages: survival, OIsurv, and KMsurv <=====#
> # install.packages("OIsurv")
> # library(OIsurv)
> data(aids)
> aids
infect induct adult
1 0.00 5.00 1
2 0.25 6.75 1
3 0.75 5.00 1
4 0.75 5.00 1
5 0.75 7.25 1
6 1.00 4.25 1
7 1.00 5.75 1
8 1.00 6.25 1
9 1.00 6.50 1
10 1.25 4.00 1
11 1.25 4.25 1
12 1.25 4.75 1
13 1.25 5.75 1
14 1.50 2.75 1
15 1.50 3.75 1
16 1.50 5.00 1
17 1.50 5.50 1
18 1.50 6.50 1
19 1.75 2.75 1
20 1.75 3.00 1
21 1.75 5.25 1
22 1.75 5.25 1
23 2.00 2.25 1
24 2.00 3.00 1
25 2.00 4.00 1
26 2.00 4.50 1
27 2.00 4.75 1
28 2.00 5.00 1
29 2.00 5.25 1
30 2.00 5.25 1
31 2.00 5.50 1
32 2.00 5.50 1
33 2.00 6.00 1
34 2.25 3.00 1
35 2.25 5.50 1
36 2.50 2.25 1
37 2.50 2.25 1
38 2.50 2.25 1
39 2.50 2.25 1
40 2.50 2.50 1
41 2.50 2.75 1
42 2.50 3.00 1
43 2.50 3.25 1
44 2.50 3.25 1
45 2.50 4.00 1
46 2.50 4.00 1
47 2.50 4.00 1
48 2.75 1.25 1
49 2.75 1.50 1
50 2.75 2.50 1
51 2.75 3.00 1
52 2.75 3.00 1
53 2.75 3.25 1
54 2.75 3.75 1
55 2.75 4.50 1
56 2.75 4.50 1
57 2.75 5.00 1
58 2.75 5.00 1
59 2.75 5.25 1
60 2.75 5.25 1
61 2.75 5.25 1
62 2.75 5.25 1
63 2.75 5.25 1
64 3.00 2.00 1
65 3.00 3.25 1
66 3.00 3.50 1
67 3.00 3.75 1
68 3.00 4.00 1
69 3.00 4.00 1
70 3.00 4.25 1
71 3.00 4.25 1
72 3.00 4.25 1
73 3.00 4.75 1
74 3.00 4.75 1
75 3.00 4.75 1
76 3.00 5.00 1
77 3.25 1.25 1
78 3.25 1.75 1
79 3.25 2.00 1
80 3.25 2.00 1
81 3.25 2.75 1
82 3.25 3.00 1
83 3.25 3.00 1
84 3.25 3.50 1
85 3.25 3.50 1
86 3.25 4.25 1
87 3.25 4.50 1
88 3.50 1.25 1
89 3.50 2.25 1
90 3.50 2.25 1
91 3.50 2.50 1
92 3.50 2.75 1
93 3.50 2.75 1
94 3.50 3.00 1
95 3.50 3.25 1
96 3.50 3.50 1
97 3.50 3.50 1
98 3.50 4.00 1
99 3.50 4.00 1
100 3.50 4.25 1
101 3.50 4.50 1
102 3.50 4.50 1
103 3.75 1.25 1
104 3.75 1.75 1
105 3.75 1.75 1
106 3.75 2.00 1
107 3.75 2.75 1
108 3.75 3.00 1
109 3.75 3.00 1
110 3.75 3.00 1
111 3.75 4.00 1
112 3.75 4.25 1
113 3.75 4.25 1
114 4.00 1.00 1
115 4.00 1.50 1
116 4.00 1.50 1
117 4.00 2.00 1
118 4.00 2.25 1
119 4.00 2.75 1
120 4.00 3.50 1
121 4.00 3.75 1
122 4.00 3.75 1
123 4.00 4.00 1
124 4.25 1.25 1
125 4.25 1.50 1
126 4.25 1.50 1
127 4.25 2.00 1
128 4.25 2.00 1
129 4.25 2.00 1
130 4.25 2.25 1
131 4.25 2.50 1
132 4.25 2.50 1
133 4.25 2.50 1
134 4.25 3.00 1
135 4.25 3.50 1
136 4.25 3.50 1
137 4.50 1.00 1
138 4.50 1.50 1
139 4.50 1.50 1
140 4.50 1.50 1
141 4.50 1.75 1
142 4.50 2.25 1
143 4.50 2.25 1
144 4.50 2.50 1
145 4.50 2.50 1
146 4.50 2.50 1
147 4.50 2.50 1
148 4.50 2.75 1
149 4.50 2.75 1
150 4.50 2.75 1
151 4.50 2.75 1
152 4.50 3.00 1
153 4.50 3.00 1
154 4.50 3.00 1
155 4.50 3.25 1
156 4.50 3.25 1
157 4.75 1.00 1
158 4.75 1.50 1
159 4.75 1.50 1
160 4.75 1.50 1
161 4.75 1.75 1
162 4.75 1.75 1
163 4.75 2.00 1
164 4.75 2.25 1
165 4.75 2.75 1
166 4.75 3.00 1
167 4.75 3.00 1
168 4.75 3.25 1
169 4.75 3.25 1
170 4.75 3.25 1
171 4.75 3.25 1
172 4.75 3.25 1
173 4.75 3.25 1
174 5.00 0.50 1
175 5.00 1.50 1
176 5.00 1.50 1
177 5.00 1.75 1
178 5.00 2.00 1
179 5.00 2.25 1
180 5.00 2.25 1
181 5.00 2.25 1
182 5.00 2.50 1
183 5.00 2.50 1
184 5.00 3.00 1
185 5.00 3.00 1
186 5.00 3.00 1
187 5.25 0.25 1
188 5.25 0.25 1
189 5.25 0.75 1
190 5.25 0.75 1
191 5.25 0.75 1
192 5.25 1.00 1
193 5.25 1.00 1
194 5.25 1.25 1
195 5.25 1.25 1
196 5.25 1.50 1
197 5.25 1.50 1
198 5.25 1.50 1
199 5.25 1.50 1
200 5.25 2.25 1
201 5.25 2.25 1
202 5.25 2.50 1
203 5.25 2.50 1
204 5.25 2.75 1
205 5.50 1.00 1
206 5.50 1.00 1
207 5.50 1.00 1
208 5.50 1.25 1
209 5.50 1.25 1
210 5.50 1.75 1
211 5.50 2.00 1
212 5.50 2.25 1
213 5.50 2.25 1
214 5.50 2.50 1
215 5.75 0.25 1
216 5.75 0.25 1
217 5.75 0.75 1
218 5.75 1.00 1
219 5.75 1.50 1
220 5.75 1.50 1
221 5.75 1.50 1
222 5.75 2.00 1
223 5.75 2.00 1
224 5.75 2.25 1
225 6.00 0.50 1
226 6.00 0.75 1
227 6.00 0.75 1
228 6.00 0.75 1
229 6.00 1.00 1
230 6.00 1.00 1
231 6.00 1.00 1
232 6.00 1.25 1
233 6.00 1.25 1
234 6.00 1.50 1
235 6.00 1.50 1
236 6.00 1.75 1
237 6.00 1.75 1
238 6.00 1.75 1
239 6.00 2.00 1
240 6.25 0.75 1
241 6.25 1.00 1
242 6.25 1.25 1
243 6.25 1.75 1
244 6.25 1.75 1
245 6.50 0.25 1
246 6.50 0.25 1
247 6.50 0.75 1
248 6.50 1.00 1
249 6.50 1.25 1
250 6.50 1.50 1
251 6.75 0.75 1
252 6.75 0.75 1
253 6.75 1.00 1
254 6.75 1.25 1
255 6.75 1.25 1
256 6.75 1.25 1
257 7.00 0.75 1
258 7.25 0.25 1
259 1.00 5.50 0
260 1.50 2.25 0
261 2.25 3.00 0
262 2.75 1.00 0
263 3.00 1.75 0
264 3.50 0.75 0
265 3.75 0.75 0
266 3.75 1.00 0
267 3.75 2.75 0
268 3.75 3.00 0
269 3.75 3.50 0
270 3.75 4.25 0
271 4.00 1.00 0
272 4.25 1.75 0
273 4.50 3.25 0
274 4.75 1.00 0
275 4.75 2.25 0
276 5.00 0.50 0
277 5.00 0.75 0
278 5.00 1.50 0
279 5.00 2.50 0
280 5.25 0.25 0
281 5.25 1.00 0
282 5.25 1.50 0
283 5.50 0.50 0
284 5.50 1.50 0
285 5.50 2.50 0
286 5.75 1.75 0
287 6.00 0.50 0
288 6.00 1.25 0
289 6.25 0.50 0
290 6.25 1.25 0
291 6.50 0.75 0
292 6.75 0.50 0
293 6.75 0.75 0
294 7.00 0.75 0
295 7.25 0.25 0
> attach(aids)
> infect
[1] 0.00 0.25 0.75 0.75 0.75 1.00 1.00 1.00 1.00 1.25 1.25 1.25 1.25 1.50 1.50
[16] 1.50 1.50 1.50 1.75 1.75 1.75 1.75 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00
[31] 2.00 2.00 2.00 2.25 2.25 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50
[46] 2.50 2.50 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75
[61] 2.75 2.75 2.75 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00
[76] 3.00 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.50 3.50 3.50
[91] 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.75 3.75 3.75
[106] 3.75 3.75 3.75 3.75 3.75 3.75 3.75 3.75 4.00 4.00 4.00 4.00 4.00 4.00 4.00
[121] 4.00 4.00 4.00 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25
[136] 4.25 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50
[151] 4.50 4.50 4.50 4.50 4.50 4.50 4.75 4.75 4.75 4.75 4.75 4.75 4.75 4.75 4.75
[166] 4.75 4.75 4.75 4.75 4.75 4.75 4.75 4.75 5.00 5.00 5.00 5.00 5.00 5.00 5.00
[181] 5.00 5.00 5.00 5.00 5.00 5.00 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25
[196] 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.50 5.50 5.50 5.50 5.50 5.50
[211] 5.50 5.50 5.50 5.50 5.75 5.75 5.75 5.75 5.75 5.75 5.75 5.75 5.75 5.75 6.00
[226] 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.25
[241] 6.25 6.25 6.25 6.25 6.50 6.50 6.50 6.50 6.50 6.50 6.75 6.75 6.75 6.75 6.75
[256] 6.75 7.00 7.25 1.00 1.50 2.25 2.75 3.00 3.50 3.75 3.75 3.75 3.75 3.75 3.75
[271] 4.00 4.25 4.50 4.75 4.75 5.00 5.00 5.00 5.00 5.25 5.25 5.25 5.50 5.50 5.50
[286] 5.75 6.00 6.00 6.25 6.25 6.50 6.75 6.75 7.00 7.25
> detach(aids)
>
>
> #=====> 3. Survival objects <=====#
> data(tongue)
> attach(tongue)
> mySurvObject <- Surv(time, delta)
> mySurvObject
[1] 1 3 3 4 10 13 13 16 16 24 26 27 28 30 30
[16] 32 41 51 65 67 70 72 73 77 91 93 96 100 104 157
[31] 167 61+ 74+ 79+ 80+ 81+ 87+ 87+ 88+ 89+ 93+ 97+ 101+ 104+ 108+
[46] 109+ 120+ 131+ 150+ 231+ 240+ 400+ 1 3 4 5 5 8 12 13
[61] 18 23 26 27 30 42 56 62 69 104 104 112 129 181 8+
[76] 67+ 76+ 104+ 176+ 231+
> detach(tongue)
>
> # Surv(time, event, type="left")
>
> # Surv(t1, t2, event)
>
>
> #=====> 4. Kaplan-Meier estimate and pointwise bounds <=====#
> data(tongue)
> attach(tongue)
> mySurv <- Surv(time[type==1], delta[type==1])
> (myFit <- survfit(mySurv ~ 1))
Call: survfit(formula = mySurv ~ 1)
n events median 0.95LCL 0.95UCL
52 31 93 67 NA
> summary(myFit)
Call: survfit(formula = mySurv ~ 1)
time n.risk n.event survival std.err lower 95% CI upper 95% CI
1 52 1 0.981 0.0190 0.944 1.000
3 51 2 0.942 0.0323 0.881 1.000
4 49 1 0.923 0.0370 0.853 0.998
10 48 1 0.904 0.0409 0.827 0.988
13 47 2 0.865 0.0473 0.777 0.963
16 45 2 0.827 0.0525 0.730 0.936
24 43 1 0.808 0.0547 0.707 0.922
26 42 1 0.788 0.0566 0.685 0.908
27 41 1 0.769 0.0584 0.663 0.893
28 40 1 0.750 0.0600 0.641 0.877
30 39 2 0.712 0.0628 0.598 0.846
32 37 1 0.692 0.0640 0.578 0.830
41 36 1 0.673 0.0651 0.557 0.813
51 35 1 0.654 0.0660 0.537 0.797
65 33 1 0.634 0.0669 0.516 0.780
67 32 1 0.614 0.0677 0.495 0.762
70 31 1 0.594 0.0683 0.475 0.745
72 30 1 0.575 0.0689 0.454 0.727
73 29 1 0.555 0.0693 0.434 0.709
77 27 1 0.534 0.0697 0.414 0.690
91 19 1 0.506 0.0715 0.384 0.667
93 18 1 0.478 0.0728 0.355 0.644
96 16 1 0.448 0.0741 0.324 0.620
100 14 1 0.416 0.0754 0.292 0.594
104 12 1 0.381 0.0767 0.257 0.566
157 5 1 0.305 0.0918 0.169 0.550
167 4 1 0.229 0.0954 0.101 0.518
>
> myFit$surv # outputs the Kaplan-Meier estimate at each t_i
[1] 0.9807692 0.9423077 0.9230769 0.9038462 0.8653846 0.8269231 0.8076923
[8] 0.7884615 0.7692308 0.7500000 0.7115385 0.6923077 0.6730769 0.6538462
[15] 0.6538462 0.6340326 0.6142191 0.5944056 0.5745921 0.5547786 0.5547786
[22] 0.5342312 0.5342312 0.5342312 0.5342312 0.5342312 0.5342312 0.5342312
[29] 0.5061138 0.4779963 0.4481216 0.4481216 0.4161129 0.4161129 0.3814368
[36] 0.3814368 0.3814368 0.3814368 0.3814368 0.3814368 0.3051494 0.2288621
[43] 0.2288621 0.2288621 0.2288621
> myFit$time # t_i
[1] 1 3 4 10 13 16 24 26 27 28 30 32 41 51 61 65 67 70 72
[20] 73 74 77 79 80 81 87 88 89 91 93 96 97 100 101 104 108 109 120
[39] 131 150 157 167 231 240 400
> myFit$n.risk # Y_i
[1] 52 51 49 48 47 45 43 42 41 40 39 37 36 35 34 33 32 31 30 29 28 27 26 25 24
[26] 23 21 20 19 18 16 15 14 13 12 10 9 8 7 6 5 4 3 2 1
> myFit$n.event # d_i
[1] 1 2 1 1 2 2 1 1 1 1 2 1 1 1 0 1 1 1 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 0
[39] 0 0 1 1 0 0 0
> myFit$std.err # standard error of the K-M estimate at t_i
[1] 0.01941839 0.03431318 0.04003204 0.04523081 0.05469418 0.06344324
[7] 0.06766650 0.07182948 0.07595545 0.08006408 0.08829642 0.09245003
[13] 0.09664709 0.10090092 0.10090092 0.10548917 0.11016365 0.11494041
[19] 0.11983624 0.12486893 0.12486893 0.13044827 0.13044827 0.13044827
[25] 0.13044827 0.13044827 0.13044827 0.13044827 0.14121165 0.15234403
[31] 0.16545504 0.16545504 0.18130051 0.18130051 0.20111100 0.20111100
[37] 0.20111100 0.20111100 0.20111100 0.20111100 0.30074180 0.41686804
[43] 0.41686804 0.41686804 0.41686804
> myFit$lower # lower pointwise estimates (alternatively, $upper)
[1] 0.9441432 0.8810191 0.8534195 0.8271685 0.7774159 0.7302341 0.7073724
[8] 0.6849189 0.6628317 0.6410776 0.5984672 0.5775712 0.5569274 0.5365233
[15] 0.5365233 0.5156073 0.4949392 0.4745101 0.4543127 0.4343412 0.4343412
[22] 0.4137057 0.4137057 0.4137057 0.4137057 0.4137057 0.4137057 0.4137057
[29] 0.3837502 0.3546085 0.3240114 0.3240114 0.2916674 0.2916674 0.2571797
[36] 0.2571797 0.2571797 0.2571797 0.2571797 0.2571797 0.1692469 0.1010963
[43] 0.1010963 0.1010963 0.1010963
>
> #pdf("kmPlot.pdf", 7, 4.5)
> #par(mar=c(3.9, 3.9, 2.5, 1), mgp=c(2.6, 0.7, 0))
> plot(myFit, main="Kaplan-Meier estimate with 95% confidence bounds",
+ xlab="time", ylab="survival function")
> #dev.off()
>
> myFit1 <- survfit(Surv(time, delta) ~ type) # 'type' specifies the grouping
> detach(tongue)
>
>
> #=====> 5. Kaplan-Meier confidence bands <=====#
> data(tongue)
> attach(tongue)
> mySurv <- Surv(time[type==1], delta[type==1])
> #pdf("confBand.pdf", 7, 4.5)
> #par(mar=c(3.9, 3.9, 2.5, 1), mgp=c(2.6, 0.7, 0))
> plot(survfit(mySurv ~ 1), xlab='time',
+ ylab='Estimated Survival Function',
+ main='Confidence intervals versus confidence bands')
> myCB <- confBands(mySurv)
Error in ep.c10[aU, aL] : subscript out of bounds
Calls: confBands
Execution halted
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-patched-linux-x86_64, r-release-linux-x86_64
Version: 0.2
Check: examples
Result: ERROR
Running examples in ‘OIsurv-Ex.R’ failed
The error most likely occurred in:
> ### Name: OIsurv-package
> ### Title: Survival analysis tutorial, a supplement to the OpenIntro guide
> ### Aliases: OIsurv-package OIsurv
>
> ### ** Examples
>
> #=====> 2. Three packages: survival, OIsurv, and KMsurv <=====#
> # install.packages("OIsurv")
> # library(OIsurv)
> data(aids)
> aids
infect induct adult
1 0.00 5.00 1
2 0.25 6.75 1
3 0.75 5.00 1
4 0.75 5.00 1
5 0.75 7.25 1
6 1.00 4.25 1
7 1.00 5.75 1
8 1.00 6.25 1
9 1.00 6.50 1
10 1.25 4.00 1
11 1.25 4.25 1
12 1.25 4.75 1
13 1.25 5.75 1
14 1.50 2.75 1
15 1.50 3.75 1
16 1.50 5.00 1
17 1.50 5.50 1
18 1.50 6.50 1
19 1.75 2.75 1
20 1.75 3.00 1
21 1.75 5.25 1
22 1.75 5.25 1
23 2.00 2.25 1
24 2.00 3.00 1
25 2.00 4.00 1
26 2.00 4.50 1
27 2.00 4.75 1
28 2.00 5.00 1
29 2.00 5.25 1
30 2.00 5.25 1
31 2.00 5.50 1
32 2.00 5.50 1
33 2.00 6.00 1
34 2.25 3.00 1
35 2.25 5.50 1
36 2.50 2.25 1
37 2.50 2.25 1
38 2.50 2.25 1
39 2.50 2.25 1
40 2.50 2.50 1
41 2.50 2.75 1
42 2.50 3.00 1
43 2.50 3.25 1
44 2.50 3.25 1
45 2.50 4.00 1
46 2.50 4.00 1
47 2.50 4.00 1
48 2.75 1.25 1
49 2.75 1.50 1
50 2.75 2.50 1
51 2.75 3.00 1
52 2.75 3.00 1
53 2.75 3.25 1
54 2.75 3.75 1
55 2.75 4.50 1
56 2.75 4.50 1
57 2.75 5.00 1
58 2.75 5.00 1
59 2.75 5.25 1
60 2.75 5.25 1
61 2.75 5.25 1
62 2.75 5.25 1
63 2.75 5.25 1
64 3.00 2.00 1
65 3.00 3.25 1
66 3.00 3.50 1
67 3.00 3.75 1
68 3.00 4.00 1
69 3.00 4.00 1
70 3.00 4.25 1
71 3.00 4.25 1
72 3.00 4.25 1
73 3.00 4.75 1
74 3.00 4.75 1
75 3.00 4.75 1
76 3.00 5.00 1
77 3.25 1.25 1
78 3.25 1.75 1
79 3.25 2.00 1
80 3.25 2.00 1
81 3.25 2.75 1
82 3.25 3.00 1
83 3.25 3.00 1
84 3.25 3.50 1
85 3.25 3.50 1
86 3.25 4.25 1
87 3.25 4.50 1
88 3.50 1.25 1
89 3.50 2.25 1
90 3.50 2.25 1
91 3.50 2.50 1
92 3.50 2.75 1
93 3.50 2.75 1
94 3.50 3.00 1
95 3.50 3.25 1
96 3.50 3.50 1
97 3.50 3.50 1
98 3.50 4.00 1
99 3.50 4.00 1
100 3.50 4.25 1
101 3.50 4.50 1
102 3.50 4.50 1
103 3.75 1.25 1
104 3.75 1.75 1
105 3.75 1.75 1
106 3.75 2.00 1
107 3.75 2.75 1
108 3.75 3.00 1
109 3.75 3.00 1
110 3.75 3.00 1
111 3.75 4.00 1
112 3.75 4.25 1
113 3.75 4.25 1
114 4.00 1.00 1
115 4.00 1.50 1
116 4.00 1.50 1
117 4.00 2.00 1
118 4.00 2.25 1
119 4.00 2.75 1
120 4.00 3.50 1
121 4.00 3.75 1
122 4.00 3.75 1
123 4.00 4.00 1
124 4.25 1.25 1
125 4.25 1.50 1
126 4.25 1.50 1
127 4.25 2.00 1
128 4.25 2.00 1
129 4.25 2.00 1
130 4.25 2.25 1
131 4.25 2.50 1
132 4.25 2.50 1
133 4.25 2.50 1
134 4.25 3.00 1
135 4.25 3.50 1
136 4.25 3.50 1
137 4.50 1.00 1
138 4.50 1.50 1
139 4.50 1.50 1
140 4.50 1.50 1
141 4.50 1.75 1
142 4.50 2.25 1
143 4.50 2.25 1
144 4.50 2.50 1
145 4.50 2.50 1
146 4.50 2.50 1
147 4.50 2.50 1
148 4.50 2.75 1
149 4.50 2.75 1
150 4.50 2.75 1
151 4.50 2.75 1
152 4.50 3.00 1
153 4.50 3.00 1
154 4.50 3.00 1
155 4.50 3.25 1
156 4.50 3.25 1
157 4.75 1.00 1
158 4.75 1.50 1
159 4.75 1.50 1
160 4.75 1.50 1
161 4.75 1.75 1
162 4.75 1.75 1
163 4.75 2.00 1
164 4.75 2.25 1
165 4.75 2.75 1
166 4.75 3.00 1
167 4.75 3.00 1
168 4.75 3.25 1
169 4.75 3.25 1
170 4.75 3.25 1
171 4.75 3.25 1
172 4.75 3.25 1
173 4.75 3.25 1
174 5.00 0.50 1
175 5.00 1.50 1
176 5.00 1.50 1
177 5.00 1.75 1
178 5.00 2.00 1
179 5.00 2.25 1
180 5.00 2.25 1
181 5.00 2.25 1
182 5.00 2.50 1
183 5.00 2.50 1
184 5.00 3.00 1
185 5.00 3.00 1
186 5.00 3.00 1
187 5.25 0.25 1
188 5.25 0.25 1
189 5.25 0.75 1
190 5.25 0.75 1
191 5.25 0.75 1
192 5.25 1.00 1
193 5.25 1.00 1
194 5.25 1.25 1
195 5.25 1.25 1
196 5.25 1.50 1
197 5.25 1.50 1
198 5.25 1.50 1
199 5.25 1.50 1
200 5.25 2.25 1
201 5.25 2.25 1
202 5.25 2.50 1
203 5.25 2.50 1
204 5.25 2.75 1
205 5.50 1.00 1
206 5.50 1.00 1
207 5.50 1.00 1
208 5.50 1.25 1
209 5.50 1.25 1
210 5.50 1.75 1
211 5.50 2.00 1
212 5.50 2.25 1
213 5.50 2.25 1
214 5.50 2.50 1
215 5.75 0.25 1
216 5.75 0.25 1
217 5.75 0.75 1
218 5.75 1.00 1
219 5.75 1.50 1
220 5.75 1.50 1
221 5.75 1.50 1
222 5.75 2.00 1
223 5.75 2.00 1
224 5.75 2.25 1
225 6.00 0.50 1
226 6.00 0.75 1
227 6.00 0.75 1
228 6.00 0.75 1
229 6.00 1.00 1
230 6.00 1.00 1
231 6.00 1.00 1
232 6.00 1.25 1
233 6.00 1.25 1
234 6.00 1.50 1
235 6.00 1.50 1
236 6.00 1.75 1
237 6.00 1.75 1
238 6.00 1.75 1
239 6.00 2.00 1
240 6.25 0.75 1
241 6.25 1.00 1
242 6.25 1.25 1
243 6.25 1.75 1
244 6.25 1.75 1
245 6.50 0.25 1
246 6.50 0.25 1
247 6.50 0.75 1
248 6.50 1.00 1
249 6.50 1.25 1
250 6.50 1.50 1
251 6.75 0.75 1
252 6.75 0.75 1
253 6.75 1.00 1
254 6.75 1.25 1
255 6.75 1.25 1
256 6.75 1.25 1
257 7.00 0.75 1
258 7.25 0.25 1
259 1.00 5.50 0
260 1.50 2.25 0
261 2.25 3.00 0
262 2.75 1.00 0
263 3.00 1.75 0
264 3.50 0.75 0
265 3.75 0.75 0
266 3.75 1.00 0
267 3.75 2.75 0
268 3.75 3.00 0
269 3.75 3.50 0
270 3.75 4.25 0
271 4.00 1.00 0
272 4.25 1.75 0
273 4.50 3.25 0
274 4.75 1.00 0
275 4.75 2.25 0
276 5.00 0.50 0
277 5.00 0.75 0
278 5.00 1.50 0
279 5.00 2.50 0
280 5.25 0.25 0
281 5.25 1.00 0
282 5.25 1.50 0
283 5.50 0.50 0
284 5.50 1.50 0
285 5.50 2.50 0
286 5.75 1.75 0
287 6.00 0.50 0
288 6.00 1.25 0
289 6.25 0.50 0
290 6.25 1.25 0
291 6.50 0.75 0
292 6.75 0.50 0
293 6.75 0.75 0
294 7.00 0.75 0
295 7.25 0.25 0
> attach(aids)
> infect
[1] 0.00 0.25 0.75 0.75 0.75 1.00 1.00 1.00 1.00 1.25 1.25 1.25 1.25 1.50 1.50
[16] 1.50 1.50 1.50 1.75 1.75 1.75 1.75 2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00
[31] 2.00 2.00 2.00 2.25 2.25 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50 2.50
[46] 2.50 2.50 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75 2.75
[61] 2.75 2.75 2.75 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00
[76] 3.00 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.25 3.50 3.50 3.50
[91] 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.50 3.75 3.75 3.75
[106] 3.75 3.75 3.75 3.75 3.75 3.75 3.75 3.75 4.00 4.00 4.00 4.00 4.00 4.00 4.00
[121] 4.00 4.00 4.00 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25 4.25
[136] 4.25 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50 4.50
[151] 4.50 4.50 4.50 4.50 4.50 4.50 4.75 4.75 4.75 4.75 4.75 4.75 4.75 4.75 4.75
[166] 4.75 4.75 4.75 4.75 4.75 4.75 4.75 4.75 5.00 5.00 5.00 5.00 5.00 5.00 5.00
[181] 5.00 5.00 5.00 5.00 5.00 5.00 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25
[196] 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.25 5.50 5.50 5.50 5.50 5.50 5.50
[211] 5.50 5.50 5.50 5.50 5.75 5.75 5.75 5.75 5.75 5.75 5.75 5.75 5.75 5.75 6.00
[226] 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.00 6.25
[241] 6.25 6.25 6.25 6.25 6.50 6.50 6.50 6.50 6.50 6.50 6.75 6.75 6.75 6.75 6.75
[256] 6.75 7.00 7.25 1.00 1.50 2.25 2.75 3.00 3.50 3.75 3.75 3.75 3.75 3.75 3.75
[271] 4.00 4.25 4.50 4.75 4.75 5.00 5.00 5.00 5.00 5.25 5.25 5.25 5.50 5.50 5.50
[286] 5.75 6.00 6.00 6.25 6.25 6.50 6.75 6.75 7.00 7.25
> detach(aids)
>
>
> #=====> 3. Survival objects <=====#
> data(tongue)
> attach(tongue)
> mySurvObject <- Surv(time, delta)
> mySurvObject
[1] 1 3 3 4 10 13 13 16 16 24 26 27 28 30 30
[16] 32 41 51 65 67 70 72 73 77 91 93 96 100 104 157
[31] 167 61+ 74+ 79+ 80+ 81+ 87+ 87+ 88+ 89+ 93+ 97+ 101+ 104+ 108+
[46] 109+ 120+ 131+ 150+ 231+ 240+ 400+ 1 3 4 5 5 8 12 13
[61] 18 23 26 27 30 42 56 62 69 104 104 112 129 181 8+
[76] 67+ 76+ 104+ 176+ 231+
> detach(tongue)
>
> # Surv(time, event, type="left")
>
> # Surv(t1, t2, event)
>
>
> #=====> 4. Kaplan-Meier estimate and pointwise bounds <=====#
> data(tongue)
> attach(tongue)
> mySurv <- Surv(time[type==1], delta[type==1])
> (myFit <- survfit(mySurv ~ 1))
Call: survfit(formula = mySurv ~ 1)
n events median 0.95LCL 0.95UCL
52 31 93 67 NA
> summary(myFit)
Call: survfit(formula = mySurv ~ 1)
time n.risk n.event survival std.err lower 95% CI upper 95% CI
1 52 1 0.981 0.0190 0.944 1.000
3 51 2 0.942 0.0323 0.881 1.000
4 49 1 0.923 0.0370 0.853 0.998
10 48 1 0.904 0.0409 0.827 0.988
13 47 2 0.865 0.0473 0.777 0.963
16 45 2 0.827 0.0525 0.730 0.936
24 43 1 0.808 0.0547 0.707 0.922
26 42 1 0.788 0.0566 0.685 0.908
27 41 1 0.769 0.0584 0.663 0.893
28 40 1 0.750 0.0600 0.641 0.877
30 39 2 0.712 0.0628 0.598 0.846
32 37 1 0.692 0.0640 0.578 0.830
41 36 1 0.673 0.0651 0.557 0.813
51 35 1 0.654 0.0660 0.537 0.797
65 33 1 0.634 0.0669 0.516 0.780
67 32 1 0.614 0.0677 0.495 0.762
70 31 1 0.594 0.0683 0.475 0.745
72 30 1 0.575 0.0689 0.454 0.727
73 29 1 0.555 0.0693 0.434 0.709
77 27 1 0.534 0.0697 0.414 0.690
91 19 1 0.506 0.0715 0.384 0.667
93 18 1 0.478 0.0728 0.355 0.644
96 16 1 0.448 0.0741 0.324 0.620
100 14 1 0.416 0.0754 0.292 0.594
104 12 1 0.381 0.0767 0.257 0.566
157 5 1 0.305 0.0918 0.169 0.550
167 4 1 0.229 0.0954 0.101 0.518
>
> myFit$surv # outputs the Kaplan-Meier estimate at each t_i
[1] 0.9807692 0.9423077 0.9230769 0.9038462 0.8653846 0.8269231 0.8076923
[8] 0.7884615 0.7692308 0.7500000 0.7115385 0.6923077 0.6730769 0.6538462
[15] 0.6538462 0.6340326 0.6142191 0.5944056 0.5745921 0.5547786 0.5547786
[22] 0.5342312 0.5342312 0.5342312 0.5342312 0.5342312 0.5342312 0.5342312
[29] 0.5061138 0.4779963 0.4481216 0.4481216 0.4161129 0.4161129 0.3814368
[36] 0.3814368 0.3814368 0.3814368 0.3814368 0.3814368 0.3051494 0.2288621
[43] 0.2288621 0.2288621 0.2288621
> myFit$time # t_i
[1] 1 3 4 10 13 16 24 26 27 28 30 32 41 51 61 65 67 70 72
[20] 73 74 77 79 80 81 87 88 89 91 93 96 97 100 101 104 108 109 120
[39] 131 150 157 167 231 240 400
> myFit$n.risk # Y_i
[1] 52 51 49 48 47 45 43 42 41 40 39 37 36 35 34 33 32 31 30 29 28 27 26 25 24
[26] 23 21 20 19 18 16 15 14 13 12 10 9 8 7 6 5 4 3 2 1
> myFit$n.event # d_i
[1] 1 2 1 1 2 2 1 1 1 1 2 1 1 1 0 1 1 1 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 0
[39] 0 0 1 1 0 0 0
> myFit$std.err # standard error of the K-M estimate at t_i
[1] 0.01941839 0.03431318 0.04003204 0.04523081 0.05469418 0.06344324
[7] 0.06766650 0.07182948 0.07595545 0.08006408 0.08829642 0.09245003
[13] 0.09664709 0.10090092 0.10090092 0.10548917 0.11016365 0.11494041
[19] 0.11983624 0.12486893 0.12486893 0.13044827 0.13044827 0.13044827
[25] 0.13044827 0.13044827 0.13044827 0.13044827 0.14121165 0.15234403
[31] 0.16545504 0.16545504 0.18130051 0.18130051 0.20111100 0.20111100
[37] 0.20111100 0.20111100 0.20111100 0.20111100 0.30074180 0.41686804
[43] 0.41686804 0.41686804 0.41686804
> myFit$lower # lower pointwise estimates (alternatively, $upper)
[1] 0.9441432 0.8810191 0.8534195 0.8271685 0.7774159 0.7302341 0.7073724
[8] 0.6849189 0.6628317 0.6410776 0.5984672 0.5775712 0.5569274 0.5365233
[15] 0.5365233 0.5156073 0.4949392 0.4745101 0.4543127 0.4343412 0.4343412
[22] 0.4137057 0.4137057 0.4137057 0.4137057 0.4137057 0.4137057 0.4137057
[29] 0.3837502 0.3546085 0.3240114 0.3240114 0.2916674 0.2916674 0.2571797
[36] 0.2571797 0.2571797 0.2571797 0.2571797 0.2571797 0.1692469 0.1010963
[43] 0.1010963 0.1010963 0.1010963
>
> #pdf("kmPlot.pdf", 7, 4.5)
> #par(mar=c(3.9, 3.9, 2.5, 1), mgp=c(2.6, 0.7, 0))
> plot(myFit, main="Kaplan-Meier estimate with 95% confidence bounds",
+ xlab="time", ylab="survival function")
> #dev.off()
>
> myFit1 <- survfit(Surv(time, delta) ~ type) # 'type' specifies the grouping
> detach(tongue)
>
>
> #=====> 5. Kaplan-Meier confidence bands <=====#
> data(tongue)
> attach(tongue)
> mySurv <- Surv(time[type==1], delta[type==1])
> #pdf("confBand.pdf", 7, 4.5)
> #par(mar=c(3.9, 3.9, 2.5, 1), mgp=c(2.6, 0.7, 0))
> plot(survfit(mySurv ~ 1), xlab='time',
+ ylab='Estimated Survival Function',
+ main='Confidence intervals versus confidence bands')
> myCB <- confBands(mySurv)
Error in ep.c10[aU, aL] : subscript out of bounds
Calls: confBands
Execution halted
Flavors: r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-ix86+x86_64, r-patched-solaris-x86, r-release-windows-ix86+x86_64, r-oldrel-windows-ix86+x86_64