Field note · December 13, 2024
The overall average hides 5 different numbers
Real group means for one column across 5 segments, and what the pooled average conceals.
region splits world-indicators into 5 groups. Here is what gdp_per_capita_usd looks like inside each.
Africa— mean 39,533, median 30,001 (144 rows)Oceania— mean 29,696, median 24,412 (72 rows)Asia— mean 25,629, median 13,266 (168 rows)Europe— mean 23,427, median 19,464 (192 rows)Americas— mean 19,277, median 7,277 (144 rows)
Top to bottom that is 39,533 against 19,277, a spread of 105.1%. The pooled average is 26,959.
select region,
count(*) as rows,
round(avg(gdp_per_capita_usd)::numeric, 2) as mean,
percentile_cont(0.5) within group (order by gdp_per_capita_usd) as median
from world_indicators
group by 1
order by mean desc;A spread that wide means the pooled number is not a summary, it is an artefact of the mix. Change the proportion of Africa rows and the overall average moves without any individual group changing at all — which is how a metric goes up while every segment goes down.
Notice the mean and median columns disagree most in Africa, where the mean sits well above the median. Always compute both in the group-by. The comparison between them per segment is free and tells you whether you are looking at a level difference or a tail difference.
This is the setup for Simpson's paradox — the case where every segment moves one way and the total moves the other.