File Coverage

blib/lib/Statistics/ANOVA/EffectSize.pm
Criterion Covered Total %
statement 42 47 89.3
branch 6 14 42.8
condition n/a
subroutine 18 20 90.0
pod 7 7 100.0
total 73 88 82.9


line stmt bran cond sub pod time code
1             package Statistics::ANOVA::EffectSize;
2            
3 5     5   27900 use 5.006;
  5         12  
4 5     5   15 use strict;
  5         8  
  5         82  
5 5     5   15 use warnings;
  5         4  
  5         123  
6 5     5   14 use base qw(Statistics::Data);
  5         6  
  5         1195  
7 5     5   42349 use Carp qw(croak);
  5         6  
  5         220  
8 5     5   18 use List::AllUtils qw(any);
  5         5  
  5         2712  
9             $Statistics::ANOVA::EffectSize::VERSION = '0.01';
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 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-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-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-squared given between- and within-group sums-of-squares (I):
45            
46             =for html

  η2P = SSb / ( SSb + SSw )

47            
48             This is also what is commonly designated as I-squared (Maxwell & Delaney, 1990, Eq. 90).
49            
50             =cut
51            
52             sub eta_sq_partial_by_ss {
53 4     4 1 58 my ($self, %args) = @_;
54 4 50   8   30 croak 'Undefined values needed to calculate partial eta-squared by sums-of-squares' if any { ! defined $args{$_} } (qw/ss_b ss_w/);
  8         18  
55 4         20 return $args{'ss_b'} / ( $args{'ss_b'} + $args{'ss_w'} );
56             }
57             *r_squared = \&eta_sq_partial_by_ss;
58            
59             =head2 r_squared_adj
60            
61             $es->r_squared_adj(ss_b => NUM, ss_w => NUM, df_b => NUM, df_w => NUM);
62            
63             Returns adjusted I-squared.
64            
65             =cut
66            
67             sub r_squared_adj {
68 0     0 1 0 my ($self, %args) = @_;
69 0         0 my $r_squared = $self->r_squared(%args); # will check for ss_b and ss_w
70 0 0   0   0 croak 'Could not obtain values to calculate adjusted r-squared' if any { ! defined $args{$_} } (qw/df_b df_w/);
  0         0  
71 0         0 return 1 - ( ($args{'df_b'} + $args{'df_w'}) / $args{'df_w'} ) * ( 1 - $r_squared );
72             }
73            
74             =head2 eta_sq_partial_by_f
75            
76             $es->eta_sq_partial_by_f(f_value => NUM , df_b => NUM, df_w => NUM);
77            
78             Returns partial I-squared given I-value and its between- and within-groups degrees-of-freedom (I):
79            
80             =for html

  η2P = ( dfb . F ) / ( dfb . F + dfw )

81            
82             =cut
83            
84             sub eta_sq_partial_by_f {
85 2     2 1 511 my ($self, %args) = @_;
86 2 50   6   17 croak 'Could not obtain values to calculate partial eta-squared by F-value' if any { ! defined $args{$_} } (qw/df_b df_w f_value/);
  6         11  
87 2         13 return ( $args{'df_b'} * $args{'f_value'} ) / ( $args{'df_b'} * $args{'f_value'} + $args{'df_w'} );
88             }
89            
90             =head2 omega_sq_partial_by_ss
91            
92             $es->omega_sq_partial_by_ss(df_b => NUM, df_w => NUM, ss_b => NUM, ss_w => NUM);
93            
94             Returns partial I-squared given the between- and within-groups sums-of-squares and degrees-of-freedom.
95            
96             Essentially as given by Maxwell & Delaney (1990), Eq. 92:
97            
98             =for html

  ω2P = ( ssb — (dfb . SSw / dfb) ) / (( SSb + SSw ) + SSw / dfw )

99            
100             =cut
101            
102             sub omega_sq_partial_by_ss {
103 1     1 1 26 my ($self, %args) = @_;
104 1 50   4   4 croak 'Undefined values for calculating partial omega-squared by sums-of-squares' if any { ! defined $args{$_} } (qw/ss_b ss_w df_b df_w/);
  4         6  
105 1         6 return ( $args{'ss_b'} - ( $args{'df_b'} * $args{'ss_w'} / $args{'df_w'} ) ) / ( ( $args{'ss_b'} + $args{'ss_w'} ) + $args{'ss_w'} / $args{'df_w'} );
106             }
107            
108             =head2 omega_sq_partial_by_ms
109            
110             $es->omega_sq_partial_by_ms(df_b => NUM, ms_b => NUM, ms_w => NUM, count => NUM);
111            
112             Returns partial I-squared given between- and within-group mean sums-of-squares (I). Also needs between-groups degrees-of-freedom and sample-size (here labelled "count") I:
113            
114             =for html

  ω2P = dfb ( MSbMSw ) / ( dfb . MSb + ( Ndfb ) MSw )

115            
116             =cut
117            
118             sub omega_sq_partial_by_ms {
119 1     1 1 169 my ($self, %args) = @_;
120 1 50   4   6 croak 'Could not obtain values to calculate partial omega-squared by mean sums-of-squares' if any { ! defined $_ } values %args;
  4         6  
121 1         8 return $args{'df_b'} * ( $args{'ms_b'} - $args{'ms_w'} ) / ( $args{'df_b'} * $args{'ms_b'} + ( $args{'count'} - $args{'df_b'} ) * $args{'ms_w'} );
122             }
123            
124             =head2 omega_sq_partial_by_f
125            
126             $es->omega_sq_partial_by_ms(f_value => NUM, df_b => NUM, df_w => NUM);
127            
128             Returns partial I-squared given I-value and its between- and within-group degrees-of-freedom (I):
129            
130             =for html

  ω2P(est.) = ( F - 1 ) / ( F + ( dfw + 1 ) / dfb )

131            
132             This is an estimate formulated by L that will not ordinarily agree with the method by (mean) sum-of-squares.
133            
134             =cut
135            
136             sub omega_sq_partial_by_f {
137 2     2 1 193 my ($self, %args) = @_;
138 2 50   6   12 croak 'Could not obtain values to calculate partial omega-squared by mean sums-of-squares' if any { ! defined $_ } values %args;
  6         9  
139 2         13 return ( $args{'f_value'} - 1 ) / ( $args{'f_value'} + ( $args{'df_w'} + 1)/$args{'df_b'} );
140             }
141            
142             =head2 eta_to_omega
143            
144             $es->eta_to_omega(df_b => NUM, df_w => NUM, eta_sq => NUM);
145            
146             Returns I-squared based on I-squared and the between- and within-groups degrees-of-freedom.
147            
148             =for html

  ω2P = ( η2P(dfb + dfw) – dfb ) / ( η2P(dfb + dfw) – dfb ) + ( (dfw + 1)(1 – η2P) ) )

149            
150             =cut
151            
152             sub eta_to_omega {
153 2     2 1 345 my ($self, %args) = @_;
154 2 50   6   12 croak 'Could not obtain values to calculate partial omega-squared by mean sums-of-squares' if any { ! defined $_ } values %args;
  6         10  
155 2         8 my $num = $args{'eta_sq'} * ( $args{'df_b'} + $args{'df_w'} ) - $args{'df_b'};
156 2         9 return $num / ( $num + ( ( $args{'df_w'} + 1) * ( 1 - $args{'eta_sq'} ) ) );
157             }
158            
159             =head1 DEPENDENCIES
160            
161             L : C method
162            
163             L : used as base.
164            
165             =head1 DIAGNOSTICS
166            
167             =over 4
168            
169             =item Could not obtain values to calculate ...
170            
171             Ced if the sufficient statistics have not been provided.
172            
173             =back
174            
175             =head1 REFERENCES
176            
177             Cohen, J. (1969). I. New York, US: Academic.
178            
179             Lakens, D. (2015). Why you should use omega-squared instead of eta-squared, I [L].
180            
181             Maxwell, S. E., & Delaney, H. D. (1990). I. Belmont, CA, US: Wadsworth.
182            
183             Olejnik, S., & Algina, J. (2003). Generalized eta and omega squared statistics: Measures of effect size for some common research designs. I, I<8>, 434-447. doi: L<10.1037/1082-989X.8.4.434|http://dx.doi.org/10.1037/1082-989X.8.4.434>.
184            
185             =head1 AUTHOR
186            
187             Roderick Garton, C<< >>
188            
189             =head1 BUGS
190            
191             Please report any bugs or feature requests to C, or through
192             the web interface at L. I will be notified, and then you'll
193             automatically be notified of progress on your bug as I make changes.
194            
195             =head1 NOTES
196            
197            
198             For independent variables only, omega-square (raw):
199            
200             w2 = (SSeffect - (dfeffect)(MSerror)) / MSerror + SStotal
201            
202             =head1 SUPPORT
203            
204             You can find documentation for this module with the perldoc command.
205            
206             perldoc Statistics::ANOVA::EffectSize
207            
208            
209             You can also look for information at:
210            
211             =over 4
212            
213             =item * RT: CPAN's request tracker (report bugs here)
214            
215             L
216            
217             =item * AnnoCPAN: Annotated CPAN documentation
218            
219             L
220            
221             =item * CPAN Ratings
222            
223             L
224            
225             =item * Search CPAN
226            
227             L
228            
229             =back
230            
231             =head1 LICENSE AND COPYRIGHT
232            
233             Copyright 2015 Roderick Garton.
234            
235             This program is free software; you can redistribute it and/or modify it
236             under the terms of either: the GNU General Public License as published
237             by the Free Software Foundation; or the Artistic License.
238            
239             See L for more information.
240            
241             =cut
242            
243             1; # End of Statistics::ANOVA::EffectSize