code: def test_sarimax_nonconsecutive():
      # SARIMAX allows using non-consecutive lag orders, which implicitly fix
      # AR coefficients to zeros, so we can test explicitly fixed AR coefficients
      # against this
      endog = macrodata["infl"]
  
      # y_t = \phi_1 y_{t-1} + \phi_4 y_{t-4} + \varepsilon_t
      # Note: because the transformation will not respect the parameter
      # constraints, we will need to set enforce_stationarity=False; set it to
      # False here too so that they both are the same model
      mod1 = sarimax.SARIMAX(
          endog, order=([1, 0, 0, 1], 0, 0), enforce_stationarity=False
      )
      mod2 = sarimax.SARIMAX(
          endog, order=(4, 0, 0), enforce_stationarity=False
      )
  
      # Start pretty close to optimum to speed up test
      start_params = [0.6, 0.2, 6.4]
      res1 = mod1.fit(start_params, disp=False)
      res2 = mod2.fit_constrained(
          {"ar.L2": 0, "ar.L3": 0},
          res1.params,
          includes_fixed=False,
          disp=False,
      )
  
      # Check that the right parameters were fixed
      assert_equal(res1.fixed_params, [])
      assert_equal(res2.fixed_params, ["ar.L2", "ar.L3"])
  
      # Check that MLE finds the same parameters in either case
      params = np.asarray(res1.params)
      desired = np.r_[params[0], 0, 0, params[1:]]
      assert_allclose(res2.params, desired)
  
      # Now smooth at the actual parameters (to allow high precision testing
      # below, even if there are small differences between MLE fitted parameters)
      with mod2.fix_params({"ar.L2": 0, "ar.L3": 0}):
          res2 = mod2.smooth(res1.params)
  
      check_results(res1, res2, check_lutkepohl=True)
  
      # Check that results methods work within the context
      with mod2.fix_params({"ar.L2": 0, "ar.L3": 0}):
          res3 = mod2.filter(res2.params, includes_fixed=True)
          check_results(res1, res3, check_lutkepohl=True)
  
imports: import numpy
  import pytest
  from statsmodels import datasets
  from statsmodels.tsa.statespace import initialization, mlemodel, sarimax, structural, dynamic_factor, varmax
  from numpy.testing import assert_, assert_raises, assert_equal, assert_allclose
label_desc: Use image node_id 12 for calling a global function with example usage: test_sarimax_nonconsecutive() without return types