assocstats.RdComputes the Pearson chi-Squared test, the Likelihood Ratio chi-Squared test, the phi coefficient, the contingency coefficient and Cramer's V for possibly stratified contingency tables.
assocstats(x)In case of a 2-dimensional table, a list with components:
a \(2 \times 3\) table with the chi-squared statistics.
The absolute value of the phi coefficient (only defined for \(2 \times 2\) tables).
The contingency coefficient.
Cramer's V.
In case of higher-dimensional tables, a list of the above mentioned structure, each list component representing one stratum defined by the combinations of all levels of the stratum dimensions.
Michael Friendly (2000), Visualizing Categorical Data. SAS Institute, Cary, NC.
Fleiss, J. L. (1981). Statistical methods for rates and proportions (2nd ed). New York: Wiley
data("Arthritis")
tab <- xtabs(~Improved + Treatment, data = Arthritis)
summary(assocstats(tab))
#>
#> Call: xtabs(formula = ~Improved + Treatment, data = Arthritis)
#> Number of cases in table: 84
#> Number of factors: 2
#> Test for independence of all factors:
#> Chisq = 13.055, df = 2, p-value = 0.001463
#> X^2 df P(> X^2)
#> Likelihood Ratio 13.530 2 0.0011536
#> Pearson 13.055 2 0.0014626
#>
#> Phi-Coefficient : NA
#> Contingency Coeff.: 0.367
#> Cramer's V : 0.394
#>
assocstats(UCBAdmissions)
#> $`Dept:A`
#> X^2 df P(> X^2)
#> Likelihood Ratio 19.054 1 1.2707e-05
#> Pearson 17.248 1 3.2804e-05
#>
#> Phi-Coefficient : 0.136
#> Contingency Coeff.: 0.135
#> Cramer's V : 0.136
#>
#> $`Dept:B`
#> X^2 df P(> X^2)
#> Likelihood Ratio 0.25864 1 0.61105
#> Pearson 0.25372 1 0.61447
#>
#> Phi-Coefficient : 0.021
#> Contingency Coeff.: 0.021
#> Cramer's V : 0.021
#>
#> $`Dept:C`
#> X^2 df P(> X^2)
#> Likelihood Ratio 0.75098 1 0.38616
#> Pearson 0.75354 1 0.38536
#>
#> Phi-Coefficient : 0.029
#> Contingency Coeff.: 0.029
#> Cramer's V : 0.029
#>
#> $`Dept:D`
#> X^2 df P(> X^2)
#> Likelihood Ratio 0.29787 1 0.58522
#> Pearson 0.29798 1 0.58515
#>
#> Phi-Coefficient : 0.019
#> Contingency Coeff.: 0.019
#> Cramer's V : 0.019
#>
#> $`Dept:E`
#> X^2 df P(> X^2)
#> Likelihood Ratio 0.99039 1 0.31965
#> Pearson 1.00107 1 0.31705
#>
#> Phi-Coefficient : 0.041
#> Contingency Coeff.: 0.041
#> Cramer's V : 0.041
#>
#> $`Dept:F`
#> X^2 df P(> X^2)
#> Likelihood Ratio 0.38362 1 0.53567
#> Pearson 0.38409 1 0.53542
#>
#> Phi-Coefficient : 0.023
#> Contingency Coeff.: 0.023
#> Cramer's V : 0.023
#>