code: def test_concentrated_loglike_sarimax():
      # Note: we will not use the "concentrate_scale" option to SARIMAX for this
      # test, which is a lower-level test of the Kalman filter using the SARIMAX
      # model as an example
      nobs = 30
      np.random.seed(28953)
      endog = np.random.normal(size=nobs)
      kwargs = {}
  
      # Typical model
      out = get_sarimax_models(endog)
      assert_allclose(out.res_conc.llf, out.res_orig.llf)
      assert_allclose(out.res_conc.llf_obs, out.res_orig.llf_obs)
      assert_allclose(
          out.mod_conc.loglike(out.params_conc),
          out.mod_orig.loglike(out.params_orig),
      )
      assert_allclose(
          out.mod_conc.loglikeobs(out.params_conc),
          out.mod_orig.loglikeobs(out.params_orig),
      )
  
      # Add missing entries
      endog[2:10] = np.nan
      out = get_sarimax_models(endog)
      assert_allclose(out.res_conc.llf, out.res_orig.llf)
      assert_allclose(out.res_conc.llf_obs, out.res_orig.llf_obs)
      assert_allclose(
          out.mod_conc.loglike(out.params_conc),
          out.mod_orig.loglike(out.params_orig),
      )
      assert_allclose(
          out.mod_conc.loglikeobs(out.params_conc),
          out.mod_orig.loglikeobs(out.params_orig),
      )
  
      # Add seasonal differencing
      # Note: now, due to differences in approximate diffuse initialization,
      # we may have differences in the first 2 observations (but notice that
      # this does not affect the computed joint log-likelihood because those
      # observations are not included there)
      kwargs["seasonal_order"] = (1, 1, 1, 2)
      out = get_sarimax_models(endog, **kwargs)
      assert_allclose(out.res_conc.llf, out.res_orig.llf)
      assert_allclose(
          out.res_conc.llf_obs[2:], out.res_orig.llf_obs[2:]
      )
      assert_allclose(
          out.mod_conc.loglike(out.params_conc),
          out.mod_orig.loglike(out.params_orig),
      )
      assert_allclose(
          out.mod_conc.loglikeobs(out.params_conc)[2:],
          out.mod_orig.loglikeobs(out.params_orig)[2:],
      )
  
      # Add loglikelihood burn, trend, and exog
      kwargs["loglikelihood_burn"] = 5
      kwargs["trend"] = "c"
      kwargs["exog"] = np.arange(nobs)
      out = get_sarimax_models(endog, **kwargs)
      assert_allclose(out.res_conc.llf, out.res_orig.llf)
      assert_allclose(
          out.res_conc.llf_obs[2:], out.res_orig.llf_obs[2:]
      )
      assert_allclose(
          out.mod_conc.loglike(out.params_conc),
          out.mod_orig.loglike(out.params_orig),
      )
      assert_allclose(
          out.mod_conc.loglikeobs(out.params_conc)[2:],
          out.mod_orig.loglikeobs(out.params_orig)[2:],
      )
  
file_path: statsmodels/statsmodels/tsa/statespace/tests/test_concentrated.py
imports: import numpy
  import pandas
  from statsmodels.tools.tools import Bunch
  from .results import results_varmax
  from statsmodels.tsa.statespace import sarimax, varmax
  from numpy.testing import assert_raises, assert_allclose
label_desc: Use image node_id 2 for calling a global function with example usage: test_concentrated_loglike_sarimax() without return types