code: def test_hac_simple():
      from statsmodels.datasets import macrodata
  
      d2 = macrodata.load_pandas().data
      g_gdp = 400 * np.diff(np.log(d2["realgdp"].values))
      g_inv = 400 * np.diff(np.log(d2["realinv"].values))
      exogg = add_constant(np.c_[g_gdp, d2["realint"][:-1].values])
      res_olsg = OLS(g_inv, exogg).fit()
  
      # > NeweyWest(fm, lag = 4, prewhite = FALSE, sandwich = TRUE,
      #             verbose=TRUE, adjust=TRUE)
      # Lag truncation parameter chosen: 4
      #             (Intercept)                   ggdp                  lint
      cov1_r = [
          [
              +1.40643899878678802,
              -0.3180328707083329709,
              -0.060621111216488610,
          ],
          [
              -0.31803287070833292,
              0.1097308348999818661,
              +0.000395311760301478,
          ],
          [
              -0.06062111121648865,
              0.0003953117603014895,
              +0.087511528912470993,
          ],
      ]
  
      # > NeweyWest(fm, lag = 4, prewhite = FALSE, sandwich = TRUE,
      #             verbose=TRUE, adjust=FALSE)
      # Lag truncation parameter chosen: 4
      #         (Intercept)                  ggdp                  lint
      cov2_r = [
          [
              +1.3855512908840137,
              -0.313309610252268500,
              -0.059720797683570477,
          ],
          [
              -0.3133096102522685,
              +0.108101169035130618,
              +0.000389440793564339,
          ],
          [
              -0.0597207976835705,
              +0.000389440793564336,
              +0.086211852740503622,
          ],
      ]
  
      cov1 = sw.cov_hac_simple(res_olsg, nlags=4, use_correction=True)
      se1 = sw.se_cov(cov1)
      cov2 = sw.cov_hac_simple(res_olsg, nlags=4, use_correction=False)
      se2 = sw.se_cov(cov2)
      # Relax precision requirements for this test due to failure in NumPy 1.23
      assert_allclose(cov1, cov1_r)
      assert_allclose(cov2, cov2_r)
      assert_allclose(np.sqrt(np.diag(cov1_r)), se1)
      assert_allclose(np.sqrt(np.diag(cov2_r)), se2)
  
      # compare default for nlags
      cov3 = sw.cov_hac_simple(res_olsg, use_correction=False)
      cov4 = sw.cov_hac_simple(res_olsg, nlags=4, use_correction=False)
      assert_allclose(cov3, cov4)
  
imports: import numpy
  from numpy.testing import assert_almost_equal, assert_allclose
  from statsmodels.regression.linear_model import OLS
  from statsmodels.tools.tools import add_constant
  import statsmodels.stats.sandwich_covariance
label_desc: Use image node_id 2 for calling a global function with example usage: test_hac_simple() without return types