Assume that each contingency tables compares two variables and resumes the
counts of association or not with a condition. This can be resumed in the
following table:
| Association | No association | Total |
Variable 1 | \(X_1\) | \(Y_1\) | \(N_1\) |
Variable 2 | \(X_2\) | \(Y_2\) | \(N_2\) |
Total | \(X_1 + X_2\) | \(Y_1 + Y_2\) | \(N_1 + N_2\) |
If input="noassoc"
, counts
has four columns which respectively contain,
\(X_1\), \(Y_1\), \(X_2\) and \(Y_2\). If input="marginal"
,
counts
has four columns which respectively contain \(X_1\), \(N_1\),
\(X_2\) and \(N_2\).
If input="HG2011"
, we are in the situation of the amnesia
data set as
in Heller & Gur (2011, see References). Each contingency table is obtained
from one variable which is compared to all other variables of the study. That
is, counts for "second variable" are replaced by the sum of the counts of the
other variables:
| Association | No association | Total |
Variable \(j\) | \(X_j\) | \(Y_j\) | \(N_j\) |
Variables \(\neq j\) | \(\sum_{i \neq j} X_i\) | \(\sum_{i \neq j} Y_i\) | \(\sum_{i \neq j} N_i\) |
Total | \(\sum X_i\) | \(\sum Y_i\) | \(\sum N_i\) |
Hence counts
needs to have only two columns which respectively contain
\(X_j\) and \(Y_j\).
The code for the computation of the p-values of Fisher's exact test is
inspired by the example in the help page of p.discrete.adjust
of package
discreteMTP
, which is no longer available on CRAN.
See the Wikipedia article about Fisher's exact test, paragraph Example, for
a good depiction of what the code does for each possible value of
alternative
.