This is a hypothetical question about accounting for a confounding factor. I have an actual study but I'm not sure how best to explain, so I'm using a simplified example below. Apologies is this question has been asked before (I'm sure it has), but I just can't seem to formulate the question properly to find an answer that fits exactly what I'm asking.
Say I have surveyed 500 people to find out what flavour ice-cream they prefer out of chocolate, vanilla and strawberry. We ask people on the street randomly, and make sure we're getting roughly equal numbers of male and female respondents. We record their gender and ask their age.
Once we've collected the data, we analyse it and find that the ratio of male to female is not the same in all age categories: females are over-represented in the younger age categories, and under-represented in the older age categories.
So when I look at the data and find that women are more likely to choose chocolate, I can't be sure if this is a function of age (younger people are more likely to choose chocolate) or if it is actually related to gender.
My question is, how can I legitimately adjust for the gender bias in the age groups of the sample?
Intuitively, I feel I could just weight the age categories where there is a gender imbalance. So, for example, if there are two times more females than males in the 18-24 age group, then each vote for a flavour should only count for 0.5:
18-24 actual votes (note: 2:1 female to male in this age category)
f m
chocolate 120 50
18-24 adjusted votes
f m (applying a 0.5 weighting factor to account for 2:1 ratio)
chocolate 60 50
Is this valid, and if so, I assume I'm then free to go on with further statistical analysis using the weighted scores? If it isn't valid, is there another more appropriate method?