R demos

Back to all R demos
Confidence intervals
You can try out the function I used in lectures 14 and 15 to visualise confidence intervals.
  1. Download this file: ci.R to your computer, and save it (as ci.R)
  2. Start up R in the usual way
  3. In R, using the Source R code command (on the File menu), navigate to the appropriate folder, and select the file ci.R
  4. The function visualises sampling from a normal distribution with the stated mean and variance, and the construction of confidence intervals for the population mean using the method of section 7.3
  5. Run the demonstration by typing ci()
  6. You can control the simulation and display with the mouse and pointer
    • If you click in the main part of the figure, the number of trials is increased
    • If you click in the menu:
      • You can choose to hide the data, or show it again
      • You can change the sample size, and start again
      • You can change the confidence level
  7. If you are interested in seeing how this is all done in R, and perhaps even modifying the actions, you can view the function by simply typing its name (without the () afterwards)