# How to compare frequency distributions

I have one categorical variable that can assume 5 possible values: 1, 2, 3, 4, 5. I observe the value of the variable in two samples of different size. Now I want to compare the frequency distribution of my variable in the two sample.

Is there any statistic that measures the concentration of the distribution (something like the Gini coefficient, but not cumulative), so to take the value of 1 if all observations of the sample are in one category and 0 if they are equally distributed across the 5 categories. Looking at the statistic, I could then say that one sample is more heterogeneous than the other.

• Are the categories ordered or nominal? For example if half the observations are in 1 and half in 5 is that more heterogeneous than half the observations in 3 and half in 4, or exactly as heterogeneous? – Glen_b Jun 13 '14 at 4:54
• @Glen_b Ordered – Francesco Jun 13 '14 at 5:04
• That changes things. How do you want the measure of concentration to change as the values get further apart? Is 50-50 in the categories 1 and 5 more heterogeneous than 20% in each of the 5 categories (perhaps taking negative values if your specified scaling is unchanged)? – Glen_b Jun 13 '14 at 5:12
• @Glen_b My categories are "political categories": far-right, right, centre, left, far-left. 50-50 in categories 1 and 5 is more heterogeneous than 50-50 in categories 1 and 2, but is equally heterogeneous as a distribution with 20 in each category. – Francesco Jun 13 '14 at 5:18
• Wait - 50% in 1 and 50% in 5 is identically diverse to having 20% in each of the categories 1 to 5? Wow. There are so many edge cases to deal with now I am not sure I even understand the question any more. For example, what if 35% are at each end and 10% in each of the intermediate categories? What if it's 40% at one end, 30% at the other, and 10% for the in-between categories? You need to think carefully about how this thing is supposed to behave and give a clear explanation. – Glen_b Jun 13 '14 at 5:22

## 3 Answers

Here's one such suggestion:

Assuming nominal categories labelled $$1, 2, ..., k$$

Consider the sum of the squares of the proportions in each category,

$$\sum_{i=1}^k p_i^2$$

If all values are in 1 category it takes the value 1 and if they're uniformly spread across categories it takes the value $$k/k^2 = 1/k$$.

So subtract $$\frac{1}{k}$$ and divide by $$1-\frac{1}{k}$$ to give it the right range.

That leaves us with the concentration coefficient $$\frac{(\sum_{i=1}^k p_i^2)-\frac{1}{k}}{1-\frac{1}{k}}=\frac{(k\sum_{i=1}^k p_i^2)-1}{k-1}$$

Note that this is a linear rescaling of the Simpson diversity index to make it a concentration (i.e. flipped around) and with the desired endpoints.

Edit: Note added later - the Simpson index is also called the Herfindahl index (one of many cases where the same thing is called different names in different areas), and the above concentration measure is the normalized Herfindahl index $$H^*$$.

There are other such indexes which you might prefer to similarly modify.

As another possibility from economics, there's also the Gini coefficient.

For ordered categories (where further apart is more heterogeneous), you might want to consider subtracting the second of the two polarization indexes discussed here from 1.

Alternatively, if you need uniformity to be zero, and 50-50-polarizaton to be negative, a simple rescaling can achieve that.

For the ordered case, further clarification is needed.

Cliff's Delta may be the way to go. It is a non-parametric effect size statistic which ranges from -1 to 1. 1 or -1 mean the distributions are completely divergent and a zero means the distributions are exactly the same. Delta's of 0.147, 0.33, and 0.474 correspond to Cohen's d's of 0.2, 0.5, and 0.8.. See this for a comparison of the two effect sizes: http://tien-nguyen.github.io/effect-size-and-its-interpretation/

You can then convert to Common Language (CL) effect size to provide more clarity for your audience (and one's self maybe?)

or NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) Copyright (C) 1988-1992 by Cambridge University Press. page 620 and further

greetings

• Can you provide a summary of the contents of the link? If the link goes dead your answer will be less helpful. – mdewey Jan 17 '17 at 13:28