Stata Technical Bulletin
33
(Î)
where za is the 100(1 — α∕2)th percentile of the standard Normal distribution.
To construct such a confidence interval, we proceed as follows. Given a value of D, define
Bl(D) = inf {θ : D*(θ') < D} , Br(D) = sup {θ : D*(θ) ≥ D} ,
i Bl(D) , if Br(D) = oo
Bc(D) = < Br(D), if Bl(D) = -oo
[ [Bl(D) + Br(D) ] /2, otherwise
(By convention, the supremum (or infimum) of a set unbounded to the right (or left) are defined as oo and — oo, respectively.)
Clearly, Bl(D) ≤ Bc(D) ≤ Br (D), and the values of Bl(D) and Br(D) (if finite) can be either the same t⅛ or two
successive ones. The confidence interval for the gth percentile difference is centered on the sample gth percentile difference
ξg=Bc(l-2ρ)
(ɛ)
cendif then calls somersd, with the Xij as the predictor variable, and the Y⅛)(ξg), for the values of q implied by the centile
option, as the predicted variables. The standard errors generated by somersd are used as estimates SE[ζ(ξq)] of the standard
error of ζ(θ) where θ satisfies (1). The lower and upper confidence limits for the gth percentile difference are, respectively,
ξ^in) = Bl(c1{ ¢(1 - 2q) - za SE[C(ξg)] }), ?“ax) = ‰(r1{ ¢(1 - 2q) + za SE[M)] }) (ə)
If tdist is specified, then cendif uses the d distribution with N — 1 degrees of freedom (or JVclust — 1 degrees of freedom
if there are 7Vclust clusters) instead of the normal distribution, so ta replaces za in (6) and (9). Note that the upper and lower
confidence limits may occasionally be infinite, in the case of extreme percentiles and/or very small sample numbers. (cendif
codes these infinite limits as plus or minus the “magic number” 1E+300, or ±1O300.) Figure 1 shows the median difference in
trunk capacity, and its confidence limits, as reference lines on the horizontal axis. The estimated median difference is 3 cubic
feet, with 95% confidence limits from 1 to 5 cubic feet. The reference lines on the vertical axis are the optimum, minimum,
and maximum values of D*(ff) required for θ to be in the confidence interval. These values of D*(ff) are saved by cendif
in the matrix r (Dsmat). If the option saving is specified, then cendif also saves an output dataset with M observations
corresponding to the ordered differences t⅛. The variables are diff (containing the t⅛), weight (containing the W⅛), Dstar
(containing the D*(t⅛)), and Dstar_r, which contains the right-hand limiting value of D*(θ),
D^(th)= IimD* (θ') (10)
θ→th+
which is the value of D*(ff) in the open interval (t⅛,t⅛+ι) for h < Λf. Conover (1980) presents a method which, for large
samples, is essentially equivalent to (6), in the special case where q = 0.5 and ^D) = D. (This is the method for calculating
confidence intervals for median differences popularized by Campbell and Gardner (1988) and Gardner and Altman (1989), and
available in Stata using Patrick Royston’s cid routine, currently on the Ideas list (Royston 1998).) However, Conover’s method
uses the assumption that the two population distributions are different only in location. This assumption (essentially) enables the
calculation of SE^(0)] for large samples and the exact distribution of D*(θ) for small samples. It also implies that the median
difference is the difference between medians. In the present case, we are not making this assumption, as the confidence interval
is intended to be robust to the possibility that the two populations are different in ways other than location. (For instance, the
two populations might be unequally variable.) The median difference is therefore not necessarily the difference between medians.
Also, we have to estimate SE [¢(0)], and this estimate is itself subject to some amount of sampling error. The method of cendif
compares to Conover’s method as the unequal-variance t-test compares to the equal-variance t-test. Conover’s method, like the
equal-variance t-test, assumes that you can use data from the larger of two samples to estimate the population variability of the
smaller sample.
I have been carrying out some simulations of sampling from two normal populations, with a view to finding the coverage
probabilities and geometric mean lengths of the confidence intervals for the median difference generated by cid and by cendif
with the tdist option. So far, I find that, even with small sample sizes, the cendif method consistently gives coverage
probabilities closer to the nominal value than the Conover method when variances are unequal, in which case cid produces
confidence intervals either too wide or too narrow, depending on whether the larger or smaller sample has the greater population
variance. Usually, the difference in coverage probability is small (1% or 2%), so the Conover method performs fairly well, in
spite of false assumptions. However, if a sample of 20 is compared to a sample of 10, and the population standard deviation
of the smaller sample is three times that of the larger sample, then the nominal 95% confidence interval has a true coverage