I've been using R package "compareGroups" for a while now. But I've been curious and playing with it and I don't understand how compareGroups computes confidence intervals.
data <- data.frame(a = c(1:20, 1:20), b = c(rep("A",20), rep("B",20)))
I get (with conf.level = 0.95 as default)
> compareGroups(b~a , data = data.frame(a = c(1:20, 1:20), b = c(rep("A",20), rep("B",20)))) %>%
+ createTable(digits = 2, show.ci = T)
--------Summary descriptives table by 'b'---------
_________________________________________________
A B p.overall
N=20 N=20
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
a 10.50 [7.73;13.27] 10.50 [7.73;13.27] 1.000
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
But then, if i try manually, I get those results :
> mean(1:20) - qnorm(0.975)*sd(1:20)/sqrt(20)
[1] 7.907211
> mean(1:20) + qnorm(0.975)*sd(1:20)/sqrt(20)
[1] 13.09279
Which are somehow different than what I got from the compareGroups %>% createTable function
Does any of you know how this package works ? Or maybe am I wrong somewhere calculating my confidence interval ?
Thank you for your help.