# Warning when doing Chi² Test although expected values should be above 5

I have the following data:

> activitiesforall2
ACTIVITY
NAME       chasing eating moving
Artur         19     22     49
Ingeborg       1     35     19
Irma           3     51     34
Johannes       6      7     13


And did a Chi² and got:

> chisq.test(activitiesforall2)

Pearson's Chi-squared test

data:  activitiesforall2
X-squared = 42.44, df = 6, p-value = 1.505e-07

Warning message:
In chisq.test(activitiesforall2) :
Chi-squared approximation may be incorrect


So as far as I know, expected values are calculated for independence, hence they are all the same and should be above 5.

So is there another criteria that would trigger that warning message?

I've tried to find out myself, but didn't find any. In his statistical lecture, a professor of my university said, that another criteria would be N>20. I couldn't find proof of that in the internet and nevertheless would be observed in by data.

I also read that Chi² shouldn't be done with relative data (percentages). But that also is observed.

Any help would be nice. =)

Edna

The expected cell count under independence is the column sum multiplied by the row sum and divided by the total, which for ‘Johannes’ and ‘chasing’ is

$(19+1+3+6)\times(6+7+13)/259\approx 2.91$

which is below 5. You can extract the expected counts from the result of chisq.test(), like this:

> chisq.test(activitiesforall2)\$expected
chasing eating moving
Artur      10.08   40.0   40.0
Ingeborg    6.16   24.4   24.4
Irma        9.85   39.1   39.1
Johannes    2.91   11.5   11.5

• Thank you for the fast answer. The output function of the expected values is really helpful. As 20% are allowed to be below 5, I'd decide to use that result as it is.
– Edna
Sep 19 '15 at 11:05
• @Edna To conclude that there is dependence between the rows and columns is not a problem at all; you can safely do that by just looking at the table (i.e., using the ‘interocular trauma test’). It’s obvious that the result must be highly significant. For example, you can note that the chasing/eating ratio is similar for Ingeborg and Irma, but completely different for Artur. A more formal way would be to use the simulate.p.value argument to chisq.test(), which will work even if several cells have low expected counts. Sep 19 '15 at 11:16
• Sure, but writing "there is an obvious difference between x and y" wouldn't really fit into a thesis. =) Yes, I already read about Monte Carlo and thought about using it when n is low.
– Edna
Sep 19 '15 at 11:49
• @Edna -- Your conclusion that you would be okay to use the chi-square approximation with one value below 5 should be fine. The usual cut-off of 5 is in most circumstances substantially too strict. Sep 19 '15 at 12:46
• @Glen_b Thank you Glen. But I've already started to change that in my thesis.
– Edna
Sep 19 '15 at 14:11