code: def test_resid_recursive():
      mod = RecursiveLS(endog, exog)
      res = mod.fit()
  
      # Test the recursive residuals against those from R (strucchange)
      assert_allclose(
          res.resid_recursive[2:10].T, results_R.iloc[:8]["rec_resid"]
      )
      assert_allclose(
          res.resid_recursive[9:20].T, results_R.iloc[7:18]["rec_resid"]
      )
      assert_allclose(
          res.resid_recursive[19:].T, results_R.iloc[17:]["rec_resid"]
      )
  
      # Test the RLS estimates against those from Stata (cusum6)
      assert_allclose(
          res.resid_recursive[3:],
          results_stata.iloc[3:]["rr"],
          atol=1e-5,
          rtol=1e-5,
      )
  
      # Test the RLS estimates against statsmodels estimates
      mod_ols = OLS(endog, exog)
      res_ols = mod_ols.fit()
      desired_resid_recursive = recursive_olsresiduals(res_ols)[4][2:]
      assert_allclose(res.resid_recursive[2:], desired_resid_recursive)
  
imports: import os
  import numpy
  from numpy.testing import assert_allclose, assert_equal, assert_raises
  import pandas
  import pytest
  from scipy.stats import norm
  from statsmodels.datasets import macrodata
  from statsmodels.genmod.api import GLM
  from statsmodels.regression.linear_model import OLS
  from statsmodels.regression.recursive_ls import RecursiveLS
  from statsmodels.stats.diagnostic import recursive_olsresiduals
  from statsmodels.tools import add_constant
  from statsmodels.tools.eval_measures import aic, bic
  from statsmodels.tools.sm_exceptions import ValueWarning
label_desc: Use image node_id 9 for calling a global function with example usage: test_resid_recursive() without return types