# categories for chi-square test of independence - what if categories are determined by TWO variables?

My categories are the combination of two variables. For example if I have two age bands and two sexes, the categories are old women, young women, old men, and young men

So on the one hand there are four categories and I'm looking at how people selected plan A or plan B across those categories. So I can mechanically perform the chi-sq test. But is it valid in a theoretical sense? Is there any theoretical reason why I shouldn't use the test because of how the categories are actually formed by smooshing two variables together (technical term). Is there some other test I should use instead?

Great! I'm also doing logistic regression with a number of additional IVs. Am I correct in expecting broad agreement betw chi-square test results and logistic regression results?

• What is important is what you want to find out; if chi-squared on your 2x4 table addresses what you wanted to know, it should be fine. You could alternatively construct a 2x2x2 array ('table') and answer a variety of possible questions using chi squared, or do approximately the same thing (answer the same questions) via binomial (e.g. logistic) regression. Commented Oct 4, 2021 at 21:33
• I've taken what you suggested in editing my answer and placed it instead into your question. That will be easier for later visitors to the site to follow. I suspect that you wanted to leave a comment but don't (yet) have enough reputation to do that. I've also expanded my answer to address that issue.
– EdM
Commented Oct 6, 2021 at 18:26

The chi-square test can be used for any contingency table where you are comparing observed counts against the counts expected among categories under a null hypothesis. So you could construct a 2 (planChoice) x 4 (age/sex combinations) contingency table and do a chi-square test on that table.
Another, more generally applicable approach would be to do a logistic regression with the binary planChoice as the outcome variable. Then you could get around your arbitrary old/young age cutoff and model age as a continuous predictor, including sex as a categorical predictor and an interaction of age with sex to see if the association of planChoice with age differs depending on sex.