class_docstr: Test parametric.py.
class_docstr_tok: ["Test","parametric.py","."]
docstr: Test function ancovan.
  Compare with JASP.
docstr_tok: ["Test","function","ancovan",".","Compare","with","JASP","."]
code: def test_ancova(self):
      """Test function ancovan.
      Compare with JASP.
      """
      df = read_dataset("ancova")
      # With one covariate, balanced design, no missing values
      aov = ancova(
          data=df, dv="Scores", covar="Income", between="Method"
      ).round(4)
      array_equal(aov["DF"], [3, 1, 31])
      array_equal(aov["F"], [3.3365, 29.4194, np.nan])
      array_equal(aov["p-unc"], [0.0319, 0.000, np.nan])
      array_equal(aov["np2"], [0.2441, 0.4869, np.nan])
      aov = ancova(
          data=df,
          dv="Scores",
          covar="Income",
          between="Method",
          effsize="n2",
      ).round(4)
      array_equal(aov["n2"], [0.1421, 0.4177, np.nan])
      # With one covariate, missing values and unbalanced design
      df.loc[[1, 2], "Scores"] = np.nan
      aov = ancova(
          data=df, dv="Scores", covar=["Income"], between="Method"
      ).round(4)
      array_equal(aov["DF"], [3, 1, 29])
      array_equal(aov["F"], [3.1471, 19.7811, np.nan])
      array_equal(aov["p-unc"], [0.0400, 0.0001, np.nan])
      array_equal(aov["np2"], [0.2456, 0.4055, np.nan])
      # With two covariates, missing values and unbalanced design
      aov = ancova(
          data=df,
          dv="Scores",
          covar=["Income", "BMI"],
          between="Method",
      ).round(4)
      array_equal(aov["DF"], [3, 1, 1, 28])
      array_equal(aov["F"], [3.0186, 19.6045, 1.2279, np.nan])
      array_equal(aov["p-unc"], [0.0464, 0.0001, 0.2772, np.nan])
      array_equal(aov["np2"], [0.2444, 0.4118, 0.0420, np.nan])
      # Same but using standard eta-squared
      aov = ancova(
          data=df,
          dv="Scores",
          covar=["Income", "BMI"],
          between="Method",
          effsize="n2",
      ).round(4)
      array_equal(aov["n2"], [0.1564, 0.3387, 0.0212, np.nan])
      # Other parameters
      ancova(
          data=df,
          dv="Scores",
          covar=["Income", "BMI"],
          between="Method",
      )
      ancova(data=df, dv="Scores", covar=["Income"], between="Method")
  
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 7 for calling the TestParametric obj's underlying member method code with example usage: obj.test_ancova() without return types