I wondered about the relationship between a confidence interval for Cramer's V (I used the rcompanion package and the command cramerV(table, ci = TRUE))
and the result of the chi-squared test (I used chisq.test(data$x, data$z, correct = FALSE)
) with the same data. My initial thought was, that IF the 95% CI of Cramer's V includes zero, we do not reject the null hypothesis of there being no association. I expected the Chi-square test, to tell me the same thing as this CI. But that is not true.
Here is a reproducible example using R:
library("tidyverse")
library("rcompanion")
set.seed((3111965))
n <- 60
data <- c(1:n) %>% as_tibble() %>% rename(., RNR = value)
data$x <- sample(c(1,2,3), n, replace = TRUE)
data$x <- as.factor(data$x)
data$z <- ifelse(data$x == 1, 3, ifelse(data$x==3, 2, 1))
data$temp <- sample(c(1,2,3), n, replace = TRUE)
data$binom <- rbinom(n,1,0.80) # change 0.80 if you want x and x to be very/not different
data$z <- ifelse(data$binom == 1, data$temp, data$z)
table <- table(data$x, data$z)
cramerV(table, ci = TRUE)
chisq.test(data$x, data$z, correct= FALSE) # I wanted to avoid the correction
This gives a CI Cramer's V not including zero, and a Chi square telling me the chance of finding this Chi square while there is actually NO association in the data is bigger than 5% (not significant).
I am probably overlooking something very basic, but I do not understand.
EDIT
After playing/reading a bit more, it appears that Cramér's V can be a heavily biased estimator of its population counterpart and will tend to overestimate the strength of association. By adding bias.correct = TRUE in the estimation in R (see Wikipedia for the formula underlying the bias correction), it more often 'includes zero' (which is of course the lowest value possible), and it seems the outcome of the chi-square test and the CI's for Cramers V are aligned. So I think, I solved the issue myself. Am I correct?