6
$\begingroup$

There are 1400 red snails, 800 blue snails, and 500 green snails. There are three parks: Park A, Park B and Park C

I find that - 800 red snails live in Park A , 200 red snails live in Park B and 400 red snails in Park C. - 100 blue snails live in Park A , 600 blue snails live in Park B and 100 blue snails in Park C. - 400 green snails live in Park A , 50 green snails live in Park B and 50 green snails in Park C.

How would I show that the proportion of coloured snails that go to different Parks is statistically significantly different. I can work out the proportion of snails that go to each park but I want to be able to say with statistical confidence that their proportions are different. How would I do that with this example above?

$\endgroup$
3
  • $\begingroup$ This is what you are looking for: stackoverflow.com/questions/16838362/… $\endgroup$ – Syd Amerikaner Apr 23 '16 at 17:03
  • $\begingroup$ @SydAmerikaner Hi I don't understand what they have done in the post but I can see they have used proportions. I have the exact frequencies which I can convert into proportions but I just want to show that the data sets are statistically significantly different. $\endgroup$ – piccolo Apr 23 '16 at 17:08
  • $\begingroup$ Just curious. The snail color... Does it correspond to different species? $\endgroup$ – Antoni Parellada Apr 23 '16 at 17:29
6
$\begingroup$

This can be approached like a chi square test of homogeneity. You want to see if there are differences from a theoretical uniform distribution across parks in the counts of snails coming from different populations or groups (colors). The margins of the tabulated data are considered random variables, and used to cross multiply and get the expected counts in each cell.

Here is your tabulated data with actual and expected counts:

> addmargins(round(snails, 0))
       park
snails     A   B   C  Sum
  red    800 200 400 1400
  blue   100 600 100  800
  green  400  50  50  500
  Sum   1300 850 550 2700
> addmargins(round(chisq.test(snails)$expected,0))
       park
snails     A   B   C  Sum
  red    674 441 285 1400
  blue   385 252 163  800
  green  241 157 102  500
  Sum   1300 850 550 2700

The chi square test can be run in R as follows:

chisq.test(snails)

    Pearson's Chi-squared test

data:  snails
X-squared = 1123, df = 4, p-value < 2.2e-16

So there is evidence that the distribution of the different snail types across parks is not homogeneous.

Here is some plotting of the results and standardized residuals:

enter image description here

Perhaps the most interesting part of your question is to discuss what to do with the results of an omnibus test on a larger than $2 \times 2$ contingency table. On this the jury is still out (amazingly) - on this you can check this very helpful reference. But the residuals, or standardized residuals are a start, and you can find them graphically plotted, and color coded. A lot of conclusions can be drawn from looking at the residuals mosaic plot, and after all, it seems like at least some authors are still condoning some post-chi "eye-balling."

On the article I link there are procedures for a more detailed post-hoc analysis of the data. A different approach altogether could be a generalized linear regression model.

Here is the interpretation, and the code:

snails <- matrix(c(800, 200, 400, 
                   100, 600, 100,
                   400, 50, 50), nrow = 3, byrow = T)
dimnames(snails) = list(snails = c("red", "blue", "green"),
                       park = c("A", "B", "C"))
snails

addmargins(round(snails, 0))
addmargins(round(chisq.test(snails)$expected,0))
chisq.test(snails)
library(vcd)
mosaic(snails, shade=TRUE, legend=TRUE)
$\endgroup$
4
  • $\begingroup$ HI Antoni, thank you for the very descriptive answer with plots - very much appreciated. I wanted to ask whether the p value of 2.22e-16 corresponds to the difference between all three snails or between any two snail groups? $\endgroup$ – piccolo Apr 23 '16 at 17:31
  • $\begingroup$ Yes, that is the issue. The chi square test is an omnibus type of test, that begs now for additional analysis. I will post a reference that I find very enlightening, and some additional comments. $\endgroup$ – Antoni Parellada Apr 23 '16 at 17:33
  • $\begingroup$ Thanks Antoni. Also what's the interpretation of the Pearson residuals? What additional information do these Pearson residuals have over the Chi-squared test p values? $\endgroup$ – piccolo Apr 23 '16 at 17:38
  • $\begingroup$ I have linked a prior post where I tried to go through the interpretation. Please take a look, and see if it helps... here it is. $\endgroup$ – Antoni Parellada Apr 23 '16 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.