In this post, I will show how one can easily construct confidence intervals in R. Assume you have a vector of numbers and you want to construct a confidence interval around the mean of this vector. The subsequent R code shows one easy way to calculate the confidence interval around the mean of this vector. The following code loads a function that allows you to pass on the vector and returns the confidence intervals. Per default the function returns the 95% confidence interval. However, the parameter ‘conf_level’ allows you to specify the interval you want. Furthermore, if you do not have many observations, you may want to use Student’s t-distribution instead of the Normal distribution. The Student’s t-distribution has wider tales when the number of observations is low and gives a you more conservative estimates of your confidence interval. In case you want to use Student’s t-distribution you case set the parameter ‘distribution’, i.e. distribution=”normal”.

Continue reading Confidence Intervals in R →