class_docstr: Test effsize.py.
docstr: Test function compute_esci.
  
  Note that since Pingouin v0.3.5, CIs around a Cohen d are calculated
  using a T (and not Z) distribution. This is the same behavior as the
  cohen.d function of the effsize R package.
  
  However, note that the cohen.d function does not use the Cohen d-avg
  for paired samples, and therefore we cannot directly compare the CIs
  for paired samples. Similarly, R uses a slightly different formula to
  estimate the SE of one-sample cohen D.
docstr_tok: ["Test","function","compute_esci",".","Note","that","since","Pingouin","v0.3.5",",","CIs","around","a","Cohen","d","are","calculated","using","a","T","(","and","not","Z",")","distribution",".","This","is","the","same","behavior","as","the","cohen.d","function","of","the","effsize","R","package",".","However",",","note","that","the","cohen.d","function","does","not","use","the","Cohen","d-avg","for","paired","samples",",","and","therefore","we","can","not","directly","compare","the","CIs","for","paired","samples",".","Similarly",",","R","uses","a","slightly","different","formula","to","estimate","the","SE","of","one-sample","cohen","D","."]
code: def test_compute_esci(self):
      """Test function compute_esci.
  
      Note that since Pingouin v0.3.5, CIs around a Cohen d are calculated
      using a T (and not Z) distribution. This is the same behavior as the
      cohen.d function of the effsize R package.
  
      However, note that the cohen.d function does not use the Cohen d-avg
      for paired samples, and therefore we cannot directly compare the CIs
      for paired samples. Similarly, R uses a slightly different formula to
      estimate the SE of one-sample cohen D.
      """
      # Pearson correlation
      # https://github.com/SurajGupta/r-source/blob/master/src/library/stats/R/cor.test.R
      ci = compute_esci(stat=0.5543563, nx=6, eftype="r", decimals=6)
      assert np.allclose(ci, [-0.4675554, 0.9420809])
      # Alternative == "greater"
      ci = compute_esci(
          stat=0.8, nx=20, eftype="r", alternative="greater", decimals=6
      )
      assert np.allclose(ci, [0.6041625, 1])
      ci = compute_esci(
          stat=-0.2,
          nx=30,
          eftype="r",
          alternative="greater",
          decimals=6,
      )
      assert np.allclose(ci, [-0.4771478, 1])
      # Alternative == "less"
      ci = compute_esci(
          stat=-0.8, nx=20, eftype="r", alternative="less", decimals=6
      )
      assert np.allclose(ci, [-1, -0.6041625])
      ci = compute_esci(
          stat=0.2, nx=30, eftype="r", alternative="less", decimals=6
      )
      assert np.allclose(ci, [-1, 0.4771478])
  
      # Cohen d
      # .. One sample and paired
      # Cannot compare to R because cohen.d uses different formulas for
      # Cohen d and SE.
      d = compute_effsize(np.r_[x, y], y=0)
      assert round(d, 6) == 2.086694  # Same as cohen.d
      ci = compute_esci(d, nx + ny, 1, decimals=6)
      d = compute_effsize(x, y, paired=True)
      ci = compute_esci(d, nx, ny, paired=True, decimals=6)
      # .. Independent (compare with cohen.d function)
      d = compute_effsize(x, y)
      ci = compute_esci(d, nx, ny, decimals=6)
      np.testing.assert_equal(ci, [-1.067645, 0.226762])
      # Same but with different n
      d = compute_effsize(x, y[:-5])
      ci = compute_esci(d, nx, len(y[:-5]), decimals=8)
      np.testing.assert_equal(ci, [-1.33603010, 0.08662825])
  
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 1 for calling the TestEffsize obj's underlying member method code with example usage: obj.test_compute_esci() without return types