Learn R Programming

DescTools (version 0.99.37)

MHChisqTest: Mantel-Haenszel Chi-Square Test

Description

The Mantel-Haenszel chi-square statistic tests the alternative hypothesis that there is a linear association between the row variable and the column variable. Both variables must lie on an ordinal scale.

Usage

MHChisqTest(x, srow = 1:nrow(x), scol = 1:ncol(x))

Arguments

x

a frequency table or a matrix.

srow

scores for the row variable, defaults to 1:nrow.

scol

scores for the colummn variable, defaults to 1:ncol.

Value

A list with class "htest" containing the following components:

statistic

the value the Mantel-Haenszel chi-squared test statistic.

parameter

the degrees of freedom of the approximate chi-squared distribution of the test statistic.

p.value

the p-value for the test.

method

a character string indicating the type of test performed.

data.name

a character string giving the name(s) of the data.

Details

The statistic is computed as \( Q_{MH} = (n-1) \cdot r^2\), where \(r^2\) is the Pearson correlation between the row variable and the column variable. The Mantel-Haenszel chi-square statistic use the scores specified by srow and scol. Under the null hypothesis of no association, \(Q_{MH}\) has an asymptotic chi-square distribution with one degree of freedom.

References

Agresti, A. (2002) Categorical Data Analysis. John Wiley & Sons, pp 86 ff.

See Also

chisq.test, for calculating correlation of a table: corr

Examples

Run this code
# NOT RUN {
## A r x c table  Agresti (2002, p. 57) Job Satisfaction
Job <- matrix(c(1,2,1,0, 3,3,6,1, 10,10,14,9, 6,7,12,11), 4, 4,
              dimnames = list(income = c("< 15k", "15-25k", "25-40k", "> 40k"),
                              satisfaction = c("VeryD", "LittleD", "ModerateS", "VeryS"))
       )

MHChisqTest(Job, srow=c(7.5,20,32.5,60))
# }

Run the code above in your browser using DataLab