NAME

Statistics::ANOVA - Perform oneway analyses of variance

SYNOPSIS

use Statistics::ANOVA 0.04;
my $varo = Statistics::ANOVA->new();

# Some data:
my @gp1 = (qw/8 7 11 14 9/);
my @gp2 = (qw/11 9 8 11 13/);
my @gp3 = (qw/7 13 12 8 10/);

# Load the data (names can be arbitrary):
$varo->load_data({gp1 => \@gp1, gp2 => \@gp2});
# Oh, forgot one:
$varo->add_data(gp3 => \@gp3);

# If they are independent data, test equality of variances, difference between them, and means:
$varo->obrien_test()->dump(title => 'O\'Brien\'s test of equality of variances');
$varo->levene_test()->dump(title => 'Levene\'s test of equality of variances');
$varo->anova_indep()->dump(title => 'Independent groups ANOVA', eta_squared => 1, omega_squared => 1);
$varo->comparisons_indep();

# or if they are repeated measures:
$varo->anova_dep()->dump(title => 'Dependent groups ANOVA');
$varo->comparisons_dep();
# or:
$varo->anova_friedman()->dump(title => 'Friedman test');
# or 
$varo->anova_friedman(f_equiv => 1)->dump(title => 'Friedman test');

DESCRIPTION

