code: def test_diagnostics_nile_durbinkoopman():
      # Test the diagnostic tests using the Nile dataset. Results are from
      # Durbin and Koopman (2012); parameter values reported on page 37; test
      # statistics on page 40
      niledata = nile.data.load_pandas().data
      niledata.index = pd.date_range(
          "1871-01-01", "1970-01-01", freq="YS"
      )
  
      mod = MLEModel(
          niledata["volume"],
          k_states=1,
          initialization="approximate_diffuse",
          initial_variance=1e15,
          loglikelihood_burn=1,
      )
      mod.ssm["design", 0, 0] = 1
      mod.ssm["obs_cov", 0, 0] = 15099.0
      mod.ssm["transition", 0, 0] = 1
      mod.ssm["selection", 0, 0] = 1
      mod.ssm["state_cov", 0, 0] = 1469.1
      res = mod.filter([])
  
      # Test Ljung-Box
      # Note: only 3 digits provided in the reference paper
      actual = res.test_serial_correlation(method="ljungbox", lags=9)[
          0, 0, -1
      ]
      assert_allclose(actual, [8.84], atol=1e-2)
  
      # Test Jarque-Bera
      # Note: The book reports 0.09 for Kurtosis, because it is reporting the
      # statistic less the mean of the Kurtosis distribution (which is 3).
      norm = res.test_normality(method="jarquebera")[0]
      actual = [norm[0], norm[2], norm[3]]
      assert_allclose(actual, [0.05, -0.03, 3.09], atol=1e-2)
  
      # Test Heteroskedasticity
      # Note: only 2 digits provided in the book
      actual = res.test_heteroskedasticity(method="breakvar")[0, 0]
      assert_allclose(actual, [0.61], atol=1e-2)
  
imports: from statsmodels.compat.pandas import MONTH_END
  import os
  import re
  import warnings
  import numpy
  from numpy.testing import assert_, assert_allclose, assert_almost_equal, assert_equal, assert_raises
  import pandas
  import pytest
  from statsmodels.datasets import nile
  from statsmodels.tsa.statespace import kalman_filter, kalman_smoother, sarimax, varmax
  from statsmodels.tsa.statespace.mlemodel import MLEModel, MLEResultsWrapper
  from statsmodels.tsa.statespace.tests.results import results_sarimax, results_var_misc
label_desc: Use image node_id 25 for calling a global function with example usage: test_diagnostics_nile_durbinkoopman() without return types