[R] ci.pd() (Epi) and Newcombe method
(Ted Harding)
Ted.Harding at manchester.ac.uk
Wed Feb 6 17:58:22 CET 2008
Greetings!
I suspect that there is an error in the code for the
function ci.pd() in the Epi package.
This function is for computing confidence intervals
for a difference of proportions between two independent
groups of 0/1 responses, and implements the Newcombe
("Nc") method and the Agrasti-Caffo "AC" method.
I think there is an error in the computation for the
Newcombe method.
Specifically, where the code says
# Put the data in the right form
x1 <- aa; n1 <- aa+cc; p1 <- x1/n1
x2 <- bb; n2 <- bb+dd; p2 <- x2/n2
pd <- x1/n1 - x2/n2
z <- qnorm(1-alpha/2)
zz <- qchisq(1-alpha/2,1)
I believe zz (which is used in the Newcombe method,
while z is used for Agresti-Caffo) should be
zz <- qchisq(1-alpha,1)
(though I think they could just as well have written
xx <- z^2), since z^2 seems to be what they want for the
Newcombe method, and qnorm(1-alpha/2)^2 = qchisq(1-alpha,1)
This was noticed as a result of comparing results from
ci.pd() with results from the RDCI module in STATA (run
by someone else, since I don't have access to STATA).
With the original code in ci.pd(), the Newcombe results
were different between ci.pd() and STATA. After making
the above change, they agreed.
I would be most grateful if anyone who has also been
down this path could confirm whether I am correct.
Since I don't have access to Newcombe's original
paper at the moment either, I am not able to check
the code against his own description of the method!
With thanks,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 06-Feb-08 Time: 16:58:19
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list