code: def test_sim(method, tester, n, p, es):
      # This function assesses the performance of the knockoff approach
      # relative to its theoretical claims.
  
      if method == "sdp" and not has_cvxopt:
          return
  
      np.random.seed(43234)
  
      # Number of variables with a non-zero coefficient
      npos = 30
  
      # Aim to control FDR to this level
      target_fdr = 0.2
  
      # Number of siumulation replications
      nrep = 10
  
      if method == "sdp" and not has_cvxopt:
          return
  
      fdr, power = 0, 0
      for k in range(nrep):
          # Generate the predictors
          x = np.random.normal(size=(n, p))
          x /= np.sqrt(np.sum(x * x, 0))
  
          # Generate the response variable
          coeff = es * (-1) ** np.arange(npos)
          y = np.dot(x[:, 0:npos], coeff) + np.random.normal(size=n)
  
          kn = RegressionFDR(y, x, tester)
  
          # Threshold to achieve the target FDR
          tr = kn.threshold(target_fdr)
  
          # Number of selected coefficients
          cp = np.sum(kn.stats >= tr)
  
          # Number of false positives
          fp = np.sum(kn.stats[npos:] >= tr)
  
          # Observed FDR
          fdr += fp / max(cp, 1)
  
          # Proportion of true positives that are detected
          power += np.mean(kn.stats[0:npos] >= tr)
  
          # The estimated FDR may never exceed the target FDR
          estimated_fdr = np.sum(kn.stats <= -tr) / (
              1 + np.sum(kn.stats >= tr)
          )
          assert_equal(estimated_fdr < target_fdr, True)
  
      power /= nrep
      fdr /= nrep
  
      # Check for reasonable power
      assert_array_equal(power > 0.6, True)
  
      # Check that we are close to the target FDR
      assert_array_equal(fdr < target_fdr + 0.1, True)
  
file_path: statsmodels/statsmodels/stats/tests/test_knockoff.py
imports: import numpy
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  import pytest
  import statsmodels.api
  from statsmodels.stats import knockoff_regeffects
  from statsmodels.stats._knockoff import RegressionFDR, _design_knockoff_equi, _design_knockoff_sdp
label_desc: Use image node_id 4 for calling a global function with example usage: test_sim(method, tester, n, p, es) without return types