I am unsure which method to use for calculating confidence interval for median values. I know the data set is small (n = 30). I've read these discussions which suggest both "bootstrap" and "binomial/SAS/exact" methods are feasible:
- Confidence intervals for median
- Confidence interval for median
- https://statisticsbyjim.com/hypothesis-testing/bootstrapping/
Can anyone provide insights on which one is more appropriate for the example data set and also why the CI ranges for the median is so different between the two methods for these two data sets I have below using the "DescTools" library in R? I have other data sets (example data3) where the results between the two methods are similar.
library(DescTools)
data1 = c(8, 7, 8, 9.5, 1, 20, 8, 7.5, 3, 20.5, 2.5, 5.5, 15.5, 2, 4, 1,
17, 2, 3.5, 8.5, 8.5, 2.5, 11, 4, 10.5, 7.5, 12, 5, 16.5, 8.5)
data2 = c(7.1, 32.0, 3.8, 1.6, 19.6, 6.0, 7.2, 14.9, 0, 2.0, 5.7,
19.4, 13.1, 15.5, 11.3, 9.6, 13.9, 5.6, 12.6, 1.0, 1.9,
8.1, 15.9, 0.8, 6.1, 8.1, 18.0, 4.6, 5.5, 15.6)
data3 = c(16.1, 10.4, 0.5, 12.2, 7.2, 1.7, 21.6, 6.3, 0.8, 3.2, 12.6, 20.0, 3.4, 7.3, 3.5,
7.5, 15.8, 4.7, 8.3, 11.9, 1.6, 9.0, 8.6, 11.7, 8.1, 5.8, 3.3, 7.9, 7.0, 8.5)
medianCI_Bootstrap_dF1 = MedianCI(data1, na.rm = TRUE, method = "boot")
medianCI_Binom_dF1 = MedianCI(data1, na.rm = TRUE, method = "exact")
medianCI_Bootstrap_dF1
medianCI_Binom_dF1
medianCI_Bootstrap_dF2 = MedianCI(data2, na.rm = TRUE, method = "boot")
medianCI_Binom_dF2 = MedianCI(data2, na.rm = TRUE, method = "exact")
medianCI_Bootstrap_dF2
medianCI_Binom_dF2
medianCI_Bootstrap_dF3 = MedianCI(data3, na.rm = TRUE, method = "boot")
medianCI_Binom_dF3 = MedianCI(data3, na.rm = TRUE, method = "exact")
medianCI_Bootstrap_dF3
medianCI_Binom_dF3