reps
samples from a normal distribution then compute
and plot confidence intervals for each sample along with information
about the population to demonstrate confidence intervals. Optionally
change the confidence level using a Tk slider.ci.examp(mean.sim = 100, sd = 10, n = 25, reps = 50, conf.level = 0.95, method = "z", lower.conf = (1 - conf.level)/2, upper.conf = 1 - (1 - conf.level)/2)
run.ci.examp(reps = 100, seed, method="z", n=25)
method
argument determines the type of interval: 'z' will
use the normal distribution and the known population standard
deviation, 't' will use the t distribution and the sample standard
deviations, 'both' will compute both for each sample for easy
comparison (it is best to reduce reps
to about 25 when using
'both').
The optional arguments lower.conf
and upper.conf
can be
used to plot non-symmetric or 1 sided confidence intervals.
The function run.ci.examp
also creates a Tk slider that will
allow you to interactively change the confidence level and replot the
intervals to show how the interval widths change with the confidence
level.z.test
, t.test
ci.examp()
run.ci.examp()
# 1 sided confidence intervals
ci.examp(lower.conf=0, upper.conf=0.95)
# non-symmetric intervals
ci.examp(lower.conf=0.02, upper.conf=0.97)
Run the code above in your browser using DataLab