Skip to contents

Alternatives to prop.test and binom.test.

Usage

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

Arguments

x

number of 'successes'

n

number of trials

conf.level

confidence level

Value

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

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.

References

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

Author

Randall Pruim

Examples


prop.test(12,30)
#> 
#> 	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 
#> 
prop.test(12,30, correct=FALSE)
#> 
#> 	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 
#> 
wald.ci(12,30)
#> [1] 0.2246955 0.5753045
#> attr(,"conf.level")
#> [1] 0.95
wilson.ci(12,30)
#> [1] 0.2463368 0.5771926
#> attr(,"conf.level")
#> [1] 0.95
wald.ci(12+2,30+4)
#> [1] 0.2463368 0.5771926
#> attr(,"conf.level")
#> [1] 0.95