pingouin.mixed_anova¶

pingouin.
mixed_anova
(data=None, dv=None, within=None, subject=None, between=None, correction='auto', effsize='np2')¶ Mixeddesign (splitplot) ANOVA.
 Parameters
 data
pandas.DataFrame
DataFrame. Note that this function can also directly be used as a Pandas method, in which case this argument is no longer needed.
 dvstring
Name of column containing the dependent variable.
 withinstring
Name of column containing the withinsubject factor (repeated measurements).
 subjectstring
Name of column containing the betweensubject identifier.
 betweenstring
Name of column containing the between factor.
 correctionstring or boolean
If True, return GreenhouseGeisser corrected pvalue. If ‘auto’ (default), compute Mauchly’s test of sphericity to determine whether the pvalues needs to be corrected.
 effsizestr
Effect size. Must be one of ‘np2’ (partial etasquared), ‘n2’ (etasquared) or ‘ng2’(generalized etasquared).
 data
 Returns
 aov
pandas.DataFrame
ANOVA summary:
'Source'
: Names of the factor considered'ddof1'
: Degrees of freedom (numerator)'ddof2'
: Degrees of freedom (denominator)'F'
: Fvalues'punc'
: Uncorrected pvalues'np2'
: Partial etasquared effect sizes'eps'
: GreenhouseGeisser epsilon factor (= index of sphericity)'pGGcorr'
: GreenhouseGeisser corrected pvalues'Wspher'
: Sphericity test statistic'pspher'
: pvalue of the sphericity test'sphericity'
: sphericity of the data (boolean)
 aov
See also
Notes
Data are expected to be in longformat (even the repeated measures). If your data is in wideformat, you can use the
pandas.melt()
function to convert from wide to long format.Missing values are automatically removed using a strict listwise approach (= completecase analysis). In other words, any subject with one or more missing value(s) is completely removed from the dataframe prior to running the test. This could drastically decrease the power of the ANOVA if many missing values are present. In that case, we strongly recommend using linear mixed effect modelling, which can handle missing values in repeated measures.
Warning
If the betweensubject groups are unbalanced (= unequal sample sizes), a type II ANOVA will be computed. Note however that SPSS, JAMOVI and JASP by default return a type III ANOVA, which may lead to slightly different results.
Examples
For more examples, please refer to the Jupyter notebooks
Compute a twoway mixed model ANOVA.
>>> from pingouin import mixed_anova, read_dataset >>> df = read_dataset('mixed_anova') >>> aov = mixed_anova(dv='Scores', between='Group', ... within='Time', subject='Subject', data=df) >>> aov.round(3) Source SS DF1 DF2 MS F punc np2 eps 0 Group 5.460 1 58 5.460 5.052 0.028 0.080 NaN 1 Time 7.628 2 116 3.814 4.027 0.020 0.065 0.999 2 Interaction 5.167 2 116 2.584 2.728 0.070 0.045 NaN
Same but reporting a generalized etasquared effect size. Notice how we can also apply this function directly as a method of the dataframe, in which case we do not need to specify
data=df
anymore.>>> df.mixed_anova(dv='Scores', between='Group', within='Time', ... subject='Subject', effsize="ng2").round(3) Source SS DF1 DF2 MS F punc ng2 eps 0 Group 5.460 1 58 5.460 5.052 0.028 0.031 NaN 1 Time 7.628 2 116 3.814 4.027 0.020 0.042 0.999 2 Interaction 5.167 2 116 2.584 2.728 0.070 0.029 NaN