pingouin.rm_anova

pingouin.
rm_anova
(data=None, dv=None, within=None, subject=None, correction='auto', detailed=False, export_filename=None)[source] Oneway and twoway repeated measures ANOVA.
 Parameters
 data
pandas.DataFrame
DataFrame. Note that this function can also directly be used as a
pandas.DataFrame
method, in which case this argument is no longer needed. Both wide and longformat dataframe are supported for oneway repeated measures ANOVA. However,data
must be in long format for twoway repeated measures. dvstring
Name of column containing the dependant variable (only required if
data
is in long format). withinstring
Name of column containing the within factor (only required if
data
is in long format). Ifwithin
is a single string, then compute a oneway repeated measures ANOVA, ifwithin
is a list with two strings, compute a twoway repeated measures ANOVA. subjectstring
Name of column containing the subject identifier (only required if
data
is in long format). correctionstring or boolean
If True, also return the GreenhouseGeisser corrected pvalue.
The default for oneway design is to compute Mauchly’s test of sphericity to determine whether the pvalues needs to be corrected (see
pingouin.sphericity()
).The default for twoway design is to return both the uncorrected and GreenhouseGeisser corrected pvalues. Note that sphericity test for twoway design are not currently implemented in Pingouin.
 detailedboolean
If True, return a full ANOVA table.
 export_filenamestring
Filename (without extension) for the output file. If None, do not export the table. By default, the file will be created in the current python console directory. To change that, specify the filename with full path.
 data
 Returns
 aovDataFrame
ANOVA summary
'Source' : Name of the withingroup factor 'ddof1' : Degrees of freedom (numerator) 'ddof2' : Degrees of freedom (denominator) 'F' : Fvalue 'punc' : Uncorrected pvalue 'np2' : Partial etasquare effect size 'eps' : GreenhouseGeisser epsilon factor (= index of sphericity) 'pGGcorr' : GreenhouseGeisser corrected pvalue 'Wspher' : Sphericity test statistic 'pspher' : pvalue of the sphericity test 'sphericity' : sphericity of the data (boolean)
See also
anova
Oneway and Nway ANOVA
mixed_anova
Two way mixed ANOVA
friedman
Nonparametric oneway repeated measures ANOVA
Notes
Data can be in wide or long format for oneway repeated measures ANOVA but must be in long format for twoway repeated measures ANOVA.
In oneway repeatedmeasures ANOVA, the total variance (sums of squares) is divided into three components
\[SS_{total} = SS_{treatment} + (SS_{subjects} + SS_{error})\]with
\[SS_{total} = \sum_i^r \sum_j^n (Y_{ij}  \overline{Y})^2\]\[SS_{treatment} = \sum_i^r n_i(\overline{Y_i}  \overline{Y})^2\]\[SS_{subjects} = r\sum (\overline{Y}_s  \overline{Y})^2\]\[SS_{error} = SS_{total}  SS_{treatment}  SS_{subjects}\]where \(i=1,...,r; j=1,...,n_i\), \(r\) is the number of conditions, \(n_i\) the number of observations for each condition, \(\overline{Y}\) the grand mean of the data, \(\overline{Y_i}\) the mean of the \(i^{th}\) condition and \(\overline{Y}_{subj}\) the mean of the \(s^{th}\) subject.
The Fstatistics is then defined as:
\[F^* = \frac{MS_{treatment}}{MS_{error}} = \frac{\frac{SS_{treatment}} {r1}}{\frac{SS_{error}}{(n  1)(r  1)}}\]and the pvalue can be calculated using a Fdistribution with \(v_{treatment} = r  1\) and \(v_{error} = (n  1)(r  1)\) degrees of freedom.
The effect size reported in Pingouin is the partial etasquare, which is equivalent to etasquare for oneway repeated measures ANOVA.
\[\eta_p^2 = \frac{SS_{treatment}}{SS_{treatment} + SS_{error}}\]Results have been tested against R and JASP. Note however that if the dataset contains one or more other within subject factors, an automatic collapsing to the mean is applied on the dependant variable (same behavior as the ezANOVA R package). As such, results can differ from those of JASP.
Missing values are automatically removed (listwise deletion) using the
pingouin.remove_rm_na()
function. This could drastically decrease the power of the ANOVA if many missing values are present. In that case, it might be better to use linear mixed effects models.Warning
The epsilon adjustement factor of the interaction in twoway repeated measures ANOVA where both factors have more than two levels slightly differs than from R and JASP. Please always make sure to doublecheck your results with another software.
Warning
Sphericity tests for the interaction term of a twoway repeated measures ANOVA are not currently supported in Pingouin. Instead, please refer to the GreenhouseGeisser epsilon value (a value close to 1 indicates that sphericity is met.) For more details, see
pingouin.sphericity()
.References
 1
Bakeman, R. (2005). Recommended effect size statistics for repeated measures designs. Behavior research methods, 37(3), 379384.
 2
Richardson, J. T. (2011). Eta squared and partial eta squared as measures of effect size in educational research. Educational Research Review, 6(2), 135147.
 3
Examples
Oneway repeated measures ANOVA using a wideformat dataset
>>> import pingouin as pg >>> data = pg.read_dataset('rm_anova_wide') >>> pg.rm_anova(data) Source ddof1 ddof2 F punc np2 eps 0 Within 3 24 5.201 0.006557 0.394 0.694
Oneway repeatedmeasures ANOVA using a longformat dataset
>>> df = pg.read_dataset('rm_anova') >>> aov = pg.rm_anova(dv='DesireToKill', within='Disgustingness', ... subject='Subject', data=df, detailed=True) >>> print(aov) Source SS DF MS F punc np2 eps 0 Disgustingness 27.485 1 27.485 12.044 0.000793016 0.116 1 1 Error 209.952 92 2.282    
Twoway repeatedmeasures ANOVA
>>> aov = pg.rm_anova(dv='DesireToKill', ... within=['Disgustingness', 'Frighteningness'], ... subject='Subject', data=df)
As a
pandas.DataFrame
method>>> df.rm_anova(dv='DesireToKill', within='Disgustingness', ... subject='Subject', detailed=True) Source SS DF MS F punc np2 eps 0 Disgustingness 27.485 1 27.485 12.044 0.000793016 0.116 1 1 Error 209.952 92 2.282    