class_docstr: Test effsize.py.
docstr: Test function convert_effsize.
  
  Compare to https://www.psychometrica.de/effect_size.html
docstr_tok: ["Test","function","convert_effsize",".","Compare","to","https",":","\/\/www.psychometrica.de\/effect_size.html"]
code: def test_convert_effsize(self):
      """Test function convert_effsize.
  
      Compare to https://www.psychometrica.de/effect_size.html
      """
      # Cohen d
      d = 0.40
      assert cef(d, "cohen", "none") == d
      assert round(cef(d, "cohen", "pointbiserialr"), 4) == 0.1961
      cef(
          d, "cohen", "pointbiserialr", nx=10, ny=12
      )  # When nx and ny are specified
      assert np.allclose(
          cef(1.002549, "cohen", "pointbiserialr"), 0.4481248
      )  # R
      assert round(cef(d, "cohen", "eta-square"), 4) == 0.0385
      assert round(cef(d, "cohen", "odds-ratio"), 4) == 2.0658
      cef(d, "cohen", "hedges", nx=10, ny=10)
      cef(d, "cohen", "pointbiserialr")
      cef(d, "cohen", "hedges")
  
      # Point-biserial correlation
      rpb = 0.65
      assert cef(rpb, "pointbiserialr", "none") == rpb
      assert round(cef(rpb, "pointbiserialr", "cohen"), 4) == 1.7107
      assert np.allclose(
          cef(0.4481248, "pointbiserialr", "cohen"), 1.002549
      )
      assert (
          round(cef(rpb, "pointbiserialr", "eta-square"), 4) == 0.4225
      )
      assert (
          round(cef(rpb, "pointbiserialr", "odds-ratio"), 4) == 22.2606
      )
      # Using actual values
      np.random.seed(42)
      x1, y1 = np.random.multivariate_normal(
          mean=[1, 2], cov=[[1, 0.5], [0.5, 1]], size=100
      ).T
      xy1 = np.hstack((x1, y1))
      xy1_bool = np.repeat([0, 1], 100)
      # Let's calculate the ground-truth point-biserial correlation
      r_biserial = pearsonr(xy1_bool, xy1)[0]  # 0.50247
      assert np.isclose(r_biserial, pointbiserialr(xy1_bool, xy1)[0])
      # Now the Cohen's d
      d = abs(
          compute_effsize(x1, y1, paired=True, eftype="cohen")
      )  # 1.15651
      # And now we can convert point-biserial r <--> d
      r_convert = cef(
          abs(d), "cohen", "pointbiserialr", nx=100, ny=100
      )  # 0.50247
      assert np.isclose(r_convert, r_biserial)
      d_convert = cef(
          r_biserial, "pointbiserialr", "cohen", nx=100, ny=100
      )  # 1.162
      assert abs(d - d_convert) < 0.1
  
      # Error
      with pytest.raises(ValueError):
          # DEPRECATED - https://github.com/raphaelvallat/pingouin/issues/302
          cef(d, "cohen", "r")
      with pytest.raises(ValueError):
          cef(d, "coucou", "hibou")
      with pytest.raises(ValueError):
          cef(d, "AUC", "eta-square")
  
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 3 for calling the TestEffsize obj's underlying member method code with example usage: obj.test_convert_effsize() without return types