cramersv | R Documentation |
This function calculates Cramer's V, a measure of association between two categorical variables. It is a scaled version of the chi-squared test statistic and lies between 0 and 1. Cramer's V is calculated as sqrt(chi-squared / (n * (k - 1))), where n is the number of observations and k is the smaller of the number of levels of the two variables.
cramersv(x)
x |
The result of |
Yates continuity correction is never applied. So in the 2x2 case, if x
is the result of stats::chisq.test
, make sure no continuity correction was applied. Otherwise, results can be inconsistent.
A numeric vector of length one.
Cramer, Harald. 1946. Mathematical Methods of Statistics. Princeton: Princeton University Press, page 282 (Chapter 21. The two-dimensional case).
tab <- table(mtcars[c("am", "vs")]) chi <- chisq.test(tab, correct = FALSE) cramersv(mtcars[c("am", "vs")]) cramersv(chi) cramersv(tab)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.