# Calculating Median of Different Data Groups?

Bear with me here. I'm a newbie at this. Let's say we have this data :

+----------+------------+---------+---------+-----+
| regions  | # of orgs  | metric1 | metric2 | ... |
+----------+------------+---------+---------+-----+
| region 1 |        220 |    9800 | ...     | ... |
| region 2 |         18 |    1000 | ...     | ... |
| region 3 |        190 |    5400 | ...     | ... |
| region 4 |         33 |     900 | ...     | ... |
| ...      |            |         |         |     |
| region x |            |         |         |     |
+----------+------------+---------+---------+-----+


For example, in geographical region #1, we have 220 organization where their median number of customer (i.e. metric1) is 9800.

Now, we have 13 geographical regions that we are interested in, and we want to show metric1 (the median) for each group. Also, we want to show the median for ALL the regions.

My question is: How to calculate the median for all organizations in all regions? Two answers came to us:

1. Combine all data (# of customers) from all organizations, and we calculate the median like we did for each region. There is one problem, the size of the regions is not the same, which made us think that the result will be biased towards the large regions (region 1 & 3).
2. Calculate the median for each region, then calculate the median of the regions' median values. This will remove the bias (we think) but we are not sure if this a valid thing to do , statistically speaking.

Could you please advise us on the correct way to calculate the median without introducing bias?

## 1 Answer

"The median over all organizations" would be the first thing.

Consider a thought experiment with only two regions. One region has a single organization, and the other all the organizations except that one; let's say there's ten thousand of them.

Now here the median of region A is 60 and the median of region B is 100. If you think the correct thing to calculate is 80 (which lies at the 2.35 percentile of the complete set of organizations) -- i.e. that the thing you want should really give as much weight to one organization as it does to the other ten thousand (if the organizations in region B are counted once, then the one for the smaller region is effectively counted ten thousand times), then what you seek is something other than "the median over all organizations".

(One question you might like to consider is what quantity is the second thing you mention an estimate of?)

Note that if you wanted an overall mean (what's the mean over all organizations?) then you'd certainly want to give more weight to larger regions, precisely because they have more organizations. Why would the same consideration not apply to the median?

• " Why would the same consideration not apply to the median?" You are right. We never thought of it in this way. "what quantity is the second thing you mention an estimate of?" We have a couple of datasets for each org (# of customer, purchases, purchases per customer, ..etc) and we are interested in the median, 25th and 75th percentiles for each/all region(s). – iTurki Dec 22 '15 at 14:42
• Question: one colleague suggested that we calculate the all regions median by adding each region's median multiplied by its weight then divide by the overall weight. What do you think? – iTurki Dec 22 '15 at 14:46
• That's not how medians work in general; under some particular assumptions (which are unlikely to be true in this case) it might be a reasonable approximation, but a correct approach can be pretty quick to calculate if you need it done more quickly than just aggregating all the information. – Glen_b -Reinstate Monica Dec 23 '15 at 0:36