class_docstr: Test parametric.py.
class_docstr_tok: ["Test","parametric.py","."]
docstr: Test function rm_anova.
  
  Compare with JAMOVI. As of March 2022, the calculation of the eta-squared is wrong in JASP.
  
  https://github.com/raphaelvallat/pingouin/issues/251
docstr_tok: ["Test","function","rm_anova",".","Compare","with","JAMOVI",".","As","of","March","2022",",","the","calculation","of","the","eta-squared","is","wrong","in","JASP",".","https",":","\/\/github.com\/raphaelvallat\/pingouin\/issues\/251"]
code: def test_rm_anova(self):
      """Test function rm_anova.
  
      Compare with JAMOVI. As of March 2022, the calculation of the eta-squared is wrong in JASP.
  
      https://github.com/raphaelvallat/pingouin/issues/251
      """
      rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df,
          correction=False,
          detailed=False,
      )
      rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df,
          correction=True,
          detailed=False,
      )
      # Compare with JAMOVI
      aov = rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df,
          correction="auto",
          detailed=True,
      ).round(5)
      assert aov.at[0, "F"] == 3.91280
      assert aov.at[0, "p-unc"] == 0.02263
      assert aov.at[0, "ng2"] == 0.03998
  
      # Same but with categorical columns
      aov = rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df_cat,
          correction="auto",
          detailed=True,
      ).round(5)
      assert aov.at[0, "F"] == 3.91280
      assert aov.at[0, "p-unc"] == 0.02263
      assert aov.at[0, "ng2"] == 0.03998
  
      # With different effect sizes
      aov = rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df,
          correction="auto",
          effsize="n2",
      ).round(5)
      assert aov.at[0, "n2"] == 0.03998  # n2 == ng2
      aov = rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df,
          correction="auto",
          detailed=True,
          effsize="np2",
      ).round(5)
      assert aov.at[0, "np2"] == 0.06219
  
      rm_anova(
          dv="Scores",
          within="Time",
          subject="Subject",
          data=df,
          correction=True,
          detailed=True,
      )
      rm_anova(
          dv="Scores", within=["Time"], subject="Subject", data=df_nan
      )
  
      # Using a wide dataframe with NaN and compare with JAMOVI
      data = read_dataset("rm_anova_wide")
      aov = data.rm_anova(detailed=True, correction=True).round(5)
      assert aov.at[0, "F"] == 5.20065
      assert aov.at[0, "p-unc"] == 0.00656
      assert aov.at[0, "ng2"] == 0.34639
      assert aov.at[0, "eps"] == 0.69433
      assert aov.at[0, "W-spher"] == 0.30678
      assert aov.at[0, "p-GG-corr"] == 0.01670
      # With different effect sizes
      aov = data.rm_anova(
          detailed=True, correction=True, effsize="n2"
      ).round(5)
      assert aov.at[0, "n2"] == 0.34639  # n2 == ng2
      aov = data.rm_anova(
          detailed=True, correction=True, effsize="np2"
      ).round(5)
      assert aov.at[0, "np2"] == 0.39397
  
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 4 for calling the TestParametric obj's underlying member method code with example usage: obj.test_rm_anova() without return types