# Re: st: Re: Fischer's exact when the expected counts are known

 From Mike Lacy To statalist@hsphsun2.harvard.edu Subject Re: st: Re: Fischer's exact when the expected counts are known Date Tue, 10 Feb 2009 10:13:33 -0700

```
>From: Ricardo Ovaldia <ovaldia@yahoo.com>
>Subject: st: Fischer's exact when the expected counts are known
>
>Dear all,
>
>Is there a command or a way to trick -tabulate- to perform a Fisher's
>exact test when the expected counts are known.
>
>For example the observe counts are:
>30 20 15 35
>
>Under the null the expected counts are
>20 30 30 20
>
>I want to test this using a fisher exact test.
>

-------
>
>Date: Mon, 9 Feb 2009 14:55:21 -0500
>Subject: Re: st: Re: Fischer's exact when the expected counts are known
>
>Richard has multinomial data: four categories with expected counts.
>There is no such thing as a Fisher Exact Test for multinomial data;
>Fisher's test is for two-way tables, and tests the hypothesis of
>independence. Richard wants to test the fit of the observed data to
>the expected.  He needs Ben Jann's -mgof- (from SSC) or the packages
>listed at the bottom of its help page.  -mgof- uses simulation to
>approximate the exact distributions of  the Pearson Chi Square and
>likelihood-ratio goodness-of-fit tests.
>

```
I can think of another way to interpret the intent that might make this do-able. Suppose we presume that the goal is to test the observed table's evidence of association (i.e., odds ratio) against the odds ratio implied by the expected frequencies that were given, as opposed to the full multinomial approach.
```
```
I don't know that there is any stock way to do this in Stata, but one *can* calculate the noncentral probability of obtaining a table with at least as large an odds ratio as that observed, given a "true" odds ratio that is not null, and given fixed marginals per the observed table. This would involve a noncentral hypergeometric distrbution as opposed to the central hypergeometric used in the special case of Fisher's test when the null odds ratio is assumed to be 1.0. I don't have the formula for the non-null case right to hand, but IIRC it is quite similar to the regular hypergeometric probability with the assumed odds ratio as a multiplier. Perhaps someone has already implemented this. SAS offers the point probability for this as the function PROBHYPER.
```
Regards,
=-=-=-=-=-=-=-=-=-=-=-=-=
Mike Lacy
Fort Collins CO USA
(970) 491-6721 office

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```