------------------------------------------------------------------------------- help forcij,ciji-------------------------------------------------------------------------------

Binomial confidence intervals for proportions (Jeffreys prior)

cij[varlist] [weight] [ifexp] [inrange] [,level(#)total]

ciji#obs#succ[,level(#)]

by...:may be used withcij(but not withciji); see help by.

fweights are allowed withcij; see help weights.

Description

cijcomputes standard errors and binomial confidence intervals for each variable invarlist, which should be 0/1 binomial variables.cijiis the immediate form ofcij, for which specify the number of observations and the number of successes. See help immed for more on immediate commands. With both commands confidence intervals are calculated based on the Jeffreys uninformative prior of a beta distribution with parameters 0.5 and 0.5.

RemarksSuppose we observe

nevents and recordksuccesses. Here as usual "success" is conventional terminology for whatever is coded 1. For a 95% confidence interval, for example, we then take the 0.025 and 0.975 quantiles of the beta distribution with parametersk+ 0.5 andn - k+ 0.5. This Bayesian procedure has a frequentist interpretation as a continuity-corrected version of the so-called exact (Clopper-Pearson) confidence interval, produced byci,binomial, which takes (in the same example) the 0.025 quantile of beta(k,n-k+ 1) and the 0.975 quantile of beta(k+ 1,n-k). The lower limit if all values are 0 is taken to be 0 and the upper limit if all values are 1 is taken to be 1. Among other properties, note that this interval is typically less conservative than the exact interval, so that coverage probabilities are on average close to the nominal confidence level. From a Bayesian point of view, however, the whole of the posterior distribution is much more fundamental than any interval derived from it.See Brown

et al.(2001) for a much fuller discussion and an entry to the literature. Brownet al.(2002) provide supporting technical background to that paper. Among many references, Agresti (2002, pp.14-21), Agresti and Coull (1998), Newcombe (1998, 2001) and Vollset (1993) provide clear and helpful context. Williams (2001, Ch.6) provides a lively alternative treatment of confidence intervals for one-parameter models. The original work on uninformative priors was by Harold Jeffreys (1946; 1948, Ch.3.9; 1961, Ch.3.10). The actuary Wilfred Perks (1947) independently produced very similar ideas. Later discussions include Good (1965, esp. pp.18-19), Rubin and Schenker (1987), Lee (1989, esp. p.93; 1997, esp. pp.88-89), Gelmanet al.(1995, esp. pp.55-56), or Carlin and Louis (1996, esp. pp.50-54; 2000, esp. pp.42-46). For more on Jeffreys (1891-1989), see Cook (1990), Lindley (2001) or Lindleyet al.(1991).The method of calculating beta quantiles used here is based on the fact that if

Yis distributed as beta(a,b) andXis distributed asF(2a,2b), thenY=aX/ (b+aX). See (e.g.) Cramér (1946, pp.241-4) for background or Lee (1989, p.251; 1997, p.291). In Stata 8, it can be done directly withinvibeta().

Options

level(#)specifies the confidence level, in percent, for confidence intervals; see help level.

totalis for use with theby...:prefix; it requests that, in addition to output for each by-group, output be added for all groups combined.

Examples. cij foreign

. ciji 10 1 (10 binomial events, 1 observed success)

AuthorNicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

AcknowledgementsAlan Feiveson suggested the Cramér reference. John R. Gleason increased my interest in this problem.

ReferencesAgresti, A. 2002.

Categorical data analysis.Hoboken, NJ: John Wiley.Agresti, A. and Coull, B.A. 1998. Approximate is better than "exact" for interval estimation of binomial proportions.

American Statistician52: 119-126.Brown, L.D., Cai, T.T., DasGupta, A. 2001. Interval estimation for a binomial proportion.

Statistical Science16: 101-133.Brown, L.D., Cai, T.T., DasGupta, A. 2002. Confidence intervals for a binomial proportion and asymptotic expansions.

Annals of Statistics30: 160-201.Carlin, B.P. and Louis, T.A. 1996/2000.

Bayes and empirical Bayes methods fordata analysis.Boca Raton, FL: Chapman and Hall/CRC (1996: London: Chapman and Hall.)Cook, A.H. 1990. Sir Harold Jeffreys.

Biographical Memoirs of Fellows of theRoyal Society36: 303-333.Cramér, H. 1946.

Mathematical methods of statistics.Princeton, NJ: Princeton University Press.Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. 1995.

Bayesian dataanalysis.London: Chapman and Hall.Good, I.J. 1965.

The estimation of probabilities:an essay on modern Bayesianmethods. Cambridge, MA: MIT Press.Jeffreys, H. 1939/1948/1961.

Theory of probability.Oxford: Oxford University Press.Jeffreys, H. 1946. An invariant form for the prior probability in estimation problems.

Proceedings of the Royal Society A186: 453-461. Reprinted in Jeffreys, H. and Jeffreys, B.S. (eds) 1977.Collected papers of Sir HaroldJeffreys on geophysics and other sciences. Volume 6: Mathematics, probabilityand miscellaneous other sciences.London: Gordon and Breach, 403-411.Lee, P.M. 1989/1997.

Bayesian statistics: an introduction.London: Edward Arnold.Lindley, D.V. 2001. Harold Jeffreys. In Heyde, C.C. and Seneta, E. (eds)

Statisticians of the centuries.New York: Springer, 402-405.Lindley, D.V., Bolt, B.A., Huzurbazar, V.S., Jeffreys, B.S., Knopoff, L. 1991. [articles on Harold Jeffreys]

Chance4(2): 10-26.Newcombe, R.G. 1998. Two-sided confidence intervals for the single proportion: comparison of seven methods.

Statistics in Medicine17: 857-872.Newcombe, R.G. 2001. Logit confidence intervals and the inverse sinh transformation.

American Statistician55: 200-202.Perks, W. 1947. Some observations on inverse probability including a new indifference rule.

Journal, Institute of Actuaries73: 285-334.Rubin, D.M. and Schenker, N. 1987. Logit-based interval estimation for binomial data using the Jeffreys prior.

Sociological Methodology17: 131-144.Vollset, S.E. 1993. Confidence intervals for a binomial proportion.

Statisticsin Medicine12: 809-824.Williams, D. 2001.

Weighing the odds: a course in probability and statistics.Cambridge: Cambridge University Press.

Also seeManual:

[R] ciOn-line: help for ci, bitest, immed