57 lines
1.8 KiB
Plaintext
57 lines
1.8 KiB
Plaintext
|
|
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
|
|
Copyright (C) 2016 The R Foundation for Statistical Computing
|
|
Platform: x86_64-apple-darwin13.4.0 (64-bit)
|
|
|
|
R is free software and comes with ABSOLUTELY NO WARRANTY.
|
|
You are welcome to redistribute it under certain conditions.
|
|
Type 'license()' or 'licence()' for distribution details.
|
|
|
|
R is a collaborative project with many contributors.
|
|
Type 'contributors()' for more information and
|
|
'citation()' on how to cite R or R packages in publications.
|
|
|
|
Type 'demo()' for some demos, 'help()' for on-line help, or
|
|
'help.start()' for an HTML browser interface to help.
|
|
Type 'q()' to quit R.
|
|
|
|
> library(survival)
|
|
>
|
|
> #
|
|
> # The survival code was failing for certain data sets when called as
|
|
> # survfit(Surv(time2-time1, status) ~ ......
|
|
> # The issue was how tied floating point numbers are handled, and the
|
|
> # fact that unique(x), factor(x) and tapply(x) are not guarranteed to
|
|
> # all be the same.
|
|
> # This test fails in survival 2.36-5, fixed in 2.36-6. Data sets that
|
|
> # can cause it are few and far between.
|
|
> #
|
|
>
|
|
> load('ties.rda')
|
|
> x <- time2 -time1
|
|
>
|
|
> # Here is the heart of the old problem
|
|
> # length(unique(x))== length(table(x))
|
|
> # And the prior fix which worked ALMOST always
|
|
> # x <- round(x, 15)
|
|
> # length(unique(round(x,15)))== length(table(round(x,15)))
|
|
>
|
|
> fit1 <- survfit(Surv(x) ~1)
|
|
> length(fit1$time) == length(fit1$surv)
|
|
[1] TRUE
|
|
>
|
|
>
|
|
> # a second test, once "rounding.R"
|
|
>
|
|
> tdata <- data.frame(time=c(1,2, sqrt(2)^2, 2, sqrt(2)^2),
|
|
+ status=rep(1,5),
|
|
+ group=c(1,1,1,2,2))
|
|
> fit <- survfit(Surv(time, status) ~ group, data=tdata)
|
|
>
|
|
> all.equal(sum(fit$strata), length(fit$time))
|
|
[1] TRUE
|
|
>
|
|
> proc.time()
|
|
user system elapsed
|
|
0.733 0.053 0.802
|