R/propCI-agresticoull.R

Defines functions propCI_agresticoull

propCI_agresticoull <-
function(x, n, l){

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

  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.