help rdci and help rdcii                                 Version 1.2 2010-09-30



rdci -- Improved asymptotic confidence interval for the difference between two independent proportions rdcii


rdci var_case var_exposed [if] [in] [weight] [, options]

rdcii #a #b #c #d [, options]

options Description ------------------------------------------------------------------------- Main level(#) set confidence level; default is prevailing setting (see creturn) zsot allow t-over-two to vary as z²-over-two (Agresti-Caffo confidence interval) cc apply continuity correction (Wallenstein confidence interval) nobruteforce turn off brute-force bracketing for root finding (Miettinen-Nurminen confidence interval) tolerance(#) relative tolerance for root-finding convergence (Miettinen-Nurminen confidence interval) ltolerance(#) absolute tolerance for root-finding convergence (Miettinen-Nurminen confidence interval) verbose displays iteration log for root-finding (Miettinen and Nurminen confidence interval) initial(numlist) initial values for root-finding (Miettinen-Nurminen confidence interval) ------------------------------------------------------------------------- by may be used with rdci; see by. fweights are allowed with rdci; see weight.


rdci calculates confidence intervals for the difference between two independent proportions by four methods that are considered to be improvements over the conventional Wald method. rdcii is the immediate form of the command.


+------+ ----+ Main +-------------------------------------------------------------

level set confidence level; it must lie between 0.1 and 99.9%, inclusive; default is the Stata level setting.

zsot adds z²-over-two successes and failures instead of a fixed value of two each for the Agresti-Caffo method

cc applies Yates's continuity correction in Wallenstein's method; this mimics a so-called exact confidence interval

nobruteforce forgoes brute-force incrementing through parameter space to set brackets on occasions when initial brackets fail to yield roots with Ridders's method

tolerance sets the relative error tolerance for root finding for Ridders's method; default is 1e-6.

ltolerance sets the absolute error tolerance for Ridders's method; not invoked by default.

verbose displays iteration history for root finding; helpful in diagnosis of problematic cases.

initial allows manually setting brackets for root finding.


rdci calculates confidence intervals for differences between two independent proportions by four methods: Miettinen-Nurminen, Agresti-Caffo, Newcombe Method 10 (so-called score method or hybrid score method), and Wallenstein. These risk difference confidence intervals are considered to have better statistical properties (i.e., are stabler, more accurate–have better "coverage") than the conventional Wald confidence interval, especially for small- to moderate-sized samples.

As with cs (see epitab), nonzero nonmissing values in the cases variable for rdci are cases, and nonzero nonmissing values in the exposure variable indicate exposure. The sequence of #a, #b, #c and #d in rdcii is identical to that for the analogous csi (see epitab), as well.

The command calls ridder during the estimation of Miettinen-Nurminen confidence interval. ridder is a user-written command that will need to be installed for rdci to estimate Miettinen-Nurminen confidence intervals. Because the command calls ridder, any global macro S_1 that the user has defined will be overwritten.

As with any root-finding algorithm, on occasion, ridder can fail. The affected Miettinen-Nurminen confidence limit will be set to missing when this occurs. The verbose option will allow the user to see the iteration log of ridder and diagnose whether a missing confidence limit results from failure of convergence or of bracketing. Adjusting the tolerance (tolerance, ltolerance or both) if the former and manually setting the brackets initial(numlist) if the latter often allows for successful root finding in such cases. One or two numbers are allowed in initial(numlist). If one number is entered, the root-finding interval will be (-1, #] in the search for the lower confidence limit and [#, +1) for the upper confidence limit. If two numbers are entered, then the second number will form this latter lower bracket in the search for the upper confidence limit.

If root finding fails during a first attempt, rdci detects this and implements an exhuastive scan of the parameter space on the affected side of the point estimate. This may be turned off with the nobruteforce option should the the user wish to do so, for example, when setting the bracket points manually or to limit output when the user invokes the verbose option. The exhaustive scan, however, ought to reduce the need for user intervention.

Note that the tolerance settings are for the difference between the objective function's result and the target chi-square statistic for the confidence level; it is not the tolerance for the values of the confidence limits. (Run the ancillary do-file for examples illustrating the meaning of this, and for suggested settings of ltolerance to assure reasonably good tolerance for the confidence limits.)

When the expectation of successes or failures is fewer than two in either exposure group, Wallenstein's method might lead to a confidence limit that implies that an individual proportion lies outside of the parameter space for proportions. rdci tests for this and applies adjustments recommended by Wallenstein. The Wallenstein method performs relatively poorly in general when the observed successes (failures) in both exposure groups are zero, especially when the two sample sizes are the same. (Run the ancillary do-file to see examples of this behavior.)

When the so-called t-over-two parameter is fixed at two (the default, as suggested by Agresti and Caffo), the Agresti-Caffo method might not be accurate with very small sample sizes when the level is set at unusually very low levels (<10%). There will not be a problem when more conventional values for level are used (>80%). Allowing the t-over-two parameter to vary with level (which is done by invoking the zsot option) might also aid accuracy.

The subroutine for the Wallenstein method is recursive, as is the main program (calling itself indirectly via ridder), but the recursion depth is only one, and so there is scant chance of exhausting memory.


. rdcii 7 12 9 2, level(90)

. rdci case exp [freq=pop]


A. Agresti and B. Caffo, Simple and effective confidence intervals for proportions and differences of proportions result from adding two successes and two failures. The American Statistician 54:280-88, 2000.

O. Miettinen and M. Nurminen, Comparative analysis of two rates. Statistics in Medicine 4:213-26, 1985.

R. G. Newcombe, Interval estimation for the difference between independent proportions: comparison of eleven methods. Statistics in Medicine 17:873-90, 1998.

S. Wallenstein, A non-iterative accurate asymptotic confidence interval for the difference between two proportions. Statistics in Medicine 16:1329-36, 1997.


Code for calculating Wilson intervals of the individual proportions (used in calculation of Newcombe's Method 10 confidence intervals) is adapted from ciwi by Nicholas J. Cox.


Joseph Coveney

Also see

Manual: [ST] epitab