# Test for three categorical variables - ANOVA? Which?

#### snowglas

##### New Member
Hi there,

I am trying to test the significance of the difference of the difference between two groups (A and B), each defined by two categorical variables, if that makes sense.

For example, I am doing research on black and white patients admitted to a hospital for appendicitis, further stratified by age <50 and age >50. I found that there are proportionally more white patients admitted to the hospital in both age groups, compared to the actual proportion of white patients in that hospital's community.

A - Patients admitted to the hospital (individual patients):

......... | White | Black |
<50 | ..... 67 | ..... 56 |
>50 | ..... 90 | ..... 23 |

B - Ethnic breakup in hospital community:

......... | White | Black |
<50 | 5500 | 5000 |
>50 | 6000 | 5500 |

So, essentially, I would like to test the statistical significance of the difference between A and B (i.e. is the increased proportion of white patients in the hospital compared to the community a significant difference).

I did some reading and am wondering if ANOVA is the right test to use? And if so, I actually have no idea how to organise the data to test (I use the program R).

Any advice in the right direction would be much appreciated!

#### obh

##### Active Member
ANOVA test compares averages.
Please try to look for the chi-squared goodness of fit

#### snowglas

##### New Member
Thank you! I heard a variation of ANOVA could be uses for categorical variables, but couldn't figure out how.

I actually can't figure out how to draw a contingency table for Chi square/Fisher's, seeing as I have two independent variables and one dependent.

I can do separate Chi2 tests for Groups A and B, but I'm not sure that would be meaningful, when the actual difference I want to look at is the ethnic ratios as stratified by age between the two groups.

Any suggestions? It could be that I'm asking the wrong question of my data.

#### snowglas

##### New Member
Hi, perhaps I wasn't asking the right question, and had confused some of the ANOVA derivatives - I can't really edit title of the post anymore - but for the record, the Chi2 tests for Groups A and B are both p <0.0001 (from my data, not the example above)

However, this only tells me that the difference within each group (within the hospital group, and within the community) is significant. It doesn't tell me that the difference between them is significant.

Hope that makes it a bit clearer I have a feeling I'm asking the wrong question of my data, but I can't figure it out

#### obh

##### Active Member
The Chi-squared test may compare the actual result with the expected result.
If this comparison has a significant result, it means that hospital admission depends on Ethnic.