code: def test_egarch_111_forecast(self):
      t = self.t
      dist = Normal(seed=self.rng)
      rng = dist.simulate([])
      vol = EGARCH(p=1, o=1, q=1)
      params = np.array([0.0, 0.1, 0.1, 0.95])
      resids = self.resid
      backcast = vol.backcast(resids)
      var_bounds = vol.variance_bounds(resids)
  
      forecast = vol.forecast(
          params, resids, backcast, var_bounds, horizon=1, start=0
      )
  
      _resids = np.array(resids.tolist() + [0])
      _sigma2 = np.empty_like(_resids)
      _var_bounds = np.array(var_bounds.tolist() + [[0, np.inf]])
      vol.compute_variance(
          params, _resids, _sigma2, backcast, _var_bounds
      )
      sigma2 = _sigma2[:-1]
      one_step = _sigma2[1:][:, None]
  
      assert_allclose(forecast.forecasts, one_step)
      assert forecast.forecast_paths is None
      assert forecast.shocks is None
  
      expected = forecast.forecasts.copy()
      expected[:-1] = np.nan
      forecast = vol.forecast(
          params, resids, backcast, var_bounds, horizon=1
      )
      assert_allclose(forecast.forecasts, expected[-1:])
      assert forecast.forecast_paths is None
      assert forecast.shocks is None
  
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              resids,
              backcast,
              var_bounds,
              horizon=5,
              start=0,
              method="simulation",
              rng=rng,
          )
      paths = np.empty((t, 1000, 5))
      shocks = np.empty((t, 1000, 5))
      sqrt2pi = np.sqrt(2 / np.pi)
      for i in range(t):
          std_shocks = rng((1000, 5))
          paths[i, :, 0] = np.log(one_step[i])
          for j in range(1, 5):
              paths[i, :, j] = (
                  params[0]
                  + params[1] * (np.abs(std_shocks[:, j - 1]) - sqrt2pi)
                  + params[2] * std_shocks[:, j - 1]
                  + params[3] * paths[i, :, j - 1]
              )
          shocks[i, :, :] = np.exp(paths[i, :, :] / 2) * std_shocks
      paths = np.exp(paths)
      assert_allclose(forecast.forecasts, paths.mean(1))
      assert_allclose(forecast.forecast_paths, paths)
      assert_allclose(forecast.shocks, shocks)
  
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              resids,
              backcast,
              var_bounds,
              horizon=5,
              start=100,
              method="bootstrap",
              random_state=self.rng,
          )
  
      std_resids = resids / np.sqrt(sigma2)
      paths = np.empty((t, 1000, 5))
      paths.fill(np.nan)
      shocks = np.empty((t, 1000, 5))
      shocks.fill(np.nan)
      sqrt2pi = np.sqrt(2 / np.pi)
      for i in range(100, t):
          locs = self.rng.random_sample((1000, 5))
          int_locs = np.floor((i + 1) * locs).astype(np.int64)
          std_shocks = std_resids[int_locs]
          paths[i, :, 0] = np.log(one_step[i])
          for j in range(1, 5):
              paths[i, :, j] = (
                  params[0]
                  + params[1] * (np.abs(std_shocks[:, j - 1]) - sqrt2pi)
                  + params[2] * std_shocks[:, j - 1]
                  + params[3] * paths[i, :, j - 1]
              )
          shocks[i, :, :] = np.exp(paths[i, :, :] / 2) * std_shocks
      paths = np.exp(paths)
      assert_allclose(forecast.forecasts, paths[100:].mean(1))
      assert_allclose(forecast.forecast_paths, paths[100:])
      assert_allclose(forecast.shocks, shocks[100:])
  
      with pytest.raises(ValueError):
          vol.forecast(params, resids, backcast, var_bounds, horizon=5)
  
imports: import numpy
  from numpy.random import RandomState
  from numpy.testing import assert_allclose
  import pandas
  import pytest
  from arch.univariate import arch_model
  from arch.univariate.distribution import Normal, StudentsT
  from arch.univariate.mean import ConstantMean
  from arch.univariate.volatility import APARCH, EGARCH, FIGARCH, GARCH, HARCH, BootstrapRng, ConstantVariance, EWMAVariance, FixedVariance, MIDASHyperbolic, RiskMetrics2006
label_desc: Use image node_id 18 for calling the TestVarianceForecasts obj's underlying member method code with example usage: obj.test_egarch_111_forecast() without return types