# What test to use to compare observed and expected frequencies when expected frequencies for each subject are independent from each other?

I conducted a study where I presented subjects with a treatment that they could either respond to with a match or non-match. I will use whales as an example. Whales can breach the water in several ways, just the tail, blowhole, head etc. However, in this example each whale prefers to breach the water in different ways. For example, whale 1 breaches with his tail 75% of the time, blowhole 10% of the time etc. Whale two breaches with his head 60% of the time, tail 30 % of the time etc.

I'm interested in seeing whether the whales will respond to a simulated whale breach with the same whale breach (e.g. if I simulate a tail breach the whale does a tail breach). However, since breaches happen at different probabilities for each whale I'm under the impression that my expected value should be the proportion that they naturally do the breach that I'm showing them. So if I show whale 1 from above a tail breach I expect that there is a 75% chance it will tail breach regardless. I simulate multiple tail breaches over a certain amount of time and record the whale's breaching behaviour. I then multiply the expected proportion of tail breaches (0.75) by the number of responses (e.g. 10) and get 7.5 as my expected value. I then do this for every other whale using their specific proportions as they relate to the breach I showed them (sometimes tail, sometimes head etc.). Some whales did not breach in response however showed interest in the stimuli in other ways e.g. came close to the simulated breach. These whales have an expected value of 0 but I don't know if it's appropriate to throw these data out considering they were aware of the stimulus and had the opportunity to match the breach.

I have data that look like this:

Obs     Exp
1       1.1
0       0
0       0.08
0       0.44
0       0
0       0.63
23      2.38
0       0.17
0       0.45
3       0.4
0       0
0       0
0       0.33


Observed is the number of matching breaches during the treatment. I want to know if the whales matched the breach more often than expected by chance. After helpful comments below, it seems a chi-square test is not appropriate here. What test would be appropriate here? Fisher Exact?

• This is not how a chi-squared test is conducted: it's based on the actual counts, not the proportions.
– whuber
Oct 14, 2018 at 18:12
• This sounds like you might not be using the software correctly. You will need to provide details if you would like us to understand your question.
– whuber
Oct 15, 2018 at 14:53
• The expected frequencies don't have to be integers but they have to have the same sum (namely 27) as the observed. Further, zero expected frequencies are fatal to summing (observed $-$ expected)$^2$ / expected. That said, I don't understand your set-up at all. If there's a structure of different subjects acting repeatedly you may need some quite different analysis. Oct 15, 2018 at 17:12
• I have put this on hold pending clarification of the obvious discrepancy between the data, the description of what is being done, and the output of the software: it's not possible to guess what you are calculating when all three contradict one another. Perhaps the most constructive way forward is to respond to the suggestions made by @NickCox.
– whuber
Oct 15, 2018 at 21:08
• I am only a very occasional R user, but with obs and exp 12 x 1 vectors as above table(obs, exp) shows a 4 x 9 contingency table for rows which are the distinct values of obs and the columns which are the distinct values of exp. That translation of the problem makes no sense to me as a comparison of observed and expected frequencies, but I can't even reproduce the chi-square result which R yields as $X^2$ = 36 on 24 df. Sorry, but I don't think that you have in any sense explained why expected frequencies have a different total or why (0, 0) pairs belong in the calculation. Oct 15, 2018 at 23:34