code: def test_gjrgarch222_simulation(self):
      vol = GARCH(p=2, o=2, q=2)
      params = np.array([10.0, 0.05, 0.03, 0.1, 0.05, 0.3, 0.2])
      dist = Normal(seed=self.rng)
      rng = dist.simulate([])
      backcast = vol.backcast(self.resid)
      var_bounds = vol.variance_bounds(self.resid)
      one_step = vol.forecast(
          params, self.resid, backcast, var_bounds, horizon=1, start=0
      )
      with preserved_state(self.rng):
          forecast = vol.forecast(
              params,
              self.resid,
              backcast,
              var_bounds,
              horizon=3,
              method="simulation",
              start=0,
              rng=rng,
              simulations=100,
          )
      paths = np.zeros((100, 3))
      shocks = np.zeros((100, 3))
  
      resids = self.resid
      sigma2_0 = (
          params[0]
          + (np.sum(params[1:]) - 0.5 * np.sum(params[3:5])) * backcast
      )
      _sigma2 = np.concatenate(
          [[backcast], [sigma2_0], one_step.forecasts[:-1, 0]]
      )
      _resids = np.concatenate([[np.sqrt(backcast)], resids])
      _asymresids = np.concatenate(
          [[np.sqrt(0.5 * backcast)], resids * (resids < 0)]
      )
  
      for t in range(resids.shape[0]):
          std_shocks = rng((100, 3))
  
          j = 0
          tau = t + 1 + j + 1
          r1, r2 = _resids[tau - 1], _resids[tau - 2]
          a1, a2 = _asymresids[tau - 1], _asymresids[tau - 2]
          s21, s22 = _sigma2[tau - 1], _sigma2[tau - 2]
  
          fcast = (
              params[0]
              + params[1] * r1**2
              + params[2] * r2**2
              + params[3] * a1**2
              + params[4] * a2**2
              + params[5] * s21
              + params[6] * s22
          )
          paths[:, j] = fcast
          shocks[:, j] = std_shocks[:, j] * np.sqrt(fcast)
  
          j = 1
          r1, r2 = shocks[:, 0], _resids[tau - 1]
          a1, a2 = (
              shocks[:, 0] * (shocks[:, 0] < 0),
              _asymresids[tau - 1],
          )
          s21, s22 = paths[:, 0], _sigma2[tau - 1]
          fcast = (
              params[0]
              + params[1] * r1**2
              + params[2] * r2**2
              + params[3] * a1**2
              + params[4] * a2**2
              + params[5] * s21
              + params[6] * s22
          )
          paths[:, j] = fcast
          shocks[:, j] = std_shocks[:, j] * np.sqrt(fcast)
  
          j = 2
          r1, r2 = shocks[:, 1], shocks[:, 0]
          a1, a2 = (
              shocks[:, 1] * (shocks[:, 1] < 0),
              shocks[:, 0] * (shocks[:, 0] < 0),
          )
          s21, s22 = paths[:, 1], paths[:, 0]
          fcast = (
              params[0]
              + params[1] * r1**2
              + params[2] * r2**2
              + params[3] * a1**2
              + params[4] * a2**2
              + params[5] * s21
              + params[6] * s22
          )
          paths[:, j] = fcast
          shocks[:, j] = std_shocks[:, j] * np.sqrt(fcast)
  
          forecasts = paths.mean(0)
          assert_allclose(forecast.forecasts[t], forecasts)
          assert_allclose(forecast.forecast_paths[t], paths)
          assert_allclose(forecast.shocks[t], shocks)
  
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 26 for calling the TestVarianceForecasts obj's underlying member method code with example usage: obj.test_gjrgarch222_simulation() without return types