code: def test_rank_compare_2indep1():
      # Example from Munzel and Hauschke 2003
      # data is given by counts, expand to observations
      levels = [-2, -1, 0, 1, 2]
      new = [24, 37, 21, 19, 6]
      active = [11, 51, 22, 21, 7]
      x1 = np.repeat(levels, new)
      x2 = np.repeat(levels, active)
  
      # using lawstat
      # > brunner.munzel.test(xn, xa) #brunnermunzel.test(x, y)
      res2_t = Holder(
          statistic=1.1757561456582,
          df=204.2984239868,
          pvalue=0.2410606649547,
          ci=[0.4700629827705593, 0.6183882855872511],
          prob=0.5442256341789052,
      )
  
      res = rank_compare_2indep(x1, x2, use_t=False)
      assert_allclose(res.statistic, -res2_t.statistic, rtol=1e-13)
      assert_allclose(res.prob1, 1 - res2_t.prob, rtol=1e-13)
      assert_allclose(res.prob2, res2_t.prob, rtol=1e-13)
      tt = res.test_prob_superior()
      # TODO: return HolderTuple
      # assert_allclose(tt.statistic, res2_t.statistic)
      # TODO: check sign/direction in lawstat
      assert_allclose(tt[0], -res2_t.statistic, rtol=1e-13)
  
      ci = res.conf_int(alpha=0.05)
      # we compare normal confint with t confint, lower rtol
      assert_allclose(ci, 1 - np.array(res2_t.ci)[::-1], rtol=0.005)
      # test consistency of test and confint
      res_lb = res.test_prob_superior(value=ci[0])
      assert_allclose(res_lb[1], 0.05, rtol=1e-13)
      res_ub = res.test_prob_superior(value=ci[1])
      assert_allclose(res_ub[1], 0.05, rtol=1e-13)
  
      # test consistency of tost and confint
      # lower margin is binding, alternative larger
      res_tost = res.tost_prob_superior(ci[0], ci[1] * 1.05)
      assert_allclose(res_tost.results_larger.pvalue, 0.025, rtol=1e-13)
      assert_allclose(res_tost.pvalue, 0.025, rtol=1e-13)
  
      # upper margin is binding, alternative smaller
      res_tost = res.tost_prob_superior(ci[0] * 0.85, ci[1])
      assert_allclose(
          res_tost.results_smaller.pvalue, 0.025, rtol=1e-13
      )
      assert_allclose(res_tost.pvalue, 0.025, rtol=1e-13)
  
      # use t-distribution
      # our ranking is defined as reversed from lawstat, and BM article
      # revere direction to match our definition
      x1, x2 = x2, x1
      res = rank_compare_2indep(x1, x2, use_t=True)
      assert_allclose(res.statistic, res2_t.statistic, rtol=1e-13)
      tt = res.test_prob_superior()
      # TODO: return HolderTuple
      # assert_allclose(tt.statistic, res2_t.statistic)
      # TODO: check sign/direction in lawstat, reversed from ours
      assert_allclose(tt[0], res2_t.statistic, rtol=1e-13)
      assert_allclose(tt[1], res2_t.pvalue, rtol=1e-13)
      assert_allclose(res.pvalue, res2_t.pvalue, rtol=1e-13)
      assert_allclose(res.df, res2_t.df, rtol=1e-13)
  
      ci = res.conf_int(alpha=0.05)
      assert_allclose(ci, res2_t.ci, rtol=1e-11)
      # test consistency of test and confint
      res_lb = res.test_prob_superior(value=ci[0])
      assert_allclose(res_lb[1], 0.05, rtol=1e-11)
      res_ub = res.test_prob_superior(value=ci[1])
      assert_allclose(res_ub[1], 0.05, rtol=1e-11)
  
      # test consistency of tost and confint
      # lower margin is binding, alternative larger
      res_tost = res.tost_prob_superior(ci[0], ci[1] * 1.05)
      assert_allclose(res_tost.results_larger.pvalue, 0.025, rtol=1e-10)
      assert_allclose(res_tost.pvalue, 0.025, rtol=1e-10)
  
      # upper margin is binding, alternative smaller
      res_tost = res.tost_prob_superior(ci[0] * 0.85, ci[1])
      assert_allclose(
          res_tost.results_smaller.pvalue, 0.025, rtol=1e-10
      )
      assert_allclose(res_tost.pvalue, 0.025, rtol=1e-10)
  
      # extras
      # cohen's d
      esd = res.effectsize_normal()
      p = prob_larger_continuous(stats.norm(loc=esd), stats.norm)
      # round trip
      assert_allclose(p, res.prob1, rtol=1e-13)
  
      # round trip with cohen's d
      pc = cohensd2problarger(esd)
      assert_allclose(pc, res.prob1, rtol=1e-13)
  
      ci_tr = res.confint_lintransf(1, -1)
      assert_allclose(ci_tr, 1 - np.array(res2_t.ci)[::-1], rtol=0.005)
  
imports: from statsmodels.compat.python import lzip
  import numpy
  from numpy.testing import assert_allclose, assert_almost_equal, assert_approx_equal, assert_
  from scipy import stats
  import pytest
  from statsmodels.stats.contingency_tables import mcnemar, cochrans_q, SquareTable
  from statsmodels.sandbox.stats.runs import Runs, runstest_1samp, runstest_2samp
  from statsmodels.sandbox.stats.runs import mcnemar
  from statsmodels.stats.nonparametric import rank_compare_2indep, rank_compare_2ordinal, prob_larger_continuous, cohensd2problarger
  from statsmodels.tools.testing import Holder
label_desc: Use image node_id 13 for calling a global function with example usage: test_rank_compare_2indep1() without return types