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

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Finzd thee wrang lelters ino eacuh wosrd

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