Statistics::ANOVA::Friedman - Nonparametric repeated measures analysis of variance for dependent factorial measures (Friedman Test)


This is documentation for version 0.02, released February 2017.


 use Statistics::ANOVA::Friedman;
 my $fri = Statistics::ANOVA::Friedman->new();
 my ($chi_value, $df, $count, $p_value) = $fri->chiprob_test(data => HOA);
 $fri->load({1 => [2, 4, 6], 2 => [3, 3, 12], 3 => [5, 7, 11]}); # or pre-load with HOA
 ($chi_value, $df, $count, $p_value) = $fri->chiprob_test();
 my ($f_value, $df_b, $df_w, $p_value2) = $fri->fprob_test();


Performs the Friedman nonparametric analysis of variance - for dependent (correlated, matched) measures of two or more discrete (nominal) variables, such as when the measures are taken from the same source (e.g., person, plot) but under different conditions. A ranking procedure is used, but, unlike the case for independent measures, the ranks are taken at each common index of each measure, i.e., within-groups.

By default, the method accounts for and corrects for ties, but if correct_ties => 0, the test-statistic is uncorrected. The correction involves accounting for the number of tied variables at each index, as per Hollander & Wolfe (1995), Eq. 7.8, p. 274.

Correctness of output is tested on installation using example data from Hollander & Wolfe (1999, p. 274ff), Rice (1995, p. 470), Sarantakos (1993, p. 404-405), and Siegal (1956, p. 167ff); tests fail if the published chi-values and degrees-of-freedom are not returned by the module.

The module uses Statistics::Data as a base so that data can be pre-loaded and added to per that module's methods.



 $fri = Statistics::ANOVA::Friedman->new();

New object for accessing methods and storing results. This "isa" Statistics::Data object.

load, add, unload

 $fri->load('a' => [1, 4], 'b' => [3, 7]);

The given data can now be used by any of the following methods. This is inherited from Statistics::Data, and all its other methods are available here via the class object. Only passing of data as a hash of arrays (HOA) is supported for now. Alternatively, give each of the following methods the HOA for the optional named argument data.


 ($chi_value, $df, $count, $p_value) = $fri->chiprob_test(data => HOA, correct_ties => 1);

Performs the ANOVA and returns the chi-square value, its degrees-of-freedom, the total number of observations, and associated probability value (or only the latter if called in scalar context). Default value of optional argument correct_ties is 1.


 $str = $fri->chiprob_str(data => HOA, correct_ties => 1);

Performs the same test as for chiprob_test but returns not an array but a string of the conventional reporting form, e.g., chi^2(df, N = total observations) = chi_value, p = p_value.


 ($f_value, $df_b, $df_w, $p_value) = $fri->fprob_test(data => HOA);
 $p_value = $fri->fprob_test(data => HOA);

Performs the same test as above but transforms the chi-value into an F-distributed value, returning this F-equivalent value, between and within groups degrees-of-freedom, and then the associated probability off the F-distribution (or only the latter if called in scalar context). Default value of optional argument correct_ties is 1. This method has not been tested against sample data as yet.


 $str = $fri->chiprob_str(data => HOA, correct_ties => 1);

Performs the same test as for fprob_test but returns not an array but a string of the conventional reporting form, e.g., F(df_b, df_w) = f_value, p = p_value.


List::AllUtils : used for summing.

Math::Cephes : used for probability functions.

Statistics::Data : used as base.

Statistics::Data::Rank : used to calculate the dependent sum-square of ranks. See this module for retrieving the actual arrays of ranks and sum-squares.


Need to have equal numbers of observations greater than 1 per two or variables for chiprob_test

croaked if there are not equal numbers of numerical values in each given variable, and if there are not at least two variables. Similarly for fprob_test.


Hollander, M., & Wolfe, D. A. (1999). Nonparametric statistical methods. New York, NY, US: Wiley.

Rice, J. A. (1995). Mathematical statistics and data analysis. Belmont, CA, US: Duxbury.

Sarantakos, S. (1993). Social research. Melbourne, Australia: MacMillan.

Siegal, S. (1956). Nonparametric statistics for the behavioral sciences. New York, NY, US: McGraw-Hill


Roderick Garton, <rgarton at>


Please report any bugs or feature requests to bug-statistics-anova-friedman-0.02 at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Statistics::ANOVA::Friedman

You can also look for information at:


Copyright 2015-2017 Roderick Garton.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.