wilson.ci: Confidence Intervals for Proportions

Description Usage Arguments Details Value Author(s) References Examples

Description

Alternatives to codeprop.test() and binom.test().

Usage

1
2
wilson.ci(x, n = 100, conf.level = 0.95)
wald.ci(x, n = 100, conf.level = 0.95) 

Arguments

x

number of 'successes'

n

number of trials

conf.level

confidence level

Details

wald.ci() produces Wald confidence intervals. wilson.ci() produces Wilson confidence intervals (also called “plus-4” confidence intervals) which are Wald intervals computed from data formed by adding 2 successes and 2 failures. The Wilson confidence intervals have better coverage rates for small samples.

Value

Lower and upper bounds of a two-sided confidence interval.

Author(s)

Randall Pruim

References

A. Agresti and B. A. Coull, Approximate is better then ‘exact’ for interval estimation of binomial proportions, American Statistician 52 (1998), 119–126.

Examples

1
2
3
4
5
prop.test(12,30)
prop.test(12,30, correct=FALSE)
wald.ci(12,30)
wilson.ci(12,30)
wald.ci(12+2,30+4)

Example output

Loading required package: mosaic
Loading required package: dplyr

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Loading required package: lattice
Loading required package: ggformula
Loading required package: ggplot2
Loading required package: ggstance

Attaching package: 'ggstance'

The following objects are masked from 'package:ggplot2':

    GeomErrorbarh, geom_errorbarh


New to ggformula?  Try the tutorials: 
	learnr::run_tutorial("introduction", package = "ggformula")
	learnr::run_tutorial("refining", package = "ggformula")
Loading required package: mosaicData
Loading required package: Matrix

The 'mosaic' package masks several functions from core packages in order to add 
additional features.  The original behavior of these functions should not be affected by this.

Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.

Attaching package: 'mosaic'

The following object is masked from 'package:Matrix':

    mean

The following object is masked from 'package:ggplot2':

    stat

The following objects are masked from 'package:dplyr':

    count, do, tally

The following objects are masked from 'package:stats':

    IQR, binom.test, cor, cor.test, cov, fivenum, median, prop.test,
    quantile, sd, t.test, var

The following objects are masked from 'package:base':

    max, mean, min, prod, range, sample, sum

Loading required package: mosaicCalc
Loading required package: mosaicCore

Attaching package: 'mosaicCore'

The following objects are masked from 'package:dplyr':

    count, tally


Attaching package: 'mosaicCalc'

The following object is masked from 'package:stats':

    D


Attaching package: 'fastR'

The following object is masked from 'package:graphics':

    panel.smooth


	1-sample proportions test with continuity correction

data:  12 out of 30
X-squared = 0.83333, df = 1, p-value = 0.3613
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
 0.2322334 0.5924978
sample estimates:
  p 
0.4 


	1-sample proportions test without continuity correction

data:  12 out of 30
X-squared = 1.2, df = 1, p-value = 0.2733
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
 0.2459063 0.5767964
sample estimates:
  p 
0.4 

[1] 0.2246955 0.5753045
attr(,"conf.level")
[1] 0.95
[1] 0.2463368 0.5771926
attr(,"conf.level")
[1] 0.95
[1] 0.2463368 0.5771926
attr(,"conf.level")
[1] 0.95

fastR documentation built on May 2, 2019, 5:53 p.m.