Learn R Programming

lessR (version 2.3.1)

sim.CImean: Pedagogical Simulation for the Confidence Interval of the Mean

Description

Show a sequence of confidence intervals, all calculated from repeated samples of simulated data from the same normal population, and show which intervals contain the true population mean.

Usage

sim.CImean(ns, n, mu=0, sigma=1, cl=0.95, 
         ylim.bound=NULL, show.data=FALSE, show.title=TRUE, 
         miss.only=FALSE, col.hit="gray40", col.miss="red",
         col.grid="grey90", pause=FALSE)

Arguments

ns
Number of samples, that is, repetitions of the experiment.
n
Size of each sample.
mu
Population mean.
sigma
Population standard deviation.
cl
Confidence level.
ylim.bound
Specify the maximum deviation of the mean in either direction for the extent of the vertical axis.
show.data
Plot the data for each sample as well as the confidence interval.
show.title
Place a title on the graph that contains the parameter values.
miss.only
For the text output, only display information for samples that missed the mean.
col.hit
Color of the confidence intervals that contains the mean.
col.miss
Color of the confidence intervals that miss the mean.
col.grid
Color of the grid lines.
pause
Build the graph and the text output confidence interval by confidence interval.

Details

Simulate random normal data and display the resulting confidence intervals.

Examples

Run this code
# 25 confidence intervals with a sample size each of 100
# mu=0, sigma=1, that is, sample from the standard normal
sim.CImean(25, 100)

# 25 confidence intervals with a sample size each of 100
# mu=100, sigma=15
# pause after each interval and show the data
sim.CImean(25, 100, mu=100, sigma=15, show.data=TRUE)

Run the code above in your browser using DataLab