[R] Survival Plots by Strata
Bret Collier
bret at tamu.edu
Wed Mar 8 16:55:54 CET 2006
Thomas,
Thank you for the response. I will post what I come up with.
Bret
>>> Thomas Lumley <tlumley at u.washington.edu> 03/08/06 9:16 AM >>>
I don't see any easy way to do this. I think you may have to do the
plotting yourself, based on the code in plot.survfit.
-thomas
On Wed, 8 Mar 2006, Bret Collier wrote:
> All,
> I am struggling to create a survival plot using LTRC data for each
year
> of a 10 year period.
>
> I have a set of individuals (birds) where 'entry' is the day of the
> year (1-365) they are released (let out of pens) into the wild (2
year
> data snip below). 'Entry' (e.g., day of year the first bird is
> released for each year) is highly variable, ranging from 48 to >250.
> When I create a plot using the below code I would like to remove the
> 'solid' line which represent S_hat=1 out to the LC point for each
year
> and instead have the survival curves formatted in more of a
'hanging'
> style, where the LC day (e.g., min(Entry for each year)) is where
each
> curve begins at S_hat=1 for each year (and does not extend back to
the
> y-axis)? I could not find anything on this in the archives or MASS
or
> Survival Analysis using S? Anyone have a suggestion on where to
look?
>
> TIA, Bret
>
>
> #Code snip for R email.
> apc.coxfit1<-coxph(Surv(Entry, Exit, Fate)~Sex + Agerelease +
> Dayrelease + strata(Year), data=mydat)
> coxfit.apc<-survfit(apc.coxfit1)
> coxfit.apc
> plot(survfit(apc.coxfit1), conf.int=F, log=T, lty=c(1:2),
col=c(1:2),
> xlim=c(205, 800)) #not run--first entry for this example is day 205
for
> 1996, 259 for 1997
>
>> mydat
> ID Year Dayrelease
> Agerelease Survivorship Entry Exit Fate Sex
>
16240 1996 205 95 164 205 369 1 0
>
16319 1996 205 88 140 205 345 1 0
>
16378 1996 248 108 100 248 348 1 0
>
20383 1996 241 98 204 241 445 1 0
>
16324 1996 219 90 227 219 446 1 0
>
16327 1996 219 90 497 219 716 1 0
>
20373 1996 241 114 413 241 654 1 0
>
20374 1996 241 111 211 241 452 1 0
>
16241 1996 205 95 234 205 439 1 1
>
16321 1996 219 90 118 219 337 1 1
>
16323 1996 219 90 180 219 399 1 1
>
20375 1996 241 103 268 241 509 1 1
>
20384 1996 241 98 299 241 540 1 1
>
20390 1996 241 93 204 241 445 1 1
>
20393 1996 241 88 208 241 449 1 1
>
16313 1996 248 122 512 248 760 0 1
>
20378 1996 241 103 236 241 477 0 1
>
20381 1996 241 101 329 241 570 0 1
>
16328 1996 219 90 224 219 443 0 1
>
16827 1997 259 127 52 259 311 1 0
>
16828 1997 259 127 216 259 475 1 0
>
16831 1997 303 171 19 303 322 1 0
>
20466 1997 289 149 31 289 320 1 0
>
20469 1997 289 149 199 289 488 1 0
>
20483 1997 289 134 18 289 307 1 0
>
16807 1997 259 137 223 259 482 1 0
>
16809 1997 259 137 1 259 260 1 0
>
16819 1997 259 131 237 259 496 1 0
>
16829 1997 303 171 7 303 310 1 0
>
20440 1997 289 161 7 289 296 1 0
>
20470 1997 289 148 257 289 546 1 0
>
20478 1997 289 143 12 289 301 1 0
>
16817 1997 259 130 85 259 344 1 0
>
20454 1997 289 154 4 289 293 1 1
>
20459 1997 289 153 335 289 624 1 1
>
20460 1997 289 153 118 289 407 1 1
>
20465 1997 289 150 31 289 320 1 1
>
20473 1997 289 147 65 289 354 1 1
>
20484 1997 289 133 58 289 347 1 1
>
20489 1997 289 130 56 289 345 1 1
>
16808 1997 259 137 137 259 396 0 1
>
16810 1997 303 181 64 303 367 0 1
>
16816 1997 259 130 1 259 260 0 1
>
20471 1997 289 147 334 289 623 0 1
>
16826 1997 259 127 20 259 279 0 1
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list