Performs oneway between groups and repeated measures ANOVAs, with estimates of proportion of variance acounted for (eta-squared) and effect-size (omega-squared), plus pairwise comparisons by the relevant t-tests. Also performs equality of variances tests (O'Brien's, Levene's).

METHODS

new

Create a new Statistics::ANOVA object

load

$varo->load('aname', @data1)
$varo->load('aname', \@data1)
$varo->load({'aname' => \@data1, 'another_name' => \@data2})

Alias: load_data

Accepts either (1) a single name => value pair of a sample name, and a list (referenced or not) of data; or (2) a hash reference of named array references of data. The data are loaded into the class object by name, within a hash called data, as Statistics::Descriptive::Full objects. So you could get at the data again, for instance, by going $varo->{'data'}->{'data1'}->get_data(). The names of the data can be arbitrary. Each call unloads any previous loads.

Returns the Statistics::ANOVA object.

add

$varo->add('another_name', @data2)
$varo->add('another_name', \@data2)
$varo->add({'another_name' => \@data2})

Alias: add_data

Same as load except that any previous loads are not unloaded.

unload

$varo->unload();

Empties all cached data and calculations upon them, ensuring these will not be used for testing. This will be automatically called with each new load, but, to take care of any development, it could be good practice to call it yourself whenever switching from one dataset for testing to another.

anova_indep

$varo->anova_indep()

An implementation of a one-way between-groups analysis of variance. Feeds the class object $varo as follows:

$varo->{'f_value'}
$varo->{'df_t'} : the treatment or numerator or between-groups degree(s) of freedom
$varo->{'df_e'} : the error or denominator or within-groups degree(s) of freedom
$varo->{'p_value'} : associated with the F-value with the above dfs
$varo->{'ss_t'} : treatment sums of squares
$varo->{'ss_e'} : error sums of squares
$varo->{'ms_t'} : treatment mean squares
$varo->{'ms_e'} : error mean squares

anova_dep

$varo->anova_dep()

Alias: anova_rm

Performs a one-way repeated measures analysis of variance (sphericity assumed). See anova_indep for fed values.

anova_friedman

$varo->anova_friedman()

Alias: friedman_test

Performs Friedman's nonparametric analysis of variance - for two or more dependent (matched, related) groups. The statistical attributes now within the class object (see anova_indep) pertain to this test, e.g., $varo->{'chi_value'} gives the chi-square statistic from the Friedman test; and $varo->{'p_value'} gives the associated p-value (area under the right-side, upper tail). There is now no defined 'f_value'.

Accepts, however, one argument: If f_equiv => 1, then, instead of the chi_value, and p_value read off the chi-square distribution, you get the F-value equivalent, with the p-value read off the F-distribution.

See some other module for performing nonparametric pairwise comparisons.

obrien_test

Performs O'Brien's Test for equality of variances. The statistical attributes now within the class object (see anova_indep) pertain to this test, e.g., $varo->{'f_value'} gives the F-statistic for O'Brien's Test; and $varo->{'p_value'} gives the p-value associated with the F-statistic for O'Brien's Test.

levene_test

Performs Levene's (1960) Test for equality of variances. The statistical attributes now within the class object (see anova_indep) pertain to this test, e.g., $varo->{'f_value'} gives the F-statistic for Levene's Test; and $varo->{'p_value'} gives the p-value associated with the F-statistic for Levene's Test.

comparisons_indep

$varo->comparisons_indep(tails => 1|2, flag => 1|0 )

Performs independent samples t-tests for each pair of the loaded data, using Statistics::TTest. Simply prints the results to STDOUT. The p_value is 2-tailed, by default, unless otherwise specified, as above. The output strings are appended with an asterisk if the logical value of the optional attribute flag equals 1 and the p_value is less than the Bonferroni-adjusted alpha level. This alpha level, relative to alpha = .05, for the number of paired comparisons, is printed at the end of the list.

comparisons_dep

$varo->comparisons_dep(tails => 1|2, flag => 1|0 )

Performs dependent samples t-tests for each pair of the loaded data, using Statistics::DependantTTest. The number of observations must be equal for each of the data-sets tested. Simply prints the results to STDOUT. The p_value is 2-tailed, by default, unless otherwise specified, as above. The output strings are appended with an asterisk if the logical value of the optional attribute flag equals 1 and the p_value is less than the Bonferroni-adjusted alpha level. This alpha level, relative to alpha = .05, for the number of paired comparisons, is printed at the end of the list.

eta_squared

Returns eta-squared if an ANOVA has been performed; otherwise croaks. Also feeds $varo with the value, named 'eta_sq'. Values range from 0 to 1, 0 indicating no effect, 1 indicating difference between at least two DV means. Generally indicates the proportion of variance in the DV related to an effect.

omega_squared

Returns the effect size statistic omega-squared if an ANOVA has been performed; otherwise croaks. Also feeds $varo with the value, named 'omega_sq'. Generally, size is small where omega_sq = .01, medium if omega_sq = .059, and strong if omega_sq = .138.

string

$str = $varo->string(mse => 1, eta_squared => 1, omega_squared => 1)

Returns a statement of result, in the form of F(df_t, df_e) = f_value, p = p_value; or, for Friedman test chi^2(df_t) = chi_value, p = p_value. Optionally also get MSe, eta_squared and omega_squared values appended to the string, where relevant.

dump

$varo->dump(mse => 1, eta_squared => 1, omega_squared => 1, title => 'ANOVA test')

Prints the string returned by string. Optionally also get MSe, eta_squared and omega_squared values appended to the string. A newline - "\n" - is appended at the end of the print. Above this string, a title can also be printed, by giving a value to the optional title attribute.

EXPORT

None by default.

REFERENCES

None yet.

SEE ALSO

Math::Cephes Probabilities for all F-tests are computed using the fdtrc function in this, rather than the Statistics::Distributions module, as the former appears to be more accurate for indicating higher-level significances.

BUGS/LIMITATIONS

Computational bugs will hopefully be identified with usage over time.

Optimisation welcomed.

No adjustment for violations of sphericity in repeated measures ANOVA.

Print only of t-test results.

REVISION HISTORY

v 0.01

June 2008: Initital release via PAUSE.

See CHANGES in installation distribution for subsequent updates.

AUTHOR/LICENSE

rgarton@utas_DOT_edu_DOT_au

This program is free software. It may may be modified, used, copied, and redistributed at your own risk, and under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html). Publicly redistributed modified versions must use a different name.

Disclaimer

To the maximum extent permitted by applicable law, the author of this module disclaims all warranties, either express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with regard to the software and the accompanying documentation.