```-------------------------------------------------------------------------------
help for ciw, ciwi
-------------------------------------------------------------------------------

Binomial confidence intervals for proportions (Wilson score)

ciw  [varlist] [weight] [if exp] [in range] [, level(#) total ]

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

by ... : may be used with ciw (but not with ciwi); see help by.

fweights are allowed with ciw; see help weights.

Description

ciw computes standard errors and binomial confidence intervals for each
variable in varlist, which should be 0/1 binomial variables.  ciwi is the
immediate form of ciw, 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 as Wilson score intervals.

Remarks

Suppose we observe n events and record k successes. Here as usual "success" is
conventional terminology for whatever is coded 1.  For a 95% confidence
interval, for example, we then solve the quadratic equation in p

(k / n - p) / sqrt[p (1 - p) / n] = +/-z

where z is invnorm(0.975). See Wilson (1927). This contribution is of
historical interest as an anticipation of Neyman's subsequent formulation of
confidence intervals. It is equivalent to adding z^2 observations to a sample,
half of them successes and half failures.  (At a 95% level, z^2 / 2 = 1.921 to
3 d.p. and so is nearly 2.) 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.

See Brown et al. (2001) for a much fuller discussion and an entry to the
literature. Brown et 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.  For more on the American
mathematician, physicist and statistician Edwin Bidwell Wilson (1879-1964), see
Stigler (1997).  He should not be confused with the American biologist Edmund
Beecher Wilson (1856-1939), who worked on cytology, embryology and heredity,
nor with the American physical chemist Edgar Bright Wilson (1908-1992); the
writings of the last include statistical topics (Wilson 1952).

Note that this is close to, but not identical to, a procedure implemented by
Gleason (1999).

Options

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

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

Examples

. ciw foreign

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

References

Agresti, 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 Statistician 52: 119-126.

Brown, L.D., Cai, T.T., DasGupta, A. 2001. Interval estimation for a binomial
proportion. Statistical Science 16: 101-133.

Brown, L.D., Cai, T.T., DasGupta, A. 2002. Confidence intervals for a binomial
proportion and asymptotic expansions. Annals of Statistics 30: 160-201.

Gleason, J.R. 1999. Improved confidence intervals for binomial proportions.
Stata Technical Bulletin 52: 16-18 (STB Reprints 9: 208-211).

Newcombe, R.G. 1998. Two-sided confidence intervals for the single proportion:
comparison of seven methods.  Statistics in Medicine 17: 857-872.

Newcombe, R.G. 2001. Logit confidence intervals and the inverse sinh
transformation.  American Statistician 55: 200-202.

Stigler, S.M. 1997. Wilson, Edwin Bidwell.  In Johnson, N.L. and Kotz, S. (eds)
Leading personalities in statistical sciences: from the seventeenth century to
the present.  New York: John Wiley, 344-346.

Vollset, S.E. 1993. Confidence intervals for a binomial proportion. Statistics
in Medicine 12: 809-824.

Williams, D. 2001.  Weighing the odds: a course in probability and statistics.
Cambridge: Cambridge University Press.

Wilson, Edgar Bright. 1952.  An introduction to scientific research.  New York:
McGraw-Hill.

Wilson, Edwin Bidwell. 1927. Probable inference, the law of succession, and
statistical inference.  Journal, American Statistical Association 22: 209-212.

Acknowledgements

John R. Gleason increased my interest in this problem.  Richard
Williams found a bug in ciwi.

Also see

Manual:  [R] ci
On-line:  help for ci, bitest, immed
```