R/add4ci.R

Defines functions add4ci

Documented in add4ci

add4ci <-
function(x,n,conf.level){
   ptilde = (x+2)/(n+4)
   z = abs(qnorm((1-conf.level)/2))
   stderr = sqrt(ptilde * (1-ptilde)/(n+4))
   ul = ptilde + z * stderr
   ll = ptilde - z * stderr
   if(ll < 0) ll = 0
   if(ul > 1) ul = 1
   cint <- c(ll, ul)
   attr(cint, "conf.level") <- conf.level
   rval <- list(conf.int = cint, estimate = ptilde)
   class(rval) <- "htest"
   return(rval)

}

Try the PropCIs package in your browser

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

PropCIs documentation built on Feb. 23, 2018, 5:02 p.m.