code: def test_trivariate(data, trend, method, lhs):
      rhs = ["x", "y", "z"]
      if isinstance(data, pd.DataFrame):
          rhs.remove(lhs)
          dep, exog = data[lhs], data[rhs]
      else:
          dep_loc = rhs.index(lhs)
          exog_locs = [0, 1, 2]
          exog_locs.remove(dep_loc)
          dep = data[:, dep_loc]
          exog = data[:, exog_locs]
  
      test = engle_granger(dep, exog, trend=trend, method=method)
      key = (lhs, trend)
      assert_allclose(test.stat, TRIVARIATE[key][0], rtol=1e-4)
      assert_allclose(test.rho, 1 + TRIVARIATE[key][2], rtol=1e-4)
      assert_allclose(test.pvalue, TRIVARIATE[key][1], rtol=2e-2)
      assert test.lags == 0
      assert isinstance(test.summary(), Summary)
      assert isinstance(test._repr_html_(), str)
  
      ci = test.cointegrating_vector
      assert isinstance(ci, pd.Series)
  
      if HAS_MATPLOTLIB:
          import matplotlib.pyplot as plt
  
          fig = test.plot()
          assert isinstance(fig, plt.Figure)
  
          plt.close("all")
      assert isinstance(test.resid, pd.Series)
      assert test.resid.shape[0] == dep.shape[0]
  
file_path: arch/arch/tests/unitroot/test_engle_granger.py
imports: import numpy
  from numpy.testing import assert_allclose
  import pandas
  import pytest
  from statsmodels.iolib.summary import Summary
  from arch.unitroot._engle_granger import engle_granger_cv, engle_granger_pval
  from arch.unitroot._shared import ResidualCointegrationTestResult, _cross_section
  from arch.unitroot.cointegration import engle_granger
label_desc: Use image node_id 4 for calling a global function with example usage: test_trivariate(data, trend, method, lhs) without return types