code: def test_sarimax_simple_differencing_time_varying_exog_shocks(
      reset_randomstate,
  ):
      # Test simulating values from the end of a time-varying SARIMAX model
      # Note that `exog` here has basically the same effect as measurement shocks
      endog = np.cumsum(np.arange(0, 11))
      exog = np.cumsum(np.arange(0, 21) ** 2)
      mod = sarimax.SARIMAX(
          endog,
          order=(1, 1, 0),
          exog=exog[:11],
          simple_differencing=True,
      )
      res = mod.filter([1.0, 0.2, 1.0])
  
      nsimulations = 10
      measurement_shocks = np.random.normal(size=nsimulations)
      state_shocks = np.random.normal(size=nsimulations)
      initial_state = res.predicted_state[:1, -1]
  
      actual = res.simulate(
          nsimulations,
          exog=exog[11:],
          anchor="end",
          measurement_shocks=measurement_shocks,
          state_shocks=state_shocks,
          initial_state=initial_state,
      )
  
      # Compute the desired simulated values directly
      x = np.r_[initial_state, state_shocks[:-1]]
      desired = (
          lfilter([1], [1, -0.2], x)
          + np.diff(exog)[10:]
          + measurement_shocks
      )
      assert_allclose(actual, desired)
  
      # Test using the model versus the results class
      mod_actual = mod.simulate(
          res.params,
          nsimulations,
          exog=exog[11:],
          anchor="end",
          measurement_shocks=measurement_shocks,
          state_shocks=state_shocks,
          initial_state=initial_state,
      )
  
      assert_allclose(mod_actual, desired)
  
imports: from statsmodels.compat.pandas import MONTH_END
  import numpy
  from numpy.testing import assert_, assert_allclose, assert_equal
  import pandas
  import pytest
  from scipy.signal import lfilter
  from statsmodels.tools.sm_exceptions import EstimationWarning, SpecificationWarning
  from statsmodels.tsa.statespace import dynamic_factor, sarimax, structural, varmax
  from .test_impulse_responses import TVSS
label_desc: Use image node_id 19 for calling a global function with example usage: test_sarimax_simple_differencing_time_varying_exog_shocks(reset_randomstate) without return types