View on GitHub

memo

Fisher Exact Test

Fisher Exact Test

Fisher exact model.

We consider following 2x2 contingency table:

Condition treatment group control group total
YES $k$ $K − k$ $K$
NO $n − k$ $N + k − n − K$ $N − K$
total $n$ $N − n$ $N$

In Fisher exact model, we interpret $k$ is a observed value of r.v. $X^{t}$ which follows hypergeometric distribution with parameters $N$, $K$, $n$.

The p.d.f. and c.d.f. of $X^{t}$ is given by

\[\begin{eqnarray} \mathrm{Hyper}(k; N, K, n) & = & P \left( X^{t} = k \right) \nonumber \\ F_{\mathrm{Hyper}}(k; N, K, n) & = & \sum_{i=0}^{k} P \left( X^{t} = k \right) . \nonumber \end{eqnarray}\]

Let $\alpha \in [0, 1]$ be significance level. Then p-value $p_{\alpha}$ is calculated by

\[\begin{eqnarray} k_{\alpha} & := & \inf \{ k \mid F_{\mathrm{Hyper}}(x^{t}; N, K, n) \le \alpha \} \\ p_{\alpha} & := & F_{\mathrm{Hyper}}(k_{\alpha}; N, K, n) \end{eqnarray}\]

Example

Infection status Vacctine Placebo Total
Yes = 1 7 = $x^{t}$ (47%) 12 = $x^{c}$ (80%) 19
No = 0 8 (53%) 3 (20%) 11
Totals 15 15 30

Fisher exact model

One-side test

\[\begin{eqnarray} F_{\mathrm{Hyper}}(x^{t}; N, K, n) & = & \sum_{k = 0}^{x^{t}} \mathrm{Hyper}(k; N, K, n) \nonumber \\ & \approx & 0.0640679660169915 \end{eqnarray}\]

Reference