GiacominiWhiteTest#

class cultivars.forecast.comparison.GiacominiWhiteTest(*, statistic, pvalue, horizon, nobs, df, coefficients, instruments, share_a, mean_differential)[source]#

Verdict of the Giacomini-White (2006) test of conditional predictive ability.

The null is not “the two forecasters lose the same on average” but “nothing known at the origin predicts which will lose more,”

\[H_0 : \mathbb{E}\bigl[d_t \mid \mathcal{F}_{t-h}\bigr] = 0 \quad\Longrightarrow\quad \mathbb{E}\bigl[h_{t}\, d_t\bigr] = 0,\]

with \(d_t = L_{A,t} - L_{B,t}\) the loss differential and \(h_t\) a vector of instruments measurable at the origin. The statistic is the Wald form \(T\, \bar z^\top \hat\Omega^{-1} \bar z\) on \(z_t = h_t d_t\), chi-squared on the number of instruments, so a rejection is a statement about a usable rule: the regression of the differential on the instruments, whose fitted sign at a fresh origin says which forecaster to run next. The constant-only case is the unconditional test; with the differential lagged by the horizon as the default instrument, a rejection with an insignificant mean says the gap is there but switches sides, which the average hides.

Variables:
  • statistic – The Wald statistic T zbar' Omega^{-1} zbar.

  • pvalue – Its upper-tail chi-squared p-value on df degrees of freedom.

  • df – Number of instruments, constant included.

  • coefficients – OLS coefficients of the differential on the instruments, in the order constant, lagged differentials, caller instruments; the decision rule.

  • instruments – What the instruments are, in words.

  • share_a – Fraction of retained origins at which the fitted rule favors the first forecaster (fitted differential negative).

  • mean_differential – Average of losses_a - losses_b over the retained origins; negative favors the first forecaster.

  • horizon – Forecast horizon behind the series.

  • nobs – Origins retained after the instruments’ lags.

Note

The framework is built for rolling-window estimation: with a window of fixed length the forecasting method is what the null describes, and its finite memory keeps that null well-posed. Under recursive estimation the parameters converge and the null drifts as the window grows. nobs is smaller than the series length because the lagged-differential instruments consume the first horizon + lags - 1 origins. At multi-step horizons the truncated Bartlett kernel understates the moment covariance and the test over-rejects mildly, about 7-9% at nominal 5% for a four-step horizon.

See also

  • giacomini_white() – the producer, with the open instrument set.

  • ForecastComparison – the unconditional question, with the small-sample correction, and this test on the default instruments as its third row.

References

Giacomini, R., & White, H. (2006). Tests of conditional predictive ability. Econometrica, 74(6), 1545-1578.

Example

A loss gap that flips sign every 25 origins averages to nearly nothing and the unconditional test misses it; a regime indicator the forecaster could have known makes it predictable:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> regime = np.where((np.arange(200) // 25) % 2 == 0, 1.0, -1.0)
>>> losses_a = rng.standard_normal(200) ** 2 + 0.4 * regime
>>> losses_b = rng.standard_normal(200) ** 2
>>> bool(ForecastComparison(losses_a, losses_b).compute().hln_pvalue > 0.3)
True
>>> verdict = giacomini_white(losses_a, losses_b, instruments=regime)
>>> verdict
GiacominiWhiteTest(statistic=8.9204, pvalue=0.03037, df=3, horizon=1, nobs=199)
>>> verdict.instruments, verdict.coefficients.round(2), bool(verdict.reject())
('constant, d[t-1], z1', array([-0.15, -0.09,  0.34]), True)

Attributes#

df

Instruments in the test, constant included; the chi-squared degrees of freedom.

coefficients

OLS coefficients of the differential on the instruments, the decision rule.

instruments

The instrument set in words, such as "constant, d[t-1], z1".

share_a

Share of retained origins at which the fitted rule favors forecaster A.

mean_differential

Average of losses_a - losses_b over the retained origins; negative favors A.

horizon

nobs

pvalue

statistic

Methods#

reject(*[, alpha])

Whether the null is rejected at level alpha.

summary()

The test as a table, renderable as text, HTML, or a dataframe.