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.
MHChisqTest(x, srow = 1:nrow(x), scol = 1:ncol(x))
a frequency table or a matrix.
scores for the row variable, defaults to 1:nrow.
scores for the colummn variable, defaults to 1:ncol.
A list with class "htest"
containing the following
components:
the value the Mantel-Haenszel chi-squared test statistic.
the degrees of freedom of the approximate chi-squared distribution of the test statistic.
the p-value for the test.
a character string indicating the type of test performed.
a character string giving the name(s) of the data.
The statistic is computed as
Agresti, A. (2002) Categorical Data Analysis. John Wiley & Sons, pp 86 ff.
chisq.test
,
for calculating correlation of a table: corr
# 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