This page is currently a draft. Edit it. |
Note about $\chi^2$ Test of Independence:
The Cramer's coefficient $v$
Consider the same example as for $\chi^2$ Test
|
|
$V = \sqrt{ 3 / 150 } = \sqrt{ 30 / 1500 } \approx 0.14 $
TODO: Expand it
cv.test = function(x,y) { CV = sqrt(chisq.test(x, y, correct=FALSE)$statistic / (length(x) * (min(length(unique(x)),length(unique(y))) - 1))) print.noquote("Cramér V / Phi:") return(as.numeric(CV)) }
So we can get Cramer's V as
helpdata = read.csv("http://www.math.smith.edu/r/data/help.csv") with(helpdata, cv.test(female, homeless)
or
cv.test <- function(x) { CV <- sqrt(chisq.test(x, correct=FALSE)$statistic / (sum(x) * min(dim(x) - 1 ))) ### The result of the Pearson chi-square (without the Yates correction) is divided by the sum of table cells and... ### ...multiplied by the smalles number of (row or column) cells minus 1. ### The $statistic sends the correct value (the X^2 only) into the sqrt function print.noquote("Cramér V / Phi:") return(as.numeric(CV)) }