Modeling the median and the tails
Today let's understand quantile regression, using a courier company's own delivery log.
A courier company logged 120 deliveries. For each one it recorded the distance, in kilometers, and how long the delivery actually took, in minutes. Distances range from 1.4 km to 24.5 km, and delivery times range from 3 minutes to 95 minutes.
Here is every one of those 120 deliveries, plotted as distance against delivery time.
Notice how tight the points sit together on the left, and how far they spread out on the right.
A single mean line, and one sigma, meet a growing spread
Let's fit the most familiar regression line through these same 120 deliveries, and see how well a single line and a single spread actually describe them.
lm() fits one straight line through all 120 deliveries: start around 7.52 minutes, and add about 2.26 minutes for every extra kilometer. The residual standard error, 14.17 minutes, is the one number this model uses to describe how far an actual delivery time strays from that line, and it uses the same 14.17 at every distance alike.
But does a short delivery really scatter around its prediction by the same 14.17 minutes as a long one? Split the residuals at the midpoint distance and compare the two halves directly.
The shorter half of deliveries scatters by only about 7.65 minutes around the line. The longer half scatters by about 18.50 minutes instead, almost two and a half times as much. One sigma, 14.17, was never the right number for either half. It was a single average covering two very different stories. Statisticians call a spread that changes like this heteroskedastic, and one that stays the same at every distance homoskedastic.