Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Stata's functions relating to the binomial distribution


From   Joseph Coveney <jcoveney@bigplanet.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   st: Stata's functions relating to the binomial distribution
Date   Thu, 04 Nov 2004 21:43:55 +0900

I have two questions related to Stata's functions relating to the binomial
distribution:

The first question relates to the functions -Binomial()-
and -invbinomial()-:

This direction is pretty good . . .

. display Binomial(100, 50, invbinomial(100, 50, 0.5))
.5

. display Binomial(100, 50, invbinomial(100, 50, 0.999))
.99950217

But is there any way to improve accuracy in the following direction?  Or is
it that I'm not understanding these functions correctly?

. display invbinomial(100, 50, Binomial(100, 50, 0.5))
.50996594

. display invbinomial(100, 50, Binomial(100, 50, 0.999))
.85115891

I've discovered that it works best to keep the probability under 0.5.  Is
that the key, then:  work with 1 - P if P >= 0.5?

.  display invbinomial(100, 50, Binomial(100, 50, 0.0001))
.0001


The second question is about a function that I haven't found in the user's
manuals, or online sources (-help functions-, -findit binomial-, search of
StataCorp's FAQs with "binomial" as the search term):

In R / S-Plus, there is a function called called "qbinomial()" / "qbinom()".
If I understand it correctly, then it appears to return the number of
successes, k, that just(?) satisfies the equation

probability of observing at least k successes = Binomial(n, k, p),
with k the only unknown.

(I've used Stata's -Binomial()- function for the description.)

The function is displayed at http://lib.stat.cmu.edu/S/discrete.  Is there
something similar in Stata?  In -Binomial()-, k does not apparently need to
be an integer, so I suppose that the equation could be solved with -ridder-
or -bisect- . . .  If I read the R / S-Plus function correctly, it seems to
just plod through the numbers.


Well, perhaps a third question:

Has anyone considered implementing Blaker's binomial confidence interval in
Stata, or is anyone aware of its acceptance in comparison to, say, the
Blyth-Still-Casella interval, in particular for inverting it to obtain a
P-value of the test p = p0?  StatXact advocates the Blyth-Still-Casella
interval for this
(www.cytel.com/Library/Issue_seven/smallerPvalues-final.pdf), but Blaker's
article indicates that it is unsuitable for this purpose, since its
intervals aren't necessarily nested.

Reference:  H. Blaker, Confidence curves and improved exact confidence
intervals for discrete distributions. _Canad J Statist_ 28:783-98, 2000.
Google "blaker00confidence" for a preprint from CiteSeer, and see
www.stat.ufl.edu/~aa/cda/R/one_sample/R1/index.html for corrected R / S-Plus
code.

Joseph Coveney




*
*   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