code: def test_hess(self):
      # NOTE: I had to overwrite this to lessen the tolerance
      for test_params in self.params:
          he = self.mod.hessian(test_params)
          hefd = numdiff.approx_fprime_cs(test_params, self.mod.score)
          assert_almost_equal(he, hefd, decimal=DEC8)
  
          # NOTE: notice the accuracy below and the epsilon changes
          # this does not work well for score -> hessian with non-cs step
          # it's a little better around the optimum
          assert_almost_equal(he, hefd, decimal=7)
          hefd = numdiff.approx_fprime(
              test_params, self.mod.score, centered=True
          )
          assert_almost_equal(he, hefd, decimal=4)
          hefd = numdiff.approx_fprime(
              test_params, self.mod.score, 1e-9, centered=False
          )
          assert_almost_equal(he, hefd, decimal=2)
  
          hescs = numdiff.approx_fprime_cs(test_params, self.mod.score)
          assert_almost_equal(he, hescs, decimal=DEC8)
  
          hecs = numdiff.approx_hess_cs(test_params, self.mod.loglike)
          assert_almost_equal(he, hecs, decimal=5)
          # NOTE: these just do not work well
          # hecs = numdiff.approx_hess1(test_params, self.mod.loglike, 1e-3)
          # assert_almost_equal(he, hecs, decimal=1)
          # hecs = numdiff.approx_hess2(test_params, self.mod.loglike, 1e-4)
          # assert_almost_equal(he, hecs, decimal=0)
          hecs = numdiff.approx_hess3(
              test_params, self.mod.loglike, 1e-4
          )
          assert_almost_equal(he, hecs, decimal=0)
  
imports: import numpy
  from numpy.testing import assert_allclose, assert_almost_equal
  import statsmodels.api
  from statsmodels.tools import numdiff
  from statsmodels.tools.numdiff import approx_fprime, approx_fprime_cs, approx_hess_cs, _approx_fprime_scalar, _approx_fprime_cs_scalar
label_desc: Use image node_id 2 for calling the TestGradMNLogit obj's underlying member method code with example usage: obj.test_hess() without return types