BacktestResult.quantile#

BacktestResult.quantile(tau, *, horizon=1)[source]#

(T, k) quantile forecasts at level \(\tau\) for one horizon.

From the predictive draws when they were recorded, as the empirical \(\tau\)-quantile across the \(S\) draws at each origin; for a point backtest the recorded forecasts are the quantile forecasts, the case of a quantile regression backtested through predict, and are returned as given whatever \(\tau\) is asked for.

Parameters:
  • tau (float) – The level, strictly inside (0, 1).

  • horizon (int) – The horizon, in 1 .. horizons.

Return type:

NDArray[double]

Returns:

The (T, k) quantile forecasts.

Raises:

SpecificationError – If the level or horizon is unusable.

Example

>>> import numpy as np
>>> from cultivars.multivariate.large_dim.bayesian import BVAR
>>> y = np.random.default_rng(0).standard_normal((140, 2))
>>> fit = lambda w: BVAR(w, order=1).fit(n_draws=50, seed=0)
>>> record = Backtest(y, fit, horizons=1, start=130, step=5).run()
>>> low, high = record.quantile(0.1), record.quantile(0.9)
>>> low.shape, bool(np.all(low < high))
((2, 2), True)