Learn R Programming

lessR (version 2.6)

simCImean: 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

simCImean(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,
         main=NULL, pdf.file=NULL, pdf.width=5, pdf.height=5)

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.
main
Title of graph.
pdf.file
Name of the pdf file to which graphics are redirected.
pdf.width
Width of the pdf file in inches.
pdf.height
Height of the pdf file in inches.

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
simCImean(25, 100)

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

Run the code above in your browser using DataLab