FAQ/BinomialCofidence/2gpp/Rcode - CBU statistics Wiki

You can't save spelling words.

Clear message
location: FAQ / BinomialCofidence / 2gpp / Rcode

R code for running Agresti-Min CI for difference in paired proportions


citation to Agresti and Min


Agresti, A. and Min, Y. (2005). Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine 24, 729-740.

--- a portion of a Google cached U.Fla web site, probably by Agresti


R code for the adjustment of the Wald confidence interval for a difference of proportions, with matched pairs. This is the interval called Wald+2 in Agresti and Min, Statistics in Medicine, 2004, which adds 0.5 to each cell before constructing the Wald CI. The CI is truncated when it overshoots the boundary.

diffpropci <- function(b,c,n,conflev)
{
 z  <- qnorm(1-(1-conflev)/2)
 diff <- (c-b)/(n+2)
 sd <- sqrt((b+c+1)-(c-b)^2/(n+2))/(n+2)
 ll <- diff - z*sd
 ul <- diff + z*sd
 if(ll < -1) ll = -1
 if(ul > 1) ul = 1 
 c(ll, ul)
}
# Adjusted Wald interval for difference of proportions with matched pairs
# "conflev"=confidence coefficient, n=sample size, b,c = off-diag counts


end extract from Agresti's site


None: FAQ/BinomialCofidence/2gpp/Rcode (last edited 2013-03-08 10:17:27 by localhost)