I'm running a chi-square test on the distribution of a variable between different age groups. The data looks like this in R:
a <- c(66,97, 48)
b <- c(145,174,58)
c <- c(129,128,58)
M <- data.frame(cbind(a,b,c))
colnames(M) <- c("18-34", "35-49","50-66")
rownames(M) <- c("Below avg" , "Average","Above avg")
view(M)
When plotted, the data from the youngest group appears similar in distribution to the middle one and different from the oldest one.
If I run an overall chi-square test, I get a non-significant difference:
X-squared = 8.6905, df = 4, p-value = 0.06932
However if I compare the age groups in pairs i get a significant difference between youngest and middle, and not between youngest and oldest.
data: M[, 1:2]
X-squared = 6.0153, df = 2, p-value = 0.04941
data: M3[, c(1, 3)]
X-squared = 5.2093, df = 2, p-value = 0.07393
I believe it has something to do with the unbalanced numbers of participants in each age group, even though the overall number of observations is rather large in each group. But I'm not sure if and how I should account for it.