Tools for Statistics Instruction using R and Shiny
========================================================
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. 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. This CI calculation is: xbar +/ Z*SEM, where SEM is the sd/(sqrt N)

When the sigma is unknown and estimated by the sample variance the critical Z value is replaced by a critical t value, based on the n1 df.
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.1, Feb. 16, 2021