Pairwise Contingency Tables
Computes a contingency table for each pair of rows of a matrix, and stores all contigency table in a matrix.
computeContCells(data, computeExp = TRUE, justDiag = FALSE, check = TRUE, n.cat = NULL)
data |
a numeric matrix consisting of integers between 1 and |
computeExp |
should the numbers of observations expected under the null hypothesis that
the respective two variables are independent also be computed? Required
when |
justDiag |
should only the diagonal elements of the contingency tables,
i.e.\ n.ii, i = 1, …, |
check |
should |
n.cat |
integer specifying the maximum number of levels a variable can take. If |
A list consisting of two matrices each consisting of m * (m - 1) / 2 rows and
n.cat
^2 columns, where m is the number of rows of data
.
One of these matrices
called mat.obs
contains in each row the values of the contingency table for
a particular pair of rows of data
, where the contigency table of the variables represented
by the ith and jth row of data
is shown in the
j + m * (i - 1) - i * (i - 1) / 2 row of mat.obs
.
The other matrix called mat.exp
consists of
the corresponding numbers of observations expected under the null hypothesis that
the respective two variables are independent.
Holger Schwender, holger.schwender@udo.edu
Schwender, H.\ (2007). A Note on the Simultaneous Computation of Thousands of Pearson's ChiSquare-Statistics. Technical Report, SFB 475, Deparment of Statistics, University of Dortmund.
## Not run: # Generate an example data set consisting of 5 rows (variables) # and 200 columns (observations) by randomly drawing integers # between 1 and 3. mat <- matrix(sample(3, 1000, TRUE), 5) # Generate the matrix containing the contingency tables for each # pair of rows of mat. out <- computeContCells(mat) # out contains both the observed numbers of observations # summarized by contingency tables out$mat.obs # and the number of observations expected under the null hypothesis # of independence. out$mat.exp # If, e.g., only the observed number of observations having the same # value is of interest, call computeContCells(mat, computeExp = FALSE, justDiag = TRUE) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.