The longevity
package includes an implementation of Turnbull's EM algorithm for the empirical distribution function for data subject to arbitrary censoring and truncation patterns.
For example, we can consider the interval censored data considered in @Lindsey.Ryan:1998. The left
and right
give respectively.
#| label: fig-aids #| eval: true #| echo: true #| fig-cap: "Nonparametric maximum likelihood estimate of the distribution function for the AIDS data" #| out-width: '80%' #| fig-width: 12 #| fig-height: 8 library(longevity) left <- c(0,15,12,17,13,0,6,0,14,12,13,12,12,0,0,0,0,3,4,1,13,0,0,6,0,2,1,0,0,2,0) right <- c(16, rep(Inf, 4), 24, Inf, 15, rep(Inf, 5), 18, 14, 17, 15, Inf, Inf, 11, 19, 6, 11, Inf, 6, 12, 17, 14, 25, 11, 14) test <- np_elife(time = left, # left bound for time time2 = right, # right bound for time type = "interval2", # data are interval censored event = 3) # specify interval censoring, argument recycled plot(test)
We can also extract the equivalence classes and compare them to @Lindsey.Ryan:1998: these match the values returned in the paper. The summary statistics reported by the print
method include the restricted mean, which is computed by calculating the area under the survival curve.
test$xval print(test)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.