3.4 Constructing Confidence Intervals

The ci() command from the epiDisplay package calculates confidence intervals using an assumed t-distribution. It defaults to a 95% confidence interval, but this can be changed with the option ‘alpha’, as in the second line of code below for a 99% confidence interval. Note that the 99% confidence interval is wider than the 95% confidence interval, as we would expect.

#--- Generate 95% and 99% confidence intervals
##    n mean  sd   se lower95ci upper95ci
##  641 3129 653 25.8      3079      3180
ci(bab9$bweight, alpha = 0.01)
##    n mean  sd   se lower99ci upper99ci
##  641 3129 653 25.8      3063      3196

Note that the implicit calculation performed by the ci() command is: \[\bar{X} \pm t \frac{s}{\sqrt{n}}\]

\(\bar{X}\) represents the sample mean, \(t\) the value of the t-distribution for a given number of degrees of freedom and confidence level, \(s\) the sample standard deviation, and \(n\) the sample size.