SVResult.forecast_variance#
- SVResult.forecast_variance(steps)[source]#
Expected variance
E[exp(h_{T+k}) | y]fork = 1..steps.Propagates the last smoothed log-variance mean and variance through the AR(1) and applies the log-normal correction,
\[m_k = \mu + \phi (m_{k-1} - \mu), \qquad v_k = \phi^2 v_{k-1} + \sigma^2, \qquad E[\exp(h_{T+k})] = \exp(m_k + \tfrac12 v_k),\]so the path converges to
unconditional_variance.- Parameters:
steps (
int) – Horizons ahead, at least 1.- Return type:
- Returns:
An array of shape
(steps,).- Raises:
SpecificationError – If
stepsis not positive.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> res = SV(rng.standard_normal(200), mean="zero").fit() >>> path = res.forecast_variance(400) >>> path.shape, bool(abs(path[-1] - res.unconditional_variance) < 0.02) ((400,), True) >>> res.forecast_variance(0) Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: steps must be at least 1; got 0.