aylmer.test
A Generalization of Fisher's exact test
A generalization of Fisher's exact test; much of the documentation and
R code is inspired by fisher.test()
 Keywords
 array
Usage
aylmer.test(x, alternative = "two.sided", simulate.p.value = FALSE,
n = 1e5, B = 2000, burnin = 100, use.brob = FALSE)
aylmer.function(x, func, simulate.p.value = FALSE, n = 1e5, B = 2000,
burnin=100, use.brob=FALSE, DNAME=NULL)
prob(x, give.log=TRUE, use.brob = FALSE)
Arguments
 x
 A matrix, possibly with some
NA
entries, coerced to integer (an object of classboard
)  alternative
 Indicates the alternative hypothesis. If not a
function, it must be one of “two.sided”, “greater” or
“less”. You may specify just the initial letter. Only used
in cases with one degree of freedom. If a function, then control is
passed to
aylmer.function()
, for whichaylmer.test()
is a wrapper  simulate.p.value
 Boolean, with default
FALSE
meaning to return the results of an exact (combinatorial) test, andTRUE
meaning to compute pvalues by Monte Carlo simulation  n
 Integer specifying the maximum number of boards to list if
simulate.p.value
isFALSE
; passed toallprobs()
and thenceno.of.boards()
. This argument has a finite default value to prevent infinite looping  B
 Integer specifying the number of replicates used in the Monte Carlo version of the test
 burnin
 Integer specifying the length of burn in. See details section
 use.brob
 Boolean, with default
FALSE
meaning to use IEEE arithmetic andTRUE
meaning to use Brobdingnagian arithmetic  give.log
 In function
prob()
, Boolean with defaultTRUE
meaning to return the logarithm of the answer andFALSE
meaning to return the value  func
 In function
aylmer.function()
, the test function used. The pvalue returned is the probability that a random permissible board has a test function less than that of argumentx
 DNAME
 In function
aylmer.function()
, the name of the dataset to be specified; default value ofNULL
means to use standard construction
Details
If simulate.p.value
is TRUE
, a vector of random
probabilities is used instead of the full enumeration. A total of
B+burnin
boards are generated of which the first burnin
are discarded.
Value

An object of class “
htest
”
Note
Function prob()
gives a number that is proportional to the
probability of observing a board.
The probability of observing a board $B$ with no NA
s,
conditional on its being permissible is, obvious notation,
$$ p(B)= \sum_{\begin{array}{c}\mbox{permissable}\\\ \mbox{boards}\end{array}} \frac{\left. \prod_{i=1}^{r}n_{i \cdot}!\cdot \prod_{j=1}^{c}n_{\cdot j}!\right/ N! }{ \prod_{i=1}^{r}\prod_{j=1}^{c}\left(n_{ij}\right)! }$$
The numerator is the same for any permissable board so is not calculated.
If simulate.p.value
is TRUE
, the default value for
B
of 2000 is likely to be low, especially for large tables, or
tables with large entries. Bear in mind that the Markov chain has high
sequential correlation.
If simulate.p.value
is FALSE
, enumerative techniques are
used. In this case, the default value for n
($10^5$) is also
likely to be low: a pvalue of 1 is returned because the first few
boards all have a probability much much smaller than that of the data.
References
 Ronald Aylmer Fisher 1955. Statistical methods for research workers, Oliver and Boyd
 G. H. Freeman and J. H. Halton 1951. Note on an Exact Treatment of Contingency, Goodness of Fit and Other Problems of Significance. Biometrika, 38(12):141149
 A. W. Ghent 1972. A Method for Exact Testing of 2x2, 2x3, 3x3, and Other Contingency Tables, Employing Binomial Coefficients. American Midland Naturalist, 88(1):1527
 R. K. S. Hankin 2007. Very Large Numbers in R: Introducing Package Brobdingnag, R news 3(3):1516
 M. J. Silvapulle and P. K. Sen 2005. Constrained
statistical inference. Wiley (page 326 for a special case of
the tests performed by
aylmer.function()
)
See Also
Examples
data(iqd)
aylmer.test(iqd)
## Not run: aylmer.test(iqd,simulate.p.value=TRUE)
data(frogs)
prob(frogs)
prob(frogs,use.brob=TRUE)