computeContCells {scrime} | R Documentation |
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 n.cat .
It is assumed that each row of these matrix represents
a variable. Missing values and different numbers of categories a variable can take are
allowed. |
computeExp |
should the numbers of observations expected under the null hypothesis that
the respective two variables are independent also be computed? Required
when computeContCells is used to compute Pearson's ChiSquare-statistic. |
justDiag |
should only the diagonal elements of the contingency tables,
i.e. n.ii, i = 1, ..., n.cat , be computed? |
check |
should data be checked more thoroughly? It is highly recommended to use
check = TRUE . |
n.cat |
integer specifying the maximum number of levels a variable can take. If NULL ,
this number will be computed. It is highly recommended not to change the default. |
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.
computeContClass
, rowChisqStats
## 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)