MHChisqTest
From DescTools v0.99.19
by Andri Signorell
MantelHaenszel ChiSquare Test
The MantelHaenszel chisquare 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.
 Keywords
 htest
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.
Details
The statistic is computed as $ Q_{MH} = (n1) \cdot r^2$, where $r^2$ is the Pearson correlation between the row variable and the column variable. The MantelHaenszel chisquare statistic use the scores specified by srow and scol. Under the null hypothesis of no association, $Q_{MH}$ has an asymptotic chisquare distribution with one degree of freedom.
Value

A list with class
"htest"
containing the following
components: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
## 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", "1525k", "2540k", "> 40k"),
satisfaction = c("VeryD", "LittleD", "ModerateS", "VeryS"))
)
MHChisqTest(Job, srow=c(7.5,20,32.5,60))
Community examples
Looks like there are no examples yet.