pingouin.friedman

pingouin.
friedman
(data=None, dv=None, within=None, subject=None, method='chisq')[source] Friedman test for repeated measurements.
 Parameters
 data
pandas.DataFrame
DataFrame
 dvstring
Name of column containing the dependent variable.
 withinstring
Name of column containing the withinsubject factor.
 subjectstring
Name of column containing the subject identifier.
 methodstring
Statistical test to perform. Must be
'chisq'
(chisquare test) or'f'
(F test). See notes below for explanation.
 data
 Returns
 stats
pandas.DataFrame
'W'
: Kendall’s coefficient of concordance, corrected for ties
If
method='chisq'
'Q'
: The Friedman chisquare statistic, corrected for ties'dof'
: degrees of freedom'punc'
: Uncorrected pvalue of the chi squared test
If
method='f'
'F'
: The Friedman F statistic, corrected for ties'dof1'
: degrees of freedom of the numerator'dof2'
: degrees of freedom of the denominator'punc'
: Uncorrected pvalue of the F test
 stats
Notes
The Friedman test is used for oneway repeated measures ANOVA by ranks.
Data are expected to be in longformat.
Note that if the dataset contains one or more other within subject factors, an automatic collapsing to the mean is applied on the dependent variable (same behavior as the ezANOVA R package). As such, results can differ from those of JASP. If you can, always doublecheck the results.
NaN values are automatically removed.
The Friedman test is equivalent to the test of significance of Kendalls’s coefficient of concordance (Kendall’s W). Most commonly a Q statistic, which has asymptotical chisquared distribution, is computed and used for testing. However, in [1] they showed the chisquared test to be overly conservative for small numbers of samples and repeated measures. Instead they recommend the F test, which has the correct size and behaves like a permutation test, but is computationaly much easier.
References
 1
Marozzi, M. (2014). Testing for concordance between several criteria. Journal of Statistical Computation and Simulation, 84(9), 1843–1850. https://doi.org/10.1080/00949655.2013.766189
Examples
Compute the Friedman test for repeated measurements.
>>> from pingouin import friedman, read_dataset >>> df = read_dataset('rm_anova') >>> friedman(data=df, dv='DesireToKill', within='Disgustingness', ... subject='Subject') Source W ddof1 Q punc Friedman Disgustingness 0.099224 1 9.227848 0.002384
This time we will use the F test method.
>>> from pingouin import friedman, read_dataset >>> df = read_dataset('rm_anova') >>> friedman(data=df, dv='DesireToKill', within='Disgustingness', ... subject='Subject', method='f') Source W ddof1 ddof2 F punc Friedman Disgustingness 0.099224 0.978495 90.021505 10.13418 0.002138
We can see, compared to the previous example, that the pvalue is slightly lower. This is expected, since the F test is more powerful (see Notes).