Skip to main content
1 of 5
gung - Reinstate Monica
  • 147.5k
  • 89
  • 406
  • 717

These are contingency tables. In your matrix m1, you have the counts associated with a null hypothesis in which the cell probabilities are all the same. That is somewhat different from the typical case of using a chi-squared test on a contingency table. The default test would check if the variables are independent, which is to say, does being in one row (column) make you more likely to be in a particular column (row) than being in a different row (column) would? That null is considerably less restrictive than yours, so we cannot use the default chi-squared test setup, but we can use the chi-squared test with a custom setup.

In essence, you are after a chi-squared test for goodness of fit, with a particular null specified. Thus, you just need to ask your software for that and specify the null you want. Any software should be able to do that for you; I will demonstrate this with R.

chisq.test(x=as.vector(m2), p=as.vector(m1)/sum(m1))
#   Chi-squared test for given probabilities
# 
# data:  as.vector(m2)
# X-squared = 18, df = 8, p-value = 0.02123

R complains about the above test, so we can check it by simulating the p-value, instead of relying on the chi-squared distribution with 8 degrees of freedom being correct. There doesn't seem to be much problem:

set.seed(6625)
chisq.test(x=as.vector(m2), p=as.vector(m1)/sum(m1), simulate.p.value=TRUE)
#   Chi-squared test for given probabilities with
#   simulated p-value (based on 2000 replicates)
# 
# data:  as.vector(m2)
# X-squared = 18, df = NA, p-value = 0.02449
gung - Reinstate Monica
  • 147.5k
  • 89
  • 406
  • 717