The Rule of Thumb 95% confidence interval is calculated simply as the sample mean +/- two standard errors.
Thus, the lower confidence limit is calculated as the sample mean minus 2 times the standard error, and the upper confidence limit is calculated as the sample mean plus 2 times the standard error.
We can re-use code from the previous section for the calculations, and we’ll assign the output to a new object called “newsamp.n20.allstats”:
<- newsamp.n20 %>% newsamp.n20.allstats summarise( Count = n() - naniar::n_miss(size), Mean_genelength = mean(size, na.rm = TRUE), SD_genelength = sd(size, na.rm = TRUE), SEM = SD_genelength/sqrt(Count), Lower_95_CL = Mean_genelength - 2 * SEM, Upper_95_CL = Mean_genelength + 2 * SEM )
We’ve added two lines of code, one for the lower confidence limit and one for the upper confidence limit.
Notice that we again use calculations completed in preceding lines as input for the subsequent lines. Specifically, we use the “Mean_genelength” value and the “SEM” value in our confidence limit calculations.
The asterisk (*) denotes multiplication.
Let’s look at the output:
kable(newsamp.n20.allstats, digits = 4)
If you are asked to report the rule-of-thumb 95% confidence interval, then you’d use the output from your calculations above to report:
1887.744 < \(\mu\) < 5239.656
Note that it is the population parameter being estimated, \(\mu\), that appears in between the lower and upper limits.
To produce greek letters such as “mu”, simply precede the “mu” with a backslash, then enclose the entire term with dollar signs, as shown at this webpage.
NOTE: In a later tutorial you’ll learn how to calculate actual confidence intervals, rather than “rule of thumb” confidence intervals