code: def test_innovations_mle_statespace_seasonal():
      # Test innovations output against state-space output.
      endog = lake.copy()
      endog = endog - endog.mean()
  
      start_params = [0, np.var(endog)]
      p, mleres = innovations_mle(
          endog,
          seasonal_order=(1, 0, 0, 4),
          demean=False,
          start_params=start_params,
      )
  
      mod = sarimax.SARIMAX(
          endog, order=(0, 0, 0), seasonal_order=(1, 0, 0, 4)
      )
  
      # Test that the maximized log-likelihood found via applications of the
      # innovations algorithm matches the log-likelihood found by the Kalman
      # filter at the same parameters
      res = mod.filter(p.params)
      assert_allclose(-mleres.minimize_results.fun, res.llf)
  
      # Test MLE fitting
      # To avoid small numerical differences with MLE fitting, start at the
      # parameters found from innovations_mle
      res2 = mod.fit(start_params=p.params, disp=0)
  
      # Test that the state space approach confirms the MLE values found by
      # innovations_mle
      assert_allclose(p.params, res2.params)
  
      # Test that starting parameter estimation succeeds and isn't terrible
      # (i.e. leads to the same MLE)
      p2, _ = innovations_mle(
          endog, seasonal_order=(1, 0, 0, 4), demean=False
      )
      # (does not need to be high-precision test since it's okay if different
      # starting parameters give slightly different MLE)
      assert_allclose(p.params, p2.params, atol=1e-5)
  
imports: import numpy
  import pytest
  from numpy.testing import assert_, assert_allclose, assert_warns, assert_raises
  from statsmodels.tsa.innovations.arma_innovations import arma_innovations
  from statsmodels.tsa.statespace import sarimax
  from statsmodels.tsa.arima.datasets.brockwell_davis_2002 import dowj, lake, oshorts
  from statsmodels.tsa.arima.estimators.burg import burg
  from statsmodels.tsa.arima.estimators.hannan_rissanen import hannan_rissanen
  from statsmodels.tsa.arima.estimators.innovations import innovations, innovations_mle
label_desc: Use image node_id 10 for calling a global function with example usage: test_innovations_mle_statespace_seasonal() without return types