========================================================
Author: Bruce Dudek at the University at Albany.
Assistance In R coding was provided by Jason Bryer, University at Albany and Excelsior College.
Built using Shiny by Rstudio and R, the Statistical Programming Language.
The purpose of this app is to provide a visualization that aids in the proper conceptualization of confidence intervals. It is illustrated with confidence intervals for a sample mean. The app is not meant to be a stand alone method of fully understanding confidence intervals, but it can provide a useful accompaniment to initial introduction of the concept in a classroom setting, guided by the instructor.
Key aspects of the conceptualization are:
Confidence intervals are centered on the observed sample mean.
With simulation, we can show what happens when repeated samples are drawn from the same population distribution. The sample mean from these simulated samples will vary according to its own sampling distribution.
Since confidence intervals are centered on the sample mean, these intervals also vary in the region of the Random Variable scale that they span.
If a Confidence level of 95% is chosen, we expect approximately 95% of the simulated intervals to overlap the true location of the population mean.
In our simulation, we have specified the true population mean so we can make this comparison to the "confidence" level. But in realistic analysis we don't know the true value of mu, but have some "confidence" about its location provided by the calculated CI. For example, we will know that with a CI of 95%, that 95% of the time, if we repeated the sample, our computed CI would overlap the true value of mu.
When sigma (population SD) is known, then the confidence interval can be found using std normal Z deviates based on the CI level, IF WE CAN ASSUME THAT THE SAMPLING DISTRIBUTION OF THE MEAN IS NORMAL.
If Sigma is known, the CI calculation defines an interval that is a number of standard errors above and below the sample mean: (\bar{X}\pm {{Z}{(1-CI)}}*{({{\sigma }{X}}}/{\sqrt{N}}\;))
If Sigma is unknown, the interval uses a critical t value instead of a std normal Z, it requires df, and an estimate of the standard error which uses the sample standard deviation: (\bar{X}\pm {{t}{(1-\text{CI),df}}}*{(s{{d}{X}}}/{\sqrt{N}}\;))
This app was inspired by a type of plot found in Box, Hunter and Hunter (1978, "Statistics for Experimenters", New York, J. Wiley) This type of plot has been dynamically implemented in a useful javascript applet from the Rossman/Chance collection and in an impressive D3 implementation by Kristoffer Magnusson. R/Shiny code to create a rudimentary version was created by Tyler Hunt and is available in a GitHub repository. The current app has partly modeled on Hunt's code, and has expanded the approach with several additional features.
Ver 1.0, June 28, 2017
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.