rowCATTs {scrime} | R Documentation |
Rowwise Cochran-Armitage Trend Test Based on Tables
Description
Given two matrices, each representing one group of subjects (e.g., cases and controls in a case-control study), that summarize the numbers of subjects showing the different (ordered) levels of the ordinal variables represented by the rows of the matrices, the value of the Cochran-Armitage Trend Test statistic is computed for each variable.
Using this function instead of rowTrendStats
is in particular recommended
when the total number of observations is very large.
Usage
rowCATTs(cases, controls, scores = NULL, add.pval = TRUE)
Arguments
cases |
a numeric matrix in which each row represents one ordinal
variable and each column one of the ordered levels that the variables exhibit. The
entries of this matrix are the numbers of observations from one group (e.g.,
the cases in a case-control study) showing a particular
level at the different variables. Such a matrix can, e.g., be generated
by |
controls |
a numeric matrix of the same dimensions as |
scores |
a numeric vector of length |
add.pval |
should p-values be added to the output? If |
Value
Either a vector containing the rowwise values of the Cochran-Armitage trend test statistic
(if add.pval = FALSE
), or a list containing these values (stats
),
and the (raw) p-values (rawp
) not adjusted for multiple comparisons (if add.pval = TRUE
).
Note
The usual contingency table for a variable can be obtained from the matrices by forming a variable-specific matrix in which each row consists of the row of one of these matrices.
Author(s)
Holger Schwender, holger.schwender@udo.edu
References
Agresti, A.\ (2002). Categorical Data Analysis. Wiley, Hoboken, NJ. 2nd Edition.
Armitage, P.\ (1955). Tests for Linear Trends in Proportions and Frequencies. Biometrics, 11, 375-386.
Cochran, W.~G.\ (1954). Some Methods for Strengthening the Common ChiSquare Tests. Biometrics, 10, 417-451.
See Also
rowTrendStats
, rowMsquares
, rowChisq2Class
Examples
## Not run:
# Generate a matrix containing data for 10 categorical
# variables with levels 1, 2, 3.
mat <- matrix(sample(3, 500, TRUE), 10)
# Now assume that the first 25 columns correspond to
# cases and the remaining 25 columns to cases. Then
# a vector containing the class labels is given by
cl <- rep(1:2, e=25)
# and the matrices summarizing the numbers of subjects
# showing the respective levels at the different variables
# are computed by
cases <- rowTables(mat[, cl==1])
controls <- rowTables(mat[,cl==2])
# The values of the rowwise Cochran-Armitage trend test
# are computed by
rowCATTs(cases, controls)
# which leads to the same results as
rowTrendStats(mat, cl)
# or as
out <- rowMsquares(cases, controls)
n <- ncol(mat)
out$stats * n / (n-1)
## End(Not run)