ForecastComparison.compute#
- ForecastComparison.compute(*, horizon=1)[source]#
Run the unconditional and conditional tests.
Forms \(d_t\), refuses a numerically constant differential, and computes the Bartlett long-run variance through
horizon - 1lags for the Diebold-Mariano ratio; scales that ratio by the HLN factor \(\sqrt{(T + 1 - 2h + h(h-1)/T)/T}\) for the \(t_{T-1}\) reading; and builds the Giacomini-White instruments – a constant and \(d_{t-h}\) – for the conditional Wald statistic. Deterministic: nothing here draws.- Parameters:
horizon (
int) – The forecast horizon behind the losses; the differential’s variance sums autocovariances throughhorizon - 1lags with Bartlett weights, since anh-step error is mechanically an MA(h - 1).- Return type:
- Returns:
- Raises:
SpecificationError – If the horizon is not positive or exceeds what the window can support, or the two series are numerically identical.
NumericalError – If the conditional moment matrix degenerates.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> a, b = rng.standard_normal(100) ** 2, rng.standard_normal(100) ** 2 >>> verdict = ForecastComparison(a, b).compute(horizon=4) >>> verdict.horizon, verdict.nobs (4, 100) >>> bool(abs(verdict.hln_statistic) < abs(verdict.dm_statistic)) True >>> ForecastComparison(a, a).compute() Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: the two loss series are numerically ...