code: def engle_granger(
      y: ArrayLike1D,
      x: ArrayLike2D,
      trend: UnitRootTrend = "c",
      *,
      lags: int | None = None,
      max_lags: int | None = None,
      method: Literal["aic", "bic", "t-stat"] = "bic",
  ) -> EngleGrangerTestResults:
      r"""
      Test for cointegration within a set of time series.
  
      Parameters
      ----------
      y : array_like
          The left-hand-side variable in the cointegrating regression.
      x : array_like
          The right-hand-side variables in the cointegrating regression.
      trend : {"n","c","ct","ctt"}, default "c"
          Trend to include in the cointegrating regression. Trends are:
  
          * "n": No deterministic terms
          * "c": Constant
          * "ct": Constant and linear trend
          * "ctt": Constant, linear and quadratic trends
      lags : int, default None
          The number of lagged differences to include in the Augmented
          Dickey-Fuller test used on the residuals of the
      max_lags : int, default None
          The maximum number of lags to consider when using automatic
          lag-length in the Augmented Dickey-Fuller regression.
      method: {"aic", "bic", "tstat"}, default "bic"
          The method used to select the number of lags included in the
          Augmented Dickey-Fuller regression.
  
      Returns
      -------
      EngleGrangerTestResults
          Results of the Engle-Granger test.
  
      See Also
      --------
      arch.unitroot.ADF
          Augmented Dickey-Fuller testing.
      arch.unitroot.PhillipsPerron
          Phillips & Perron's unit root test.
      arch.unitroot.cointegration.phillips_ouliaris
          Phillips-Ouliaris tests of cointegration.
  
      Notes
      -----
      The model estimated is
  
      .. math::
  
         Y_t = X_t \beta + D_t \gamma + \epsilon_t
  
      where :math:`Z_t = [Y_t,X_t]` is being tested for cointegration.
      :math:`D_t` is a set of deterministic terms that may include a
      constant, a time trend or a quadratic time trend.
  
      The null hypothesis is that the series are not cointegrated.
  
      The test is implemented as an ADF of the estimated residuals from the
      cross-sectional regression using a set of critical values that is
      determined by the number of assumed stochastic trends when the null
      hypothesis is true.
      """
      setup = _check_cointegrating_regression(y, x, trend)
      xsection = _cross_section(setup.y, setup.x, setup.trend)
      resid = xsection.resid
      # Never pass in the trend here since only used in x-section
      adf = ADF(
          resid, lags, trend="n", max_lags=max_lags, method=method
      )
      stat = adf.stat
      nobs = resid.shape[0] - adf.lags - 1
      num_x = setup.x.shape[1]
      cv = engle_granger_cv(trend, num_x, nobs)
      pv = engle_granger_pval(stat, trend, num_x)
      return EngleGrangerTestResults(
          stat, pv, cv, order=num_x, adf=adf, xsection=xsection
      )
  
imports: from __future__ import annotations
  import numpy
  import pandas
  from scipy import stats
  from statsmodels.iolib.summary import Summary
  from statsmodels.iolib.table import SimpleTable
  from statsmodels.regression.linear_model import RegressionResults
  from arch.typing import ArrayLike1D, ArrayLike2D, Literal, UnitRootTrend
  from arch.unitroot._shared import ResidualCointegrationTestResult, _check_cointegrating_regression, _cross_section
  from arch.unitroot.critical_values.engle_granger import CV_PARAMETERS, LARGE_PARAMETERS, SMALL_PARAMETERS, TAU_MAX, TAU_MIN, TAU_STAR
  from arch.unitroot.unitroot import ADF, TREND_DESCRIPTION
label_desc: Use image node_id 1 for calling a global function with example usage: engle_granger(y, x, trend) and returns: EngleGrangerTestResults