rowTrendStats {scrime} | R Documentation |
Rowwise Linear Trend Tests
Description
Computes for each row of a matrix the value of the statistic of a linear trend test for testing whether the ordinal variable corresponding to the row of the matrix is associated with an ordinal response.
In the two-class case, the statistic of the Cochran-Armitage trend test is computed by default.
Usage
rowTrendStats(X, y, use.n = NULL, add.pval = TRUE)
Arguments
X |
a numeric matrix in which each row represents an ordinal variable and each column corresponds to an observation. The entries of this matrix are interpreted as scores for the different (ordered) levels of the respective variables. |
y |
a numeric vector of length |
use.n |
should the squared values of Pearson's correlation coefficient be multiplied
by |
add.pval |
should p-values be added to the output? If |
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.
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
rowMsquares
, 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 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(0:1, e=25)
# The values of the Cochran-Armitage trend test can
# then be computed by
rowTrendStats(mat, cl)
# This leads to the same results as
cases <- rowTables(mat[, cl==1])
controls <- rowTables(mat[,cl==0])
rowCATTs(cases, controls)
# or as
out <- rowMsquares(cases, controls)
n <- ncol(mat)
out$stats * n / (n - 1)
## End(Not run)