## Example data
dta <- data.frame(
y = gl(4, 5),
x = gl(5, 4)
)
## Asymptotic Cochran-Mantel-Haenszel Test
ct <- cmh_test(y ~ x, data = dta)
## Test statistic
statistic(ct)
## The unstandardized linear statistic...
statistic(ct, type = "linear")
## ...is identical to the contingency table
xtabs(~ x + y, data = dta)
## The centered linear statistic...
statistic(ct, type = "centered")
## ...is identical to
statistic(ct, type = "linear") - expectation(ct)
## The standardized linear statistic, illustrating departures from the null
## hypothesis of independence...
statistic(ct, type = "standardized")
## ...is identical to
(statistic(ct, type = "linear") - expectation(ct)) / sqrt(variance(ct))
Run the code above in your browser using DataLab