Let's say I have some data on students' test scores that consists of
score. For example,
category1 could be "major subject" with values like Physics, Math, etc.
category2 could be "class section" with just two values $A, B$ or four values $A,B,C,D$ - whatever. The point is that the different categories can take up different no. of values.
I want to get a sense of how much the score varies among different categories. Let's focus on a particular category - the natural route that occurred to me was to group the data points by different values of that category, take the mean score for value of that category and look at some measure of dispersion of the means. As an example, I could calculate the mean score of students in sections $A,B,C,D$ and then try to see how spread out these means are. If they're roughly similar, that means score doesn't vary much across sections. The same treatment can be repeated for other categories and the measure of dispersion in each case can be compared.
One thing is that there may be several categories and very few of them may have abnormally high or low means; however, the rest of the categories may have more or less similar means. So I guess it makes sense to use a robust measure of scale like IQR or median absolute deviation.
This would be great if the
ids were more or less evenly distributed into categories. But what if the distribution were uneven? Something like this:
The above is a histogram of the number of students for each value of
category2. So let's say there are $50$ data points corresponding to the value $x_1$ of
category2, I can take the mean score for
category2$=x_1$. But let's say we have only $3$ data points for
category2$=x_2$. The mean of only these $3$ points is obviously not on an equal footing with the mean of those $50$ points. Therefore I'm reluctant to just blindly take the mean of $x$ for each category and then take the IQR or MAD of those means.
Any suggestions on how one should go about this analysis?
How do I account for the fact that the category could take different possible numbers of values?