Modelling the edges, not the middle
Least squares models the average. Risk lives in the tails: a stock's worst days may react to a variable that hardly moves its average day. Quantile regression fits a chosen quantile τ of the response directly, for example the 5% quantile that a value-at-risk limit is built on. It does this by minimising the check (pinball) loss ρτ(u)=u(τ−1[u<0]) over the residuals u=y−q. Positive residuals are weighted by τ and negative ones by 1−τ, so for τ=0.9 a guess that is too low costs nine times more than one that is too high, which pushes the guess up to the 90th percentile. For τ=0.5 the loss is half the absolute error and the minimiser is the median. In statsmodels you write smf.quantreg('y ~ vol', data).fit(q=0.05).
ρτ(u)=u(τ−1[u<0]),β^τ=argβmini∑ρτ(yi−xi⊤β),Qτ(y∣x)=x⊤βτ(1) Loss by hand and a value-at-risk lineTake
y=1,2,3,10,20. The median
3 has absolute loss
2+1+0+7+17=27, while the mean
7.2 has
31.2. For
τ=0.9 and the guess
q=10 the residuals are
−9,−8,−7,0,10 and the loss is
0.1(9+8+7)+0.9⋅10=11.4, while the guess
q=20 costs only
0.1(19+18+17+10)=6.4, because four of five points sit below it, which is what a 90% quantile should look like. Now use real data: SPY's next-day return in percent against the volatility of the past 20 days (also in percent),
5,384 days. Least squares finds almost no effect, with a slope of
0.011. Quantile regression finds a slope of
−1.50 at
τ=0.05 (standard error
0.05) and
+1.37 at
τ=0.95, and
0.03 at the median. At volatility
1% the fitted quantiles are
−1.77%,
0.07% and
1.64%, and at
2% they are
−3.27%,
0.10% and
3.01%: a band of width
6.28 points. The tails open up with volatility while the centre barely moves. As a value-at-risk limit the fitted
τ=0.05 line is breached on
5.0% of days overall, and on
7.2% of the
263 days with volatility above
2%, where the constant normal limit of
−1.92% is breached on
22.4% and on only
1.3% of the
2,600 calm days below
0.8%.
Two cautions. Quantile lines fitted separately can cross, so the 5% line ends above the 50% line in the extremes of x, which a careful analyst checks. And the standard errors of quantile regression are bootstrapped or asymptotic, with the same autocorrelation worries as before, so tail estimates from short samples are noisy.
- Pick the quantile you care about: 5% for downside risk, 50% for the typical case, 95% for the upside.
- Check coverage by regime: a limit that is right overall can be wrong in every calm and every stormy period.
Lab · what's graded
- An absolute loss15 pts
- A pinball loss15 pts
- A predicted 5% quantile15 pts
- The width of the band10 pts
- Expected breaches15 pts
- Why the constant limit fails10 pts
- The average hides the tail20 pts