Load and examine data
library(vcdExtra)
data(SexualFun)
SexualFun # show the table
## Wife
## Husband Never Fun Fairly Often Very Often Always fun
## Never Fun 7 7 2 3
## Fairly Often 2 8 3 7
## Very Often 1 5 4 9
## Always fun 2 8 9 14
Test association
assocstats(SexualFun) # association statistics
## X^2 df P(> X^2)
## Likelihood Ratio 15.486 9 0.078421
## Pearson 16.955 9 0.049422
##
## Phi-Coefficient : 0.432
## Contingency Coeff.: 0.396
## Cramer's V : 0.249
fisher.test(SexualFun) # exact test
##
## Fisher's Exact Test for Count Data
##
## data: SexualFun
## p-value = 0.09578
## alternative hypothesis: two.sided
Tests for ordered factors
CMHtest(SexualFun) # CMH tests
## Cochran-Mantel-Haenszel Statistics for Husband by Wife
##
## AltHypothesis Chisq Df Prob
## cor Nonzero correlation 10.014 1 0.0015534
## cmeans Col mean scores differ 12.568 3 0.0056702
## rmeans Row mean scores differ 12.319 3 0.0063653
## general General association 16.769 9 0.0524600