what are the internals of mean_cl_normal function and is it safe to use for confidence intervals calculation? How does it work in detail?
mean_cl_normal is part of ggplot. It uses smean.cl.normal(...) in Hmisc, which uses quantiles of the t-distribution to calculate confidence limits.
set.seed(1) # for reproducibility
x <- rnorm(100, mean=5)
library(Hmisc)
smean.cl.normal(x)
# Mean Lower Upper
# 5.108887 4.930665 5.287110
mean(x) + c(0,1,-1) * qt(0.05/2,(length(x)-1))*sd(x)/sqrt(length(x))
# [1] 5.108887 4.930665 5.287110
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With