code: def test_varmax():
      np.random.seed(371934)
      nobs = 100
      eps = np.random.normal(size=nobs)
      exog = np.random.normal(size=(nobs, 1))
  
      eps1 = np.zeros(nobs)
      eps2 = np.zeros(nobs)
      eps2[49] = 1
      eps3 = np.zeros(nobs)
      eps3[50:] = 1
  
      # VAR(2) - single series
      mod1 = varmax.VARMAX([[0]], order=(2, 0), trend="n")
      mod2 = sarimax.SARIMAX([0], order=(2, 0, 0))
      actual = mod1.simulate(
          [0.5, 0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod1.k_states),
      )
      desired = mod2.simulate(
          [0.5, 0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod2.k_states),
      )
      assert_allclose(actual, desired)
  
      # VMA(2) - single series
      mod1 = varmax.VARMAX([[0]], order=(0, 2), trend="n")
      mod2 = sarimax.SARIMAX([0], order=(0, 0, 2))
      actual = mod1.simulate(
          [0.5, 0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod1.k_states),
      )
      desired = mod2.simulate(
          [0.5, 0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod2.k_states),
      )
      assert_allclose(actual, desired)
  
      # VARMA(2, 2) - single series
      warning = EstimationWarning
      match = r"VARMA\(p,q\) models is not"
      with pytest.warns(warning, match=match):
          mod1 = varmax.VARMAX([[0]], order=(2, 2), trend="n")
      mod2 = sarimax.SARIMAX([0], order=(2, 0, 2))
      actual = mod1.simulate(
          [0.5, 0.2, 0.1, -0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod1.k_states),
      )
      desired = mod2.simulate(
          [0.5, 0.2, 0.1, -0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod2.k_states),
      )
      assert_allclose(actual, desired)
  
      # VARMA(2, 2) + trend - single series
      warning = EstimationWarning
      match = r"VARMA\(p,q\) models is not"
      with pytest.warns(warning, match=match):
          mod1 = varmax.VARMAX([[0]], order=(2, 2), trend="c")
      mod2 = sarimax.SARIMAX([0], order=(2, 0, 2), trend="c")
      actual = mod1.simulate(
          [10, 0.5, 0.2, 0.1, -0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod1.k_states),
      )
      desired = mod2.simulate(
          [10, 0.5, 0.2, 0.1, -0.2, 1],
          nobs,
          state_shocks=eps,
          initial_state=np.zeros(mod2.k_states),
      )
      assert_allclose(actual, desired)
  
      # VAR(1)
      transition = np.array([[0.5, 0.1], [-0.1, 0.2]])
  
      mod = varmax.VARMAX([[0, 0]], order=(1, 0), trend="n")
      actual = mod.simulate(
          np.r_[transition.ravel(), 1.0, 0, 1.0],
          nobs,
          state_shocks=np.c_[eps1, eps1],
          initial_state=np.zeros(mod.k_states),
      )
      assert_allclose(actual, 0)
  
      actual = mod.simulate(
          np.r_[transition.ravel(), 1.0, 0, 1.0],
          nobs,
          state_shocks=np.c_[eps1, eps1],
          initial_state=[1, 1],
      )
      desired = np.zeros((nobs, 2))
      state = np.r_[1, 1]
      for i in range(nobs):
          desired[i] = state
          state = np.dot(transition, state)
      assert_allclose(actual, desired)
  
      # VAR(1) + measurement error
      mod = varmax.VARMAX(
          [[0, 0]], order=(1, 0), trend="n", measurement_error=True
      )
      actual = mod.simulate(
          np.r_[transition.ravel(), 1.0, 0, 1.0, 1.0, 1.0],
          nobs,
          measurement_shocks=np.c_[eps, eps],
          state_shocks=np.c_[eps1, eps1],
          initial_state=np.zeros(mod.k_states),
      )
      assert_allclose(actual, np.c_[eps, eps])
  
      # VARX(1)
      mod = varmax.VARMAX(
          np.zeros((nobs, 2)), order=(1, 0), trend="n", exog=exog
      )
      actual = mod.simulate(
          np.r_[transition.ravel(), 5, -2, 1.0, 0, 1.0],
          nobs,
          state_shocks=np.c_[eps1, eps1],
          initial_state=[1, 1],
      )
      desired = np.zeros((nobs, 2))
      state = np.r_[1, 1]
      for i in range(nobs):
          desired[i] = state
          if i < nobs - 1:
              state = exog[i + 1] * [5, -2] + np.dot(transition, state)
      assert_allclose(actual, desired)
  
      # VMA(1)
      # TODO: This is just a smoke test
      mod = varmax.VARMAX(
          np.random.normal(size=(nobs, 2)), order=(0, 1), trend="n"
      )
      mod.simulate(mod.start_params, nobs)
  
      # VARMA(2, 2) + trend + exog
      # TODO: This is just a smoke test
      warning = EstimationWarning
      match = r"VARMA\(p,q\) models is not"
      with pytest.warns(warning, match=match):
          mod = varmax.VARMAX(
              np.random.normal(size=(nobs, 2)),
              order=(2, 2),
              trend="c",
              exog=exog,
          )
      mod.simulate(mod.start_params, nobs)
  
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 4 for calling a global function with example usage: test_varmax() without return types