allboards: Various board functionality

Description Usage Arguments Details Author(s) See Also Examples

Description

A board is a matrix with non-negative integer elements; an object of class board. It represents a contingency table; NA entries specify structural zeros. Function allboards() takes a matrix x, coerces it to a board, then enumerates all boards with identical marginal totals, and zeros at the same locations as the structural zeros of x.

Usage

1
2
3
4
5
no.of.boards(x, n = 1e5)
allboards(x, n = 1e5, func=NULL)
allprobs(x, n = 1e5, normalize=TRUE, give.log=FALSE, use.C=TRUE)
is.1dof(x)
maxlike(x)

Arguments

x

Matrix, coerced to integer. Usually with one or more NA entries

n

Integer specifying how many boards to return. See details section

use.C

In function allprobs(), Boolean with default TRUE meaning to use the C routine, and FALSE meaning to use an R routine

func

In function allboards(), argument to specify the function returned; default NULL means to return the whole board

normalize

In function allprobs(), Boolean with default TRUE meaning to normalize the returned values so they sum to one (and thus correspond to probabilities conditional on the marginal totals and structural zeros)

give.log

Boolean specifying whether to return the log of the probabilities

Details

Function no.of.boards(x) returns the number of boards with non-negative entries that have the same marginal totals as x and structural zeros where x has NA entries (that is, permissible boards). Function allboards() enumerates such boards.

Function prob(x) returns a number proportional to the probability of observing x, given the structural zeros and marginal total.

Function is.1dof(x) returns TRUE if and only if x is of the same form as gear, and thus has only one degree of freedom. Note that there exist other configurations which have only one degree of freedom (such as any permutation of the rows and columns of gear).

Function maxlike(x) returns the entry of allboards() that has the highest probability of occurring. Compare best().

In functions no.of.boards() and allboards(), argument n is the maximum number of boards (or maximum count) returned, except for special value 0, which means to return (or count) all possible boards.

(Actually, if there are more than n permissible boards, the first n+1 boards are returned by allboards(), and n+1 is returned by no.of.boards(). This is because the C code checks for the last board having a successor).

Warning Many frequently-encountered boards have a very large number of possible configurations, and if called with n=0, these functions will iterate for a very long time before stopping.

Author(s)

Robin K. S. Hankin (R); Luke G. West (C++)

See Also

marginals,aylmer.test,best

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(chess)
allboards(chess)
maxlike(chess)

data(frogs)

x <- matrix(c(28,2,9,7,3,1,14,34,9,8,6,2),ncol=2)
## Not run: no.of.boards(x) # Should be 339314 according to Gail and Mantel


data(iqd)
f <- function(x){x[1,1]}
table(allboards(iqd,1000,f))

aylmer documentation built on May 29, 2017, 1:12 p.m.