# how best test for differences among two samples of abundance (count) data measured at the same sites

I want to test for differences in the abundance (counts) of two types of lizards. Both types were sampled at the same sites (n=284). The distribution of both types is overloaded with zeros and lizards of type "A " consistently reached greater frequencies at my contingency table. For several abundance classes, the frequency is lower than 5, though. I tried using a chi square test for independence and it gives non significant results, which strikes me a lot. The table below shows the number of sampling sites per abundance class (ab column) for each lizard type.

     C table
ab     A         B
0   205       226
1    33        29
2    15        18
3    13         8
4     4         2
5     5         1
6     3         0
7     2         0
9     1         0
12    2         0
23    1         0


Which would be the right test for me to use in this case? Any example/reference for R language? I have seen related questions in CV and other sites but it looks that details matter when it comes to these questions.

• What is the "ab" column? Jun 3 '15 at 11:32
• "ab" is probably abundance, that is, counts. That is a variable with ordering, an ordering which the usual Chi Squared test do not take into account. You need an analysis which take into account ordering. I would try logistic regression with ab as predictor. Mar 2 '17 at 19:37
• I'm not sure I understand the data any longer. sum(A)=sum(B)=284, what is that? What is the "abundance classes"? I though abundance whas simply a count... Is there 284 sites, of them 205 sites have zero A, 226 sites have zero B, and so on? Then maybe logistic regression is not right, maybe chisquare with simulated p values? Mar 2 '17 at 20:06

Yes, I believe the count values are too small. In these situations, it is common to combine rows to get larger counts. After combining the last 7 rows.

a <- c(205, 33, 15, 13, sum(4, 5, 3, 2, 1, 2, 1))
b <- c(226, 29, 18, 8,  sum(2, 1, 0, 0, 0, 0, 0))
m <- matrix(c(a, b), byrow=FALSE, ncol=2)
m
chisq.test(m)


The chi squared test of independence is significant which means that the count of lizards is not independent of location.

In this case, since the counts are based on physical locations, consider combining sites that are physically next to each other instead of something like combining all the smallest rows together. Also, having a minimum count of 5 in each cell is a good one but conservative. There are other rules of thumb you can consider.

• Thanks for that. The physical locations also vary in size which might affect the total number of lizard. Should that be taken into account? If afirmative, which would be the appropriate test? The same grouped by size classes? Jun 3 '15 at 16:55
• The chi-squared test looks if the proportion of counts changes from one lizard type to the other. Having different proportion of counts within a single lizard type is expected. However, if you believe there is a confounding variable, there is the (Generalized) Cochran–Mantel–Haenszel test. Jun 3 '15 at 21:10

I dont understand what the column of "ab" is? But as far as I understand, you can do chi-square test based on Fisher exact or based on Monte Carlo simulation. And there is package named "chisq.test {stats}" included Monte Carlo simulation.

• A fisher's test was my first option, but it was strongly rejected in a previous related post (stackoverflow.com/questions/30608240/…). the column ab means "abundance classes", groups samples by the number of individuals registered in a given sample unit. Jun 3 '15 at 16:52