code: def p_tests(
      z: Float64Array, lag: int, trend: UnitRootTrend
  ) -> tuple[float, float]:
      x, y = z[:, 1:], z[:, 0]
      nobs = x.shape[0]
      x = add_trend(x, trend=trend)
      beta = np.linalg.lstsq(x, y, rcond=None)[0]
      u = y - x @ beta
      z_lead = z[1:]
      z_lag = add_trend(z[:-1], trend=trend)
      phi = np.linalg.lstsq(z_lag, z_lead, rcond=None)[0]
      xi = z_lead - z_lag @ phi
  
      omega = xi.T @ xi / nobs
      for i in range(1, lag + 1):
          w = 1 - i / (lag + 1)
          gamma = xi[i:].T @ xi[:-i] / nobs
          omega += w * (gamma + gamma.T)
      omega21 = omega[0, 1:]
      omega22 = omega[1:, 1:]
      omega112 = omega[0, 0] - np.squeeze(
          omega21.T @ np.linalg.inv(omega22) @ omega21
      )
      denom = u.T @ u / nobs
      p_u = nobs * omega112 / denom
  
      tr = add_trend(nobs=z.shape[0], trend=trend)
      if tr.shape[1]:
          z = z - tr @ np.linalg.lstsq(tr, z, rcond=None)[0]
      else:
          z = z - z[0]
      m_zz = z.T @ z / nobs
      p_z = nobs * (omega @ np.linalg.inv(m_zz)).trace()
      return p_u, p_z
  
file_path: arch/arch/tests/unitroot/test_phillips_ouliaris.py
imports: import numpy
  from numpy.testing import assert_allclose
  import pytest
  from statsmodels.iolib.summary import Summary
  from arch.typing import Float64Array, UnitRootTrend
  from arch.unitroot._phillips_ouliaris import CriticalValueWarning, phillips_ouliaris_cv, phillips_ouliaris_pval
  from arch.unitroot.cointegration import phillips_ouliaris
  from arch.utility.timeseries import add_trend
label_desc: Use image node_id 2 for calling a global function with example usage: p_tests(z, lag, trend) and returns: p_u,  p_z