# Can you use the chi-squared test to test difference between two already observed groups?

I have conducted a survey regarding the age range of both customers and non-customers of a particular restaurant. The results can be seen below:

                  | 25  | 26-40  |   42-65 |   65+  | Total
Customers         | 17  |   79   |     68  |   10   |  174
Non Customers     | 21  |   41   |     65  |   17   |  144


I would like to determine if there is any difference among the two groups regarding age. And in particular which age ranges seem to be significantly different. However, im just confused as to how to come up with expected values.

Glen_b's answer on Can you use the chi-squared test when the expected values are not determined? helped me, however, I'm still confused as to how I would find out if there is a significant difference in an individual age range, as opposed to an overall difference.

If for example, the observed value was 1, and expected 2, would I simply do ((1 - 2) ^2)/2 and use a df of 1?

• What's wrong with a chi-square test of independence for the contingency table presented in your question? – Mike Hunter Apr 3 '17 at 19:05
• I don't understand the distinction you're making regarding "already observed groups". – gung - Reinstate Monica Apr 3 '17 at 19:15
• You're not sufficiently clearly explaining what you want. If you're trying to find where the bigger deviations from expected are you could look at the $(o_i-e_i)/\sqrt{e_i}$ values (whose squares are contributions to chi-square), or you can look at binomial standardized residuals (which are a bit larger); this sort of calculation would be a common thing to do after a chi-square. If you're specifically looking at age-by-age comparisons you can do two sample proportions tests (which should correspond to 2x2 chi-squared of that age out of the rest) ... but you'll be doing 4 tests just for that – Glen_b Apr 3 '17 at 22:07