rowMsquares {scrime} | R Documentation |
Rowwise Linear Trend Test Based on Tables
Description
Given a set of 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 levels of the categorical variables represented by the rows of the matrices, the value of the linear trend statistic based on Pearson's correlation coefficient and described on page 87 of Agresti (2002) 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
rowMsquares(..., listTables = NULL, clScores = NULL, levScores = NULL,
add.pval = TRUE)
Arguments
... |
numeric matrices in each of which each row corresponds to a ordinal variable
and each column to one of the ordered levels of these variables. Each of these matrices
represents one of the groups of interest and comprises the numbers of observations showing
the respective levels at the different variables. These matrices can, e.g., generated by
employing |
listTables |
instead of inputting the matrices directly,
a list consisting of these matrices can be generated and then be used in |
clScores |
a numeric vector with one entry for each matrix specifying the score that should
be assigned to the corresponding group. If |
levScores |
a numeric vector with one score for each level of the variables.If not specified,
i.e.\ |
add.pval |
should p-values be added to the output? If |
Details
This is an extension of the Cochran-Armitage trend test from two to several classes. The
statistic of the Cochran-Armitage trend test can be obtained by multiplying the statistic
of this general linear trend test with n / (n - 1)
, where n
is the number
of observations.
Value
Either a vector containing the rowwise values of the linear 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.
Mantel, N.\ (1963). Chi-Square Test with one Degree of Freedom: Extensions of the Mantel-Haenszel Procedure. Journal of the American Statistical Association, 58, 690-700.
See Also
rowTrendStats
, rowCATTs
, rowChisqMultiClass
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 we consider a case-control study,
# i.e. two groups, and that the first 25 columns
# of mat 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 liner trend test are
# computed by
rowMsquares(cases, controls)
# which leads to the same results as
listTab <- list(cases, controls)
rowMsquares(listTables = listTab)
# or as
rowTrendStats(mat, cl, use.n = FALSE)
# or as
out <- rowCATTs(cases, controls)
n <- ncol(mat)
out$stats * (n - 1) / n
## End(Not run)