mantel.test: Mantel-Haenszel test for two-way tables

Description Usage Arguments Details Value References Examples

Description

Performs a Mantel-Haenszel test for linear trend in two way tables

Usage

1
2
mantel.test(x, byVar, row.scores = c("equal", "midrank"),
  col.scores = c("equal", "midrank"))

Arguments

x

Either a vector of data or a two way table. If a vector is given, it should be a factor variable

byVar

If x is a vector, then byVar is a factor variable to be tabulated against x.

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.

Details

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.

Value

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

References

Alan Agresti, An Introduction to Categorical Data Analysis, 1996, pp. 34 - 39.

Examples

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")

lazyWeave documentation built on Jan. 25, 2018, 5:04 p.m.