Description Usage Arguments Details Value References Examples
Performs a Mantel-Haenszel test for linear trend in two way tables
1 2 | mantel.test(x, byVar, row.scores = c("equal", "midrank"),
col.scores = c("equal", "midrank"))
|
x |
Either a vector of data or a two way table. If a vector is given, it should be a factor variable |
byVar |
If |
row.scores |
choice of scores for the row variable. May be "equal", "midrank", or user defined. |
col.scores |
Choice of scores for the column variable. May be "equal", "midrank", or user defined. |
Currently, there is no check to ensure that either variables submitted are factors.
Data should be ordinal. Nominal data may not have any practical meaning in this test. Sometimes, when a nominal variable has only two levels, this test may still be appropriate, i.e. Yes vs. No.
In 2xJ tables, when arbitrary scores (i.e., 0, 1) are applied to the rows and midranks applied to the columns, this test is equivalent to the Wilcoxon, or Mann-Whitney test.
In Ix2 tables, when monotone scores are applied to the rows and abitrary scores applied to the columns, this test is equivalent to the Cochran-Armitage test. See the reference for further details.
Returns an object of type htest.
statistic |
M^2, a Chi-square statistic with 1 degree of freedom. |
parameter |
degrees of freedom for M^2 |
p.value |
p-value for the test |
method |
Type of test performed. |
correlation |
correlation coefficient of linear trend |
Alan Agresti, An Introduction to Categorical Data Analysis, 1996, pp. 34 - 39.
1 2 3 4 5 6 7 | mantel.test(mtcars$gear,mtcars$cyl)
mantel.test(table(mtcars$gear,mtcars$cyl))
mantel.test(table(mtcars$gear,mtcars$cyl), row.scores="midrank")
mantel.test(table(mtcars$gear,mtcars$cyl), col.scores="midrank")
|
Mantel Haenszel Chi-Square Test for Two Way Tables
data:
M^2 = 7.5249, df = 1, p-value = 0.006085
Mantel Haenszel Chi-Square Test for Two Way Tables
data:
M^2 = 7.5249, df = 1, p-value = 0.006085
Mantel Haenszel Chi-Square Test for Two Way Tables
data:
M^2 = 9.739, df = 1, p-value = 0.001804
Mantel Haenszel Chi-Square Test for Two Way Tables
data:
M^2 = 7.6211, df = 1, p-value = 0.005769
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.