Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Confidence Interval for Proportion


From   rgutierrez@stata.com (Roberto G. Gutierrez, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Confidence Interval for Proportion
Date   Tue, 11 Mar 2008 12:31:37 -0500

Maarten buis <maartenbuis@yahoo.co.uk> gives simulation code for calculating
coverage probabilities for "exact" binomial CIs:

> set more off
> capture program drop sim
> program define sim, rclass
> 	drop _all
> 	set obs 1000
> 	gen x = uniform()<.99
> 	ci x, binomial
> 	return scalar correct = r(lb)<.99 & r(ub)>.99
> end
> simulate correct=r(correct), reps(10000): sim
> sum correct

A while ago, Nick Cox and wrote -bincoverage-, which will calculate binomial
CI coverage probabilities exactly (and here we do mean "exactly") through the
summing of binomial probabilities.

   . findit bincoverage

-bincoverage- allows you to set the sample size, true success probability,
nominal level, and the flavor of exact binomial CI to examine:
Clopper-Pearson (the default), Wilson, Agresti, or Jeffreys.

   . bincoverage, n(50) p(0.75) wilson

   For N = 50 and p = .75, the true coverage probability of the nominal
       95% wilson CI is 0.9519.

--Bobby
rgutierrez@stata.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index