I am working on a very large dataset of patients who belong to one of five groups. I want to test if groups are not so much different than each other in terms of age, race, sex, smoking level, weight, and some other factors. Some factors are numerical and some are categorical. I know I can use ANOVA to compare mean differences between groups for numerical factors. However, I do not know how I can test mean differences for categorical factors. Some references say that Chi-Squared test can be used for this purpose, but it seems that chisq.test
in R
is only for testing either independency or goodness of fit.
Could someone write a sample code in R
showing how the mean differences between more than two groups can be evaluated for a categorical factor? Is any pre-evaluation required to check if a specific test is valid to be used? Thanks in advance.