# Chi-square or ANOVA for two groups with multiple possible categories

I am working on a research project examining diagnoses in two populations, lets say A and B. Then I categorize their diagnoses: D1, D2, D3, ... (about 9 of them). (N>500 for both groups). So D1 is the number of patients with D1 as a diagnoses. (Also each of these diagnoses have subcategories, but I wont go into that).

Originally I was going to use a Chi Square analysis with the raw numbers to determine the significance of each diagnoses... but now I'm wondering if I should do an ANOVA (which I've never done in excel).. Any thoughts here?

Most of the groups should have an n>1, otherwise I will use a Fisher Exact test (using the =hypogeo.dist function in excel).

I guess my question is how will I be able to tell if there are significantly more of one diagnoses in group A rather than group B if I get one chi square value from the entire data section.

Side note, when can I assume a normal distribution for a population and use t tests?

*Resident doctor who was a math major, very rusty!

• I suppose you are using Excel because it is convenient for collecting data and comes for free with your computer. But if you are going to do statistical analyses such as chi-squared tests, t tests, and ANOVAs, maybe you should begin to learn how to use statistical software. R is also free. (Don't get overwhelmed by all the things R can do. Just focus on using R for each task at hand. Lots of online help and examples available. Nobody knows all of R; if anyone did know all of R today, it's expanding so they wouldn't know all of R tomorrow.) – BruceET May 28 at 20:22
• I just love having everything in one place , but you are absolutely correct. I took a class on R a few years ago and it just never clicked – meariMD May 29 at 11:37

Chi-squared test. I think I see what you are doing with the chi-squared test. Here are simulated data for groups A and B, with categories labeled with numbers 1 through 6. Using R statistical software, I have selected different theoretical probability apportionments to categories for the two groups.

Make category counts for A and B.

set.seed(528)
p.a = c(.1,.2,.3,.2,.1,.1)
a = sample(1:6, 500, rep=T, prob=p.a)
t.a = tabulate(a);  t.a
[1]  44 100 160  90  50  56
p.b = c(.3,.2,.2,.1,.1,.1)
b = sample(1:6, 500, rep=T, prob=p.b)
t.b = tabulate(b);  t.b
[1] 141  91 100  49  59  60


Put the counts into a table:

TBL = rbind(t.a, t.b);  TBL
[,1] [,2] [,3] [,4] [,5] [,6]
t.a   44  100  160   90   50   56
t.b  141   91  100   49   59   60
rowSums(TBL)  # row totals
t.a t.b
500 500
colSums(TBL)  # column totals
[1] 185 191 260 139 109 116


Chi-squared test for counts in table: This is a test of homogeneity of distributions among categories. For my data, distributions for groups A and B are (highly) significantly different with a P-value very near 0.

chisq.test(TBL)

Pearson's Chi-squared test

data:  TBL
X-squared = 78.104, df = 5, p-value = 2.091e-15


Possible two-way ANOVA. However, I am not sure what you plan for an ANOVA.

Do you have numerical test results for each patient?

• These test results should not have been used to decide how the 500 patients in each group are put into categories.
• I'm assuming assignment to categories is based on some combination of overt characteristics, such as age, gender, symptoms, attempted treatments.

Then you could do a two-factor ANOVA with test result data. The ANOVA table would have rows for Group (A,B), Category(1 through 6), and Error/Residual. With 500 subjects in each group, the degrees of freedom DF would be 1 for Group, 5 for Category, and 993 for Error (or Residual).

Possible two-sample t test. If you have test results from patients in the two groups, then you could use a Welch two-sample t test to see if population mean test results differ between groups A and B.

However, you should not use nominal categorical group labels as data for a two-sample t test.

• Okay yes, so just use chi square for two groups and multiple categories. Yes I have numerical test results for each patient, e.g. 50 patients have a diagnosis of papulosquamous dermatosis. The categories A and B are based on overt characteristics yes, categorical. – meariMD May 29 at 11:40
• I guess my question is how will I be able to tell if there are significantly more of one diagnoses in group A rather than group B if I get one chi square value from the entire data section – meariMD May 29 at 13:02