CIplot: Illustration of the meaning of confidence levels.

CIplotR Documentation

Illustration of the meaning of confidence levels.

Description

Illustration of the meaning of confidence levels. Generate sets of confidence intervals for independent randomly generated sets of normally distributed numbers. Low confidence levels give narrow intervals that are less likely to bracket the true value. Higher confidence levels increase the probability of bracketing the true value, and are also much wider and therefore less precise. The shiny app can animate how the increase in confidence level and width leads to a consequent decrease in precision.

Usage

CIplot(n.intervals = 100,
       n.per.row = 40,
       pop.mean = 0,
       pop.sd = 1,
       conf.level = 0.95,
       ...)

confintervaldata(n.intervals = 100,
                 n.per.row = 40,
                 pop.mean = 0,
                 pop.sd = 1,
                 conf.level = 0.95,
                 seed,
                 ...)

confinterval.matrix(x,
                    conf.level = attr(x, "conf.level"),
                    ...)

confintervalplot(x.ci,
                 n.intervals = nrow(x.ci),
                 pop.mean = attr(x.ci, "pop.mean"),
                 pop.sd = attr(x.ci, "pop.sd"),
                 n.per.row = attr(x.ci, "n.per.row"),
                 xlim, ylim, ...)

shiny.CIplot(height = "auto")

Arguments

n.intervals

Number of sets of observations to generate. Each set leads to one confidence interval on the plot.

n.per.row

Number of observations in each set.

pop.mean, pop.sd

Population mean and standard deviation for generated set of n.per.row independent normally distributed random numbers.

conf.level

Confidence level of each of the n.per.row confidence intervals calculated from the generated datasets.

seed

Standard argument to rnorm.

x

Output matrix from confintervaldata.

x.ci

Output data.frame from confinterval.matrix.

xlim, ylim

Standard xyplot arguments.

height

Height of graph on web page in pixels.

...

Additional arguments. For CIplot, seed will be forwarded to confintervaldata, and xlim and ylim will be forwarded to confintervalplot. Any other additional arguments will be ignored.

Details

The shiny app has sliders for the n.intervals, n.per.row, pop.mean, pop.sd, and conf.level. Changes in the conf.level slider, either manually by animation, use the same set of generated data to show how increasing the confidence level increases the width of the confidence interval and consequently decreases the precision of the interval estimator.

Value

CIplot and confintervalplot return a "trellis" plot containing a plot of Confidence Intervals.

confintervaldata returns a matrix of n.intervals rows by n.per.row columns of independent normally distributed random numbers. The matrix has a set of attributes recording the arguments to the function.

confinterval.matrix returns a data.frame of n.intervals with three columns containing the lower bound, center, and upper bound of the confidence interval for each row of its input matrix. The data.frame has a set of attributes recording the arguments to the function.

shiny.CIplot returns a shiny app object which, when printed, runs a shiny app displaying the Confidence Interval plot and several slider controls.

Author(s)

Richard M. Heiberger <rmh@temple.edu>

Examples


## A. from the console

## example 1
CIplot()

## example 2
## Not run: 
CIplot(n.intervals=100,
       n.per.row=40,
       pop.mean=0,
       pop.sd=1,
       conf.level=.95)

## End(Not run)

## example 3
## Not run: 
tmp.data <- confintervaldata()
tmp.ci <- confinterval.matrix(tmp.data)
confintervalplot(tmp.ci)

## End(Not run)

## example 4
## Not run: 
tmp.data <- confintervaldata(n.intervals=100,
                             n.per.row=40,
                             pop.mean=0,
                             pop.sd=1,
                             conf.level=.95)
tmp.ci <- confinterval.matrix(tmp.data)
confintervalplot(tmp.ci)

## End(Not run)


## B. shiny, initiated from the console

## example 5
## Not run: 
  if (interactive())
    shiny.CIplot()

## End(Not run)

## example 6
## Not run: 
  if (interactive())
    shiny.CIplot(height=800)  ## px
  ## take control of the height of the graph in the web page

## End(Not run)

HH documentation built on May 29, 2024, 6:24 a.m.

Related to CIplot in HH...