code: def test_equivalence_2indep():
      # this checks the pvalue of the equivalence test at value equal to the
      # confidence limit
      alpha = 0.05
      count1, nobs1 = 7, 34
      count2, nobs2 = 1, 34
      count1v, nobs1v = [7, 1], 34
      count2v, nobs2v = [1, 7], 34
  
      methods_both = [
          ("diff", "agresti-caffo"),
          # ('diff', 'newcomb'),  # only confint
          ("diff", "score"),
          ("diff", "wald"),
          ("ratio", "log"),
          ("ratio", "log-adjusted"),
          ("ratio", "score"),
          ("odds-ratio", "logit"),
          ("odds-ratio", "logit-adjusted"),
          ("odds-ratio", "logit-smoothed"),
          ("odds-ratio", "score"),
      ]
  
      for co, method in methods_both:
          low, upp = confint_proportions_2indep(
              count1,
              nobs1,
              count2,
              nobs2,
              compare=co,
              method=method,
              alpha=2 * alpha,
              correction=False,
          )
  
          # Note: test should have only one margin at confint
          res = smprop.tost_proportions_2indep(
              count1,
              nobs1,
              count2,
              nobs2,
              low,
              upp * 1.05,
              compare=co,
              method=method,
              correction=False,
          )
          assert_allclose(res.pvalue, alpha, atol=1e-10)
  
          res = smprop.tost_proportions_2indep(
              count1,
              nobs1,
              count2,
              nobs2,
              low * 0.95,
              upp,
              compare=co,
              method=method,
              correction=False,
          )
          assert_allclose(res.pvalue, alpha, atol=1e-10)
  
          # vectorized
          if method == "logit-smoothed":
              # not correctly vectorized
              return
          res1 = res  # for debugging  # noqa
          res = smprop.tost_proportions_2indep(
              count1v,
              nobs1v,
              count2v,
              nobs2v,
              low * 0.95,
              upp,
              compare=co,
              method=method,
              correction=False,
          )
          assert_allclose(res.pvalue[0], alpha, atol=1e-10)
  
imports: import warnings
  import numpy
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_less, assert_equal, assert_raises
  import pandas
  import pytest
  import statsmodels.stats.proportion
  from statsmodels.stats.proportion import confint_proportions_2indep, multinomial_proportions_confint, power_proportions_2indep, proportion_confint, samplesize_proportions_2indep_onetail, score_test_proportions_2indep
  from statsmodels.tools.sm_exceptions import HypothesisTestWarning
  from statsmodels.tools.testing import Holder
  from statsmodels.stats.tests.results.results_proportion import res_binom, res_binom_methods
label_desc: Use image node_id 20 for calling a global function with example usage: test_equivalence_2indep() without return types