From four models to one fair contest
Every tool of this skill answers one question: how large will tomorrow's move be? A constant variance, an exponentially weighted average, a GARCH(1,1) and a HAR regression on the daily high-low range give four different answers, and the only honest way to choose between them is a contest with fair rules. Each forecast for day t may use only data before day t. GARCH is fitted once on the first 1,000 days and never refitted. All four are scored on the days after that, against the squared return, with a loss that punishes under-predicting the variance more than over-predicting it. Only NumPy is needed.
The EWMA and the GARCH both update a variance state with yesterday's squared return. GARCH has more room: its parameters are chosen by maximising a Gaussian likelihood, here over a small grid with the long-run variance σ² fixed to the sample value (variance targeting). The HAR model reads the range instead. Its feature for day t is built from the Parkinson variance of the days before: yesterday's value, the mean of the last 5 days and the mean of the last 22. Its target is the squared return, which is noisy but has the right level, and it is refitted every 21 days on the previous 750 days. The score is the mean QLIKE, y/h-ln(y/h)-1 with y the proxy and h the forecast, and the Diebold-Mariano statistic tells whether a difference between two forecasters is larger than luck.
On SPY, scored on the 4,404 days after the first 1,000, the mean QLIKE against the squared return is about 2.03 for the constant forecast, 1.63 for the EWMA, 1.59 for the GARCH (grid choice α=0.11, β=0.88, so a persistence of 0.99) and 1.56 for the HAR model on the range. Every step down is a better forecast. The Diebold-Mariano statistic is about 3.5 for EWMA against GARCH and 3.6 for EWMA against HAR, both far beyond 1.96. GARCH against HAR gives about 1.9, just short of significance at 5%. With a proxy as noisy as one squared return, the gaps are modest even when the ordering is clear.
- Fair rules: a forecast for day t uses only data before day t, the GARCH is fitted before the scoring period and filtered forward with fixed parameters.
- QLIKE is the loss, the squared return is the proxy, and Diebold-Mariano tells whether two forecasters really differ.
- Ladder: constant, EWMA, GARCH, HAR on the range; each step lowers the loss on SPY, but the last gap is within noise.
The proxy is one squared return, so all losses are high and differences are small; a realised variance would sharpen them. The GARCH is fitted once on a coarse grid and never updated, whereas a live system would refit it. The likelihood is Gaussian although returns have fat tails. And the score is for one asset in one period that includes a crisis: a winner here is not a promise for the next decade.
Lab · what's graded
8 tasks · 100 pts- A range-based variance10 pts
- An EWMA forecaster15 pts
- A GARCH filter15 pts
- Fitting a GARCH on a grid15 pts
- A HAR forecaster20 pts
- The QLIKE loss10 pts
- The Diebold-Mariano statistic5 pts
- The contest10 pts