Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does the 'mean_cl_normal function' from Hmisc work?

Tags:

r

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?

like image 770
cross Avatar asked Oct 29 '25 08:10

cross


1 Answers

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
like image 94
jlhoward Avatar answered Oct 31 '25 23:10

jlhoward



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!