This should be a very elementary question, yet I cannot figure out where I am going wrong. The matrix below contains data on the colour distributions of balls in two urns. I am looking for a formal method that can tell me whether the contents of the two come from the same population distribution.
freqs = c(25,94,85,47,13,1685) data = matrix(freqs, nrow=2) dimnames(data) = list("treatment"=c("Urn1","Urn2"), "outcome"=c("Blue","Green","Red"))
Plotting the (frequency-based) MLE's per urn, I can qualitatively observe that the colour distributions of Urn1 and Urn2 look pretty dissimilar.
toplot<- as.matrix(rbind(data[1,],data[2,] )) barplot(toplot, beside = TRUE, col = c("green", "gray"), las=2);
I have seen the $\chi^2$ independence test used to check 'association' between two sample sets like mine. When I run the test (below) I get the p_value < 2.2e-16 (below), which accepts (?) the null hypothesis that the colour distribution of sample set Urn1 is independent of the colour distribution of Urn2. I had expected to see a test result that indicates the two sample sets come from independent / different population distributions.
I think I am mixing concepts here. Am I trying to use $\chi^2$ test for something that it is not meant for ? If so, which method should I use for my simple comparison?
result <- chisq.test(data) # Pearson's Chi-squared test # #data: data #X-squared = 884.9506, df = 2, p-value < 2.2e-16