# Can you average categorical variables and then perform a two sample t-test?

I have a situation where I have two sets of apples. I want to show that one batch has more problems than the other. How could I go about doing it?

The problems are things like: "Mold", "Worms", "Rotten"

So far I looked at each apple and gave it a score where each instance of a problem counted as "1". So if an apple had mold and worms it had a value of 2 (for two problems).

I then added the problems of the apples in each group and took an average, standard deviation, and performed a two sample student's t-test. Would this be the accurate way of assessing whether one group of apples had more problems than another group or is there a more accurate method?

If you count the number of problems you have a discrete quantitative variable, and you can perform quantitative analysis on it - for example, t-test.

Whether it makes sense depends on whether that quantitative measure is a good description of your observations for your purpose. Please notice that by counting problems you lose some information on the nature of the problem. Furthermore, by averaging your lose information on the distribution of the problem.

Let's make some questions:

1. Is a population with 50% of rotten apples equivalent to a population with 50% of moldy apples? If it weren't, counting problems wouldn't be useful.
2. Is a population with 25% of moldy rotten wormsy apples and 75% healthy apples equivalent to a population of 25% moldy apples, 25% rotten apples, 25% wormsy apples and 25% healty apples? If it weren't, averaging wouldn't make sense (and please notice that those populations aren't equivalent to anybody wanting to get as many healthy apples as possible).

I would outline a couple of alternatives that might be useful depending on your purpose:

• Thank you for this response! I used your advice with fisher's exact test I was able to reject null and determine that the proportion of healthy apples were not the same between the two groups. Commented Jun 7, 2017 at 20:46
• How could I further expand upon this to determine if the 'sick' apples in each group had on average the same amount of problems per apple? The type of problem (e.g. worms, mold, etc) would not be an ordinal value. Now that I know the proportions of sick apples are not the same, I simply want to test to see if each group's sick apples had about the same amount of problems per apple. For example, How could I make sure that the group with the smaller proportion of sick apples didn't have say 2x as many problems per sick apple as the group with the larger proportion of sick apples? Commented Jun 8, 2017 at 2:10
• That might be another question. However, if you are interested in the amount of problems per sick apple, now your variable is quantitative (number of problems) and you can perform a t-test - provided that your samples are reasonably large.
– Pere
Commented Jun 8, 2017 at 8:23
• It's a borderline case. 30 (or 50) are textbook thresholds for t-test provided that the distribution is not too skewed - that means that it would work unless nearly all apples have the same number of problems.
– Pere
Commented Jun 8, 2017 at 17:26
• All that should deserve another question, but I your data seems well behaved enough for t-test to work.
– Pere
Commented Jun 8, 2017 at 18:24