# Chi-squared test for continuous variables (averages)

I'm looking for a suitable statistical test for my situation. The best way to describe it is a "Chi-Squared test for continuous data". Please tell me otherwise.

Here is a made-up scenario: Say we spend a few days observing whales and sharks in the Atlantic and Indian oceans. Here are the counts in a contingency table:

|          |Atlantic |Indian |Total |
|----------|---------|-------|------|
| whales   | 8       | 2     | 10   |
| sharks   | 1       | 5     | 6    |
|----------|---------|-------|------|
| Total:   | 9       | 7     | 16   |


Here I use the Chi-squared test to determine if the observations of whales/sharks are independent of ocean location.

Let's consider another metric: the average weight of the animals. Here again, is the table:

|          |Atlantic |Indian |Avg.  |
|----------|---------|-------|------|
| whales   | 6.9     | 7.2   | 7.1  |
| sharks   | 2.3     | 2.9   | 2.5  |
|----------|---------|-------|------|
| Avg.:    | 4.3     | 5.4   | 4.9  |


Instead of total counts, I now have averages for the total of the populations along the side and last row. Here is my question: is the average weight of an animal independent of the ocean? Which test do I use now?

Just as a side note, the population sizes of each category might be very uneven such as a ratio of 1:999.

The question you are asking could be answered by performing what is very often called a 2-way ANOVA (also called two factor analysis of variance in Zar's Biostatistical Analysis).

Side comment: What I find very interesting in the way you ask your question is that indeed there are striking similarities between a 2-way ANOVA and a $\chi^2$ test.

In order to use the method, we need more information that what is available in the "mean" table: in order to calculate the statistic of the test, we also need to be able to compute the variability within each cell, and the total variability.

• I would be very greatful if you could show how I could apply the example to the test Commented Feb 29, 2016 at 11:02
• If I had the averages and variability pre-calculated, do you how could I perform the test using R or Python? Commented Mar 1, 2016 at 11:10
• Do you have all the values, then? Commented Mar 1, 2016 at 13:23
• Yes. But it may be easier if I can just input the mean and variability (thanks for you help) Commented Mar 1, 2016 at 13:54

On the first part at least, I think it's wrong to say you can use the Chi2 test "to determine if the NUMBER of whales/sharks are independent to ocean location". One can use the Chi2 test to determine "whether observations of a big animal is whale or shark are independent to ocean location". And for this hypothesis, you use the "count of whale/shark observations" to construct a contingency table.

• I know its a bit late but thanks - I have edited the original question Commented Jul 31, 2023 at 15:52