R/propCI-wald.R

Defines functions propCI_wald

propCI_wald <-
function(x, n, l){
  p <- x / n

  if (x == 0){
    lw <- 0
    up <- p - qnorm(l[3]) * sqrt(p * (1 - p) / n)
  } else if (x == n){
    lw <- p + qnorm(l[3]) * sqrt(p * (1 - p) / n)
    up <- 1
  } else{
    lw <- p + qnorm(l[3]) * sqrt(p * (1 - p) / n)
    up <- p - qnorm(l[3]) * sqrt(p * (1 - p) / n)
  }

  return(c(lw, up))
}

Try the prevalence package in your browser

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

prevalence documentation built on June 4, 2022, 1:05 a.m.