R/binom.wilson.R

"binom.wilson" <-
  function(x, n, conf.level = 0.95) {
    Z <- qnorm(0.5*(1 + conf.level))
    Zinsert <- Z*sqrt(((x*(n-x))/n^3) + Z^2/(4*n^2))
    R.lower <- (n/(n+Z^2))*(x/n + Z^2/(2*n) - Zinsert)
    R.upper <- (n/(n+Z^2))*(x/n + Z^2/(2*n) + Zinsert)
    data.frame(x = x,
               n = n,
               proportion = x/n, 
               lower = R.lower,
               upper = R.upper,
               conf.level = conf.level
               )
}

Try the epitools package in your browser

Any scripts or data that you put into this service are public.

epitools documentation built on March 26, 2020, 9:14 p.m.