conf.int {animation}R Documentation

Demonstration of Confidence Intervals

Description

This function gives a demonstration of the concept of confidence intervals in mathematical statistics in this way: keep on drawing samples from the Normal distribution N(0, 1), computing the intervals based on a given confidence level and plotting them as segments in a graph. In the end, we may check the coverage rate against the given confidence level.

Usage

conf.int(level = 0.95, size = 50, 
    control = ani.control(interval = 0.3), ...)

Arguments

level the confidence level (1 - alpha), e.g. 0.95
size the sample size for drawing samples from N(0, 1)
control control parameters for the animation; see ani.control
... other arguments passed to ani.control

Details

Intervals that cover the true parameter are denoted in gray color, otherwise in red color. As the process of drawing samples goes on, there will be a legend indicating the numbers of the two kinds of intervals respectively.

The argument nmax in control means the times of drawing samples.

Value

A list containing

level confidence level
size sample size
CI a matrix of confidence intervals for each sample
CR coverage rate

Author(s)

Yihui Xie

References

George Casella and Roger L. Berger. Statistical Inference. Duxbury Press, 2th edition, 2001.

Examples

conf.int()

## Not run: 
 
# save the animation in HTML pages
ani.start()
conf.int(saveANI = TRUE, interval = 0.2, width = 600, height = 500)
ani.stop() 

## End(Not run)

[Package animation version 0.2-0 Index]