| 1 | package Statistics::ANOVA::EffectSize; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 6 | ▶ | use base qw(Statistics::Data); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 6 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 6 | ▶ | use List::AllUtils qw(any); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 6 | $Statistics::ANOVA::EffectSize::VERSION = '0.02'; | |||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Statistics::ANOVA::EffectSize - Calculate effect-sizes from ANOVAs incl. eta-squared and omega-squared | ||||||||||
| 14 | |||||||||||
| 15 | =head1 VERSION | ||||||||||
| 16 | |||||||||||
| 17 | This is documentation for B<Version 0.02> of Statistics::ANOVA::EffectSize. | ||||||||||
| 18 | |||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||
| 20 | |||||||||||
| 21 | use Statistics::ANOVA::EffectSize; | ||||||||||
| 22 | my $es = Statistics::ANOVA::EffectSize->new(); | ||||||||||
| 23 | $es->load(HOA); # a hash of arefs, or other, as in Statistics::Data | ||||||||||
| 24 | my $etasq = $es->eta_squared(independent => BOOL, partial => 1); # or give data => HOA here | ||||||||||
| 25 | my $omgsq = $es->omega_squared(independent => BOOL); | ||||||||||
| 26 | # or calculate not from loaded data but directly: | ||||||||||
| 27 | |||||||||||
| 28 | =head2 DESCRIPTION | ||||||||||
| 29 | |||||||||||
| 30 | Calculates effect-sizes from ANOVAs. | ||||||||||
| 31 | |||||||||||
| 32 | For I<eta>-squared, 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. | ||||||||||
| 33 | |||||||||||
| 34 | For I<omega>-squared, size is conventionally described as small where omega_sq = .01, medium if omega_sq = .059, and strong if omega_sq = .138 (Cohen, 1969). | ||||||||||
| 35 | |||||||||||
| 36 | =head1 SUBROUTINES/METHODS | ||||||||||
| 37 | |||||||||||
| 38 | Rather than working from raw data, these methods are given the statistics, like sums-of-squares, needed to calculate the effect-sizes. | ||||||||||
| 39 | |||||||||||
| 40 | =head2 eta_sq_partial_by_ss, r_squared | ||||||||||
| 41 | |||||||||||
| 42 | $es->eta_sq_partial_by_ss(ss_b => NUM, ss_w => NUM); | ||||||||||
| 43 | |||||||||||
| 44 | Returns partial I<eta>-squared given between- and within-group sums-of-squares (I<SS>): | ||||||||||
| 45 | |||||||||||
| 46 | =for html <p> η<sup>2</sup><sub>P</sub> = <i>SS</i><sub>b</sub> / ( <i>SS</i><sub>b</sub> + <i>SS</i><sub>w</sub> )</p> | ||||||||||
| 47 | |||||||||||
| 48 | This is also what is commonly designated as I<R>-squared (Maxwell & Delaney, 1990, Eq. 90). | ||||||||||
| 49 | |||||||||||
| 50 | =cut | ||||||||||
| 51 | |||||||||||
| 52 | 4 | ▶ | sub eta_sq_partial_by_ss { | ||||||||
|
Subroutine
eta_sq_partial_by_ss: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 53 | 4 | my ( $self, %args ) = @_; | |||||||||
| 54 | croak | ||||||||||
| 55 | 'Undefined values needed to calculate partial eta-squared by sums-of-squares' | ||||||||||
| 56 | 4 | ▶ | if any { !defined $args{$_} } (qw/ss_b ss_w/); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 57 | 4 | return $args{'ss_b'} / ( $args{'ss_b'} + $args{'ss_w'} ); | |||||||||
| 58 | } | ||||||||||
| 59 | 6 | *r_squared = \&eta_sq_partial_by_ss; | |||||||||
| 60 | |||||||||||
| 61 | =head2 r_squared_adj | ||||||||||
| 62 | |||||||||||
| 63 | $es->r_squared_adj(ss_b => NUM, ss_w => NUM, df_b => NUM, df_w => NUM); | ||||||||||
| 64 | |||||||||||
| 65 | Returns adjusted I<R>-squared. | ||||||||||
| 66 | |||||||||||
| 67 | =cut | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub r_squared_adj { | ||||||||
|
Subroutine
r_squared_adj: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 70 | 0 | my ( $self, %args ) = @_; | |||||||||
| 71 | 0 | my $r_squared = $self->r_squared(%args); # will check for ss_b and ss_w | |||||||||
| 72 | croak 'Could not obtain values to calculate adjusted r-squared' | ||||||||||
| 73 | 0 | ▶ | if any { !defined $args{$_} } (qw/df_b df_w/); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 74 | return 1 - | ||||||||||
| 75 | 0 | ( ( $args{'df_b'} + $args{'df_w'} ) / $args{'df_w'} ) * | |||||||||
| 76 | ( 1 - $r_squared ); | ||||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | =head2 eta_sq_partial_by_f | ||||||||||
| 80 | |||||||||||
| 81 | $es->eta_sq_partial_by_f(f_value => NUM , df_b => NUM, df_w => NUM); | ||||||||||
| 82 | |||||||||||
| 83 | Returns partial I<eta>-squared given I<F>-value and its between- and within-groups degrees-of-freedom (I<df>): | ||||||||||
| 84 | |||||||||||
| 85 | =for html <p> η<sup>2</sup><sub>P</sub> = ( <i>df</i><sub>b</sub> . <i>F</i> ) / ( <i>df</i><sub>b</sub> . <i>F</i> + <i>df</i><sub>w</sub> )</p> | ||||||||||
| 86 | |||||||||||
| 87 | =cut | ||||||||||
| 88 | |||||||||||
| 89 | 2 | ▶ | sub eta_sq_partial_by_f { | ||||||||
|
Subroutine
eta_sq_partial_by_f: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 90 | 2 | my ( $self, %args ) = @_; | |||||||||
| 91 | croak 'Could not obtain values to calculate partial eta-squared by F-value' | ||||||||||
| 92 | 2 | ▶ | if any { !defined $args{$_} } (qw/df_b df_w f_value/); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 93 | return ( $args{'df_b'} * $args{'f_value'} ) / | ||||||||||
| 94 | 2 | ( $args{'df_b'} * $args{'f_value'} + $args{'df_w'} ); | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | =head2 omega_sq_partial_by_ss | ||||||||||
| 98 | |||||||||||
| 99 | $es->omega_sq_partial_by_ss(df_b => NUM, df_w => NUM, ss_b => NUM, ss_w => NUM, count => NUM); | ||||||||||
| 100 | |||||||||||
| 101 | Returns partial I<omega>-squared given the between- and within-groups sums-of-squares and degrees-of-freedom. | ||||||||||
| 102 | |||||||||||
| 103 | =for html <p> ω<sup>2</sup><sub>P</sub> = ( <i>ss</i><sub>b</sub> — (<i>df</i><sub>b</sub> . <i>SS</i><sub>w</sub> / <i>df</i><sub>w</sub>) ) / ( <i>SS</i><sub>b</sub> + (<i>N</i> – <i>df</i><sub>b</sub> ) <i>SS</i><sub>w</sub> / <i>df</i><sub>w</sub> ) | ||||||||||
| 104 | |||||||||||
| 105 | (as in, e.g., Olejnik & Algina, 2003, p. 435). | ||||||||||
| 106 | |||||||||||
| 107 | =cut | ||||||||||
| 108 | |||||||||||
| 109 | 2 | ▶ | sub omega_sq_partial_by_ss { | ||||||||
|
Subroutine
omega_sq_partial_by_ss: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 110 | 2 | my ( $self, %args ) = @_; | |||||||||
| 111 | croak | ||||||||||
| 112 | 'Undefined values for calculating partial omega-squared by sums-of-squares' | ||||||||||
| 113 | 2 | ▶ | if any { !defined $args{$_} } (qw/ss_b ss_w df_b df_w count/); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 114 | 2 | return _omega_numerator_ss( \%args ) / _omega_denominator_ss( \%args ); | |||||||||
| 115 | } | ||||||||||
| 116 | |||||||||||
| 117 | =head2 omega_sq_partial_by_ms | ||||||||||
| 118 | |||||||||||
| 119 | $es->omega_sq_partial_by_ms(df_b => NUM, ms_b => NUM, ms_w => NUM, count => NUM); | ||||||||||
| 120 | |||||||||||
| 121 | Returns partial I<omega>-squared given between- and within-group mean sums-of-squares (I<MS>). Also needs between-groups degrees-of-freedom and sample-size (here labelled "count") I<N>: | ||||||||||
| 122 | |||||||||||
| 123 | =for html <p> ω<sup>2</sup><sub>P</sub> = <i>df</i><sub>b</sub> ( <i>MS</i><sub>b</sub> – <i>MS</i><sub>w</sub> ) / ( <i>df</i><sub>b</sub> . <i>MS</i><sub>b</sub> + ( <i>N</i> – <i>df</i><sub>b</sub> ) <i>MS</i><sub>w</sub> ) </p> | ||||||||||
| 124 | |||||||||||
| 125 | (as in, e.g., Lakens, 2013, Eq. 15). | ||||||||||
| 126 | |||||||||||
| 127 | =cut | ||||||||||
| 128 | |||||||||||
| 129 | 1 | ▶ | sub omega_sq_partial_by_ms { | ||||||||
|
Subroutine
omega_sq_partial_by_ms: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 130 | 1 | my ( $self, %args ) = @_; | |||||||||
| 131 | croak | ||||||||||
| 132 | 'Could not obtain values to calculate partial omega-squared by mean sums-of-squares' | ||||||||||
| 133 | 1 | ▶ | if any { !defined $_ } values %args; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 134 | 1 | return _omega_numerator_ms( \%args ) / _omega_denominator_ms( \%args ); | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | =head2 omega_sq_partial_by_f | ||||||||||
| 138 | |||||||||||
| 139 | $es->omega_sq_partial_by_ms(f_value => NUM, df_b => NUM, df_w => NUM); | ||||||||||
| 140 | |||||||||||
| 141 | Returns partial I<omega>-squared given I<F>-value and its between- and within-group degrees-of-freedom (I<df>): | ||||||||||
| 142 | |||||||||||
| 143 | =for html <p> ω<sup>2</sup><sub>P</sub>(est.) = ( <i>F</i> - 1 ) / ( <i>F</i> + ( df</i><sub>w</sub> + 1 ) / <i>df</i><sub>b</sub> )</p> | ||||||||||
| 144 | |||||||||||
| 145 | This is an estimate provided by L<D. Lakens|http://daniellakens.blogspot.com.au/2015/06/why-you-should-use-omega-squared.html>. | ||||||||||
| 146 | |||||||||||
| 147 | =cut | ||||||||||
| 148 | |||||||||||
| 149 | 2 | ▶ | sub omega_sq_partial_by_f { | ||||||||
|
Subroutine
omega_sq_partial_by_f: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 150 | 2 | my ( $self, %args ) = @_; | |||||||||
| 151 | croak | ||||||||||
| 152 | 'Could not obtain values to calculate partial omega-squared by mean sums-of-squares' | ||||||||||
| 153 | 2 | ▶ | if any { !defined $_ } values %args; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 154 | return ( $args{'f_value'} - 1 ) / | ||||||||||
| 155 | 2 | ( $args{'f_value'} + ( $args{'df_w'} + 1 ) / $args{'df_b'} ); | |||||||||
| 156 | } | ||||||||||
| 157 | |||||||||||
| 158 | =head2 eta_to_omega | ||||||||||
| 159 | |||||||||||
| 160 | $es->eta_to_omega(df_b => NUM, df_w => NUM, eta_sq => NUM); | ||||||||||
| 161 | |||||||||||
| 162 | Returns I<omega>-squared based on I<eta>-squared and the between- and within-groups degrees-of-freedom. | ||||||||||
| 163 | |||||||||||
| 164 | =for html <p> ω<sup>2</sup><sub>P</sub> = ( η<sup>2</sup><sub>P</sub>(<i>df</i><sub>b</sub> + <i>df</i><sub>w</sub>) – <i>df</i><sub>b</sub> ) / ( η<sup>2</sup><sub>P</sub>(<i>df</i><sub>b</sub> + <i>df</i><sub>w</sub>) – <i>df</i><sub>b</sub> ) + ( (<i>df</i><sub>w</sub> + 1)(1 – η<sup>2</sup><sub>P</sub>) ) ) </p> | ||||||||||
| 165 | |||||||||||
| 166 | =cut | ||||||||||
| 167 | |||||||||||
| 168 | 2 | ▶ | sub eta_to_omega { | ||||||||
|
Subroutine
eta_to_omega: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 169 | 2 | my ( $self, %args ) = @_; | |||||||||
| 170 | croak | ||||||||||
| 171 | 'Could not obtain values to calculate partial omega-squared by mean sums-of-squares' | ||||||||||
| 172 | 2 | ▶ | if any { !defined $_ } values %args; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 173 | my $num = | ||||||||||
| 174 | 2 | $args{'eta_sq'} * ( $args{'df_b'} + $args{'df_w'} ) - $args{'df_b'}; | |||||||||
| 175 | return $num / | ||||||||||
| 176 | 2 | ( $num + ( ( $args{'df_w'} + 1 ) * ( 1 - $args{'eta_sq'} ) ) ); | |||||||||
| 177 | } | ||||||||||
| 178 | |||||||||||
| 179 | 3 | ▶ | sub _omega_numerator_ss { | ||||||||
|
Subroutine
_omega_numerator_ss: called CC=1 SCAR=0.0
| |||||||||||
| 180 | 3 | my $args = shift; | |||||||||
| 181 | return $args->{'ss_b'} - | ||||||||||
| 182 | 3 | $args->{'df_b'} * $args->{'ss_w'} / $args->{'df_w'}; | |||||||||
| 183 | } | ||||||||||
| 184 | |||||||||||
| 185 | 2 | ▶ | sub _omega_numerator_ms { | ||||||||
|
Subroutine
_omega_numerator_ms: called CC=1 SCAR=0.0
| |||||||||||
| 186 | 2 | my $args = shift; | |||||||||
| 187 | 2 | return $args->{'df_b'} * ( $args->{'ms_b'} - $args->{'ms_w'} ); | |||||||||
| 188 | } | ||||||||||
| 189 | |||||||||||
| 190 | 3 | ▶ | sub _omega_denominator_ss { | ||||||||
|
Subroutine
_omega_denominator_ss: called CC=1 SCAR=0.0
| |||||||||||
| 191 | 3 | my $args = shift; | |||||||||
| 192 | |||||||||||
| 193 | #return ( $args->{'ss_b'} + $args->{'ss_w'} ) + $args->{'ss_w'} / $args->{'df_w'}; | ||||||||||
| 194 | return $args->{'ss_b'} + | ||||||||||
| 195 | ( $args->{'count'} - $args->{'df_b'} ) * | ||||||||||
| 196 | $args->{'ss_w'} / | ||||||||||
| 197 | 3 | $args->{'df_w'}; | |||||||||
| 198 | } | ||||||||||
| 199 | |||||||||||
| 200 | 2 | ▶ | sub _omega_denominator_ms { | ||||||||
|
Subroutine
_omega_denominator_ms: called CC=1 SCAR=0.0
| |||||||||||
| 201 | 2 | my $args = shift; | |||||||||
| 202 | return $args->{'df_b'} * $args->{'ms_b'} + | ||||||||||
| 203 | 2 | ( $args->{'count'} - $args->{'df_b'} ) * $args->{'ms_w'}; | |||||||||
| 204 | } | ||||||||||
| 205 | |||||||||||
| 206 | =head1 DEPENDENCIES | ||||||||||
| 207 | |||||||||||
| 208 | L<List::AllUtils|List::AllUtils> : C<any> method | ||||||||||
| 209 | |||||||||||
| 210 | L<Statistics::Data|Statistics::Data> : used as base. | ||||||||||
| 211 | |||||||||||
| 212 | =head1 DIAGNOSTICS | ||||||||||
| 213 | |||||||||||
| 214 | =over 4 | ||||||||||
| 215 | |||||||||||
| 216 | =item Could not obtain values to calculate ... | ||||||||||
| 217 | |||||||||||
| 218 | C<croak>ed if the sufficient statistics have not been provided. | ||||||||||
| 219 | |||||||||||
| 220 | =back | ||||||||||
| 221 | |||||||||||
| 222 | =head1 REFERENCES | ||||||||||
| 223 | |||||||||||
| 224 | Cohen, J. (1969). I<Statistical power analysis for the behavioral sciences>. New York, US: Academic. | ||||||||||
| 225 | |||||||||||
| 226 | Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: A practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4, 863. doi:L<10.3389/fpsyg.2013.00863|http://dx.doi.org/10.3389/fpsyg.2013.00863> | ||||||||||
| 227 | |||||||||||
| 228 | Lakens, D. (2015). Why you should use omega-squared instead of eta-squared, I<The 20% statistician> [L<Weblog|http://daniellakens.blogspot.com.au/2015/06/why-you-should-use-omega-squared.html>]. | ||||||||||
| 229 | |||||||||||
| 230 | Maxwell, S. E., & Delaney, H. D. (1990). I<Designing experiments and analyzing data: A model comparison perspective>. Belmont, CA, US: Wadsworth. | ||||||||||
| 231 | |||||||||||
| 232 | Olejnik, S., & Algina, J. (2003). Generalized eta and omega squared statistics: Measures of effect size for some common research designs. I<Psychological Methods>, I<8>, 434-447. doi: L<10.1037/1082-989X.8.4.434|http://dx.doi.org/10.1037/1082-989X.8.4.434>. | ||||||||||
| 233 | |||||||||||
| 234 | =head1 AUTHOR | ||||||||||
| 235 | |||||||||||
| 236 | Roderick Garton, C<< <rgarton at cpan.org> >> | ||||||||||
| 237 | |||||||||||
| 238 | =head1 BUGS | ||||||||||
| 239 | |||||||||||
| 240 | Please report any bugs or feature requests to C<bug-statistics-anova-effectsize-0.02 at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Statistics-ANOVA-EffectSize-0.02>. I will be notified, and then you'll | ||||||||||
| 241 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 242 | |||||||||||
| 243 | =head1 SUPPORT | ||||||||||
| 244 | |||||||||||
| 245 | You can find documentation for this module with the perldoc command. | ||||||||||
| 246 | |||||||||||
| 247 | perldoc Statistics::ANOVA::EffectSize | ||||||||||
| 248 | |||||||||||
| 249 | |||||||||||
| 250 | You can also look for information at: | ||||||||||
| 251 | |||||||||||
| 252 | =over 4 | ||||||||||
| 253 | |||||||||||
| 254 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||
| 255 | |||||||||||
| 256 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Statistics-ANOVA-EffectSize-0.02> | ||||||||||
| 257 | |||||||||||
| 258 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 259 | |||||||||||
| 260 | L<http://annocpan.org/dist/Statistics-ANOVA-EffectSize-0.02> | ||||||||||
| 261 | |||||||||||
| 262 | =item * CPAN Ratings | ||||||||||
| 263 | |||||||||||
| 264 | L<http://cpanratings.perl.org/d/Statistics-ANOVA-EffectSize-0.02> | ||||||||||
| 265 | |||||||||||
| 266 | =item * Search CPAN | ||||||||||
| 267 | |||||||||||
| 268 | L<http://search.cpan.org/dist/Statistics-ANOVA-EffectSize-0.02/> | ||||||||||
| 269 | |||||||||||
| 270 | =back | ||||||||||
| 271 | |||||||||||
| 272 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 273 | |||||||||||
| 274 | Copyright 2015-2018 Roderick Garton. | ||||||||||
| 275 | |||||||||||
| 276 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 277 | under the terms of either: the GNU General Public License as published | ||||||||||
| 278 | by the Free Software Foundation; or the Artistic License. | ||||||||||
| 279 | |||||||||||
| 280 | See L<http://dev.perl.org/licenses/> for more information. | ||||||||||
| 281 | |||||||||||
| 282 | =cut | ||||||||||
| 283 | |||||||||||
| 284 | 6 | 1; # End of Statistics::ANOVA::EffectSize | |||||||||