class_docstr: Test effsize.py.
docstr: Test function compute_effsize
docstr_tok: ["Test","function","compute_effsize"]
code: def test_compute_effsize(self):
      """Test function compute_effsize"""
      compute_effsize(x=x, y=y, eftype="cohen", paired=False)
      compute_effsize(x=x, y=y, eftype="AUC", paired=True)
      compute_effsize(x=x, y=y, eftype="r", paired=False)
      compute_effsize(x=x, y=y, eftype="odds-ratio", paired=False)
      compute_effsize(x=x, y=y, eftype="eta-square", paired=False)
      compute_effsize(x=x, y=y, eftype="cles", paired=False)
      compute_effsize(x=x, y=y, eftype="pointbiserialr", paired=False)
      compute_effsize(x=x, y=y, eftype="none", paired=False)
      # Unequal variances
      z = np.random.normal(2.5, 3, 30)
      compute_effsize(x=x, y=z, eftype="cohen")
      # Wrong effect size type
      with pytest.raises(ValueError):
          compute_effsize(x=x, y=y, eftype="wrong")
      # Unequal sample size with paired == True
      z = np.random.normal(2.5, 3, 25)
      compute_effsize(x=x, y=z, paired=True)
      # Compare with the effsize R package
      a = [3.2, 6.4, 1.8, 2.4, 5.8, 6.5]
      b = [2.4, 3.2, 3.2, 1.4, 2.8, 3.5]
      d = compute_effsize(x=a, y=b, eftype="cohen", paired=False)
      assert np.isclose(d, 1.002549)
      # Note that ci are different than from R because we use a normal and
      # not a T distribution to estimate the CI.
      # Also, for paired samples, effsize does not return the Cohen d-avg.
      # ci = compute_esci(ef=d, nx=na, ny=nb)
      # assert ci[0] == -.2
      # assert ci[1] == 2.2
      # With Hedges correction
      g = compute_effsize(x=a, y=b, eftype="hedges", paired=False)
      assert np.isclose(g, 0.9254296)
      # CLES
      # Compare to
      # https://janhove.github.io/reporting/2016/11/16/common-language-effect-sizes
      x2 = [20, 22, 19, 20, 22, 18, 24, 20, 19, 24, 26, 13]
      y2 = [38, 37, 33, 29, 14, 12, 20, 22, 17, 25, 26, 16]
      cl = compute_effsize(x=x2, y=y2, eftype="cles")
      assert np.isclose(cl, 0.3958333)
      assert np.isclose(
          (1 - cl), compute_effsize(x=y2, y=x2, eftype="cles")
      )
  
file_path: pingouin/pingouin/tests/test_effsize.py
imports: import pytest
  import numpy
  import pandas
  from unittest import TestCase
  from scipy.stats import pearsonr, pointbiserialr
  from pingouin.effsize import compute_esci, compute_effsize, compute_effsize_from_t, compute_bootci
  from pingouin.effsize import convert_effsize
label_desc: Use image node_id 4 for calling the TestEffsize obj's underlying member method code with example usage: obj.test_compute_effsize() without return types