Open itsdfish opened 2 years ago
I'm not familiar with the mice
library in R. Does the same thing happen using the survival
library?
Unfortunately, I had trouble figuring out how to adapt the example above to surival
in R. Here is what I tried, but the output didn't look correct:
library("survival")
df = data.frame(time = c(1,2,3,4,5))
df$status = 1
fit <- survfit(Surv(time, status) ~ 1, ctype=1, data = df)
Do you have more experience with it?
AFAIK there are two ways, one more manual than the other:
library("survival")
df <- data.frame(time=1:5, status=1)
na1 <- basehaz(coxph(Surv(time, status) ~ 1, data=df))$hazard
surv <- survfit(Surv(time, status) ~ 1, data=df)
na2 <- cumsum(surv$n.event / surv$n.risk)
They produce the same result, which matches your mice
example.
However, when using other data (specifically t
and s
as defined in the Nelson-Aalen portion of test/runtests.jl
), I get matching results for Julia and R.
I noticed that NelsonAalen repeats the second to last value twice. I thought this was odd, so I compared it to R.
Julia
Result
R
Result
Version