class_docstr: Test parametric.py.
class_docstr_tok: ["Test","parametric.py","."]
docstr: Test function rm_anova2.
  
  Compare with JAMOVI.
docstr_tok: ["Test","function","rm_anova2",".","Compare","with","JAMOVI","."]
code: def test_rm_anova2(self):
      """Test function rm_anova2.
  
      Compare with JAMOVI.
      """
      data = read_dataset("rm_anova2")
      aov = rm_anova(
          data=data,
          subject="Subject",
          within=["Time", "Metric"],
          dv="Performance",
      ).round(5)
      array_equal(aov.loc[:, "MS"], [828.81667, 682.61667, 112.21667])
      array_equal(aov.loc[:, "F"], [33.85228, 26.95919, 12.63227])
      array_equal(aov.loc[:, "ng2"], [0.25401, 0.35933, 0.08442])
      array_equal(aov.loc[:, "eps"], [1.0, 0.96910, 0.72717])
  
      # With categorical
      data_cat = data.copy()
      data_cat[["Subject", "Time", "Metric"]] = data_cat[
          ["Subject", "Time", "Metric"]
      ].astype("category")
      data_cat["Time"] = data_cat["Time"].cat.add_categories("Casper")
      aov = rm_anova(
          data=data_cat,
          subject="Subject",
          within=["Time", "Metric"],
          dv="Performance",
      ).round(5)
      array_equal(aov.loc[:, "MS"], [828.81667, 682.61667, 112.21667])
      array_equal(aov.loc[:, "F"], [33.85228, 26.95919, 12.63227])
      array_equal(aov.loc[:, "ng2"], [0.25401, 0.35933, 0.08442])
      array_equal(aov.loc[:, "eps"], [1.0, 0.96910, 0.72717])
  
      # With different effect sizes
      aov = rm_anova(
          data=data,
          subject="Subject",
          within=["Time", "Metric"],
          dv="Performance",
          effsize="n2",
      ).round(5)
      array_equal(aov.loc[:, "n2"], [0.17080, 0.28134, 0.04625])
  
      aov = rm_anova(
          data=data,
          subject="Subject",
          within=["Time", "Metric"],
          dv="Performance",
          effsize="np2",
      ).round(5)
      array_equal(aov.loc[:, "np2"], [0.78998, 0.74972, 0.58395])
  
      # 2 factors with missing values. Cannot compare with JASP directly
      # because Pingouin applies an automatic removal of missing values
      # (on the last factor). JASP uses a regression-based approach which
      # can handle missing values.
      df2 = read_dataset("rm_missing")
      df2.rm_anova(
          dv="BOLD", within=["Session", "Time"], subject="Subj"
      )
  
      # Error: more than two factors
      with pytest.raises(ValueError):
          df2.rm_anova(
              dv="BOLD",
              within=["Session", "Time", "Wrong"],
              subject="Subj",
          )
  
file_path: pingouin/pingouin/tests/test_parametric.py
imports: import pytest
  import numpy
  from unittest import TestCase
  from numpy.testing import assert_array_equal
  from pingouin import read_dataset
  from pingouin.parametric import ttest, anova, rm_anova, mixed_anova, ancova, welch_anova
label_desc: Use image node_id 5 for calling the TestParametric obj's underlying member method code with example usage: obj.test_rm_anova2() without return types