# [R] ci.pd() (Epi) and Newcombe method

From: Ted Harding <Ted.Harding_at_manchester.ac.uk>
Date: Wed, 06 Feb 2008 16:58:22 -0000 (GMT)

Greetings!

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 ------------------------------

______________________________________________
```
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 06 Feb 2008 - 17:02:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Feb 2008 - 17:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.