File Coverage

blib/lib/Statistics/ANOVA.pm
Criterion Covered Total %
statement 453 567 79.8
branch 114 230 49.5
condition 12 48 25.0
subroutine 54 63 85.7
pod 20 21 95.2
total 653 929 70.2


line stmt bran cond sub pod time code
1             package Statistics::ANOVA;
2 16     16   209771 use 5.008008;
  16         41  
3 16     16   62 use strict;
  16         15  
  16         347  
4 16     16   52 use warnings;
  16         25  
  16         390  
5 16     16   59 use base qw(Statistics::Data);
  16         20  
  16         7620  
6 16     16   335943 use Carp qw(croak carp);
  16         21  
  16         731  
7 16     16   60 use List::AllUtils qw(any sum0);
  16         19  
  16         612  
8 16     16   7652 use Math::Cephes qw(:dists);
  16         67335  
  16         3527  
9 16     16   7405 use Readonly;
  16         51490  
  16         715  
10 16     16   109 use Scalar::Util qw(looks_like_number);
  16         16  
  16         591  
11 16     16   7315 use Statistics::Data::Rank;
  16         40358  
  16         479  
12 16     16   70 use Statistics::Lite qw(count max mean min sum stddev variance);
  16         16  
  16         76933  
13            
14             $Statistics::ANOVA::VERSION = '0.13';
15             Readonly my $ALPHA_DEFAULT => .05;
16            
17             =head1 NAME
18            
19             Statistics::ANOVA - Parametric and nonparametric 1-way analyses of variance for means-comparison and clustering per differences/trends over independent or repeated measures of variables or levels
20            
21             =head1 VERSION
22            
23             This is documentation for B of Statistics::ANOVA.
24            
25             =head1 SYNOPSIS
26            
27             use Statistics::ANOVA 0.13;
28             my $aov = Statistics::ANOVA->new();
29            
30             # Some data:
31             my @gp1 = (qw/8 7 11 14 9/);
32             my @gp2 = (qw/11 9 8 11 13/);
33             my $res; # each anova method returns hash of F-value, p-value, ss_b, ss_w, etc., where relevant
34            
35             # Load the data:
36             $aov->load_data({1 => \@gp1, 2 => \@gp2}); # NB: hashref
37             # or $aov->load_data([ [1, \@gp1], [2, \@gp2] ]);
38             # or $aov->load_data([ [1, @gp1], [2, @gp2] ]);
39             my @gp3 = (qw/7 13 12 8 10/);
40             $aov->add_data(3 => \@gp3);
41            
42             # Test equality of variances before omnibus comparison:
43             %res = $aov->obrien()->dump(title => 'O\'Brien\'s test of equality of variances');
44             %res = $aov->levene()->dump(title => 'Levene\'s test of equality of variances');
45            
46             # 1.10 Independent nominal variables ANOVA - parametric testing:
47             %res = $aov->anova(independent => 1, parametric => 1)->dump(title => 'Indep. variables parametric ANOVA', eta_squared => 1, omega_squared => 1);
48             # 1.11 Independent nominal variables (groups) ANOVA - NON-parametric:
49             %res = $aov->anova(independent => 1, parametric => 0)->dump(title => 'Kruskal-Wallis test');
50            
51             # or if independent AND ordered variables (levels): test linear/non-linear trend:
52             # 1.20 Independent ordinal variables ANOVA - parametric testing:
53             %res = $aov->anova(independent => 1, parametric => 1, ordinal => 1)->dump(title => 'Indep. variables parametric ANOVA: Linear trend');
54             %res = $aov->anova(independent => 1, parametric => 1, ordinal => 2)->dump(title => 'Indep. variables parametric ANOVA: Non-linear trend');
55             # 1.21 Independent ordinal variables ANOVA - NONparametric testing:
56             %res = $aov->anova(independent => 1, parametric => 0, ordinal => 1)->dump(title => 'Jonckheere-Terpstra test');
57            
58             # If they are repeated measures:
59             # 2.10 Dependent nominal variables ANOVA - parametric testing:
60             %res = $aov->anova(independent => 0, parametric => 1)->dump(title => 'Dependent variables ANOVA');
61             # 2.11 Dependent nominal variables ANOVA - NONparametric testing:
62             %res = $aov->anova(independent => 0, parametric => 0, f_equiv => 0)->dump(title => 'Friedman test');
63            
64             # or if repeated AND ordinal measures:
65             # 2.20 Dependent ordinal variables ANOVA - parametric testing: NOT IMPLEMENTED
66             #$aov->anova(independent => 0, parametric => 1)->dump(title => '');
67             # 2.21 Dependent ordinal variables test - NONparametric testing:
68             %res = $aov->anova(independent => 0, parametric => 0, ordinal => 1, f_equiv => 0)->dump(title => 'Page test');
69            
70             # Get pairwise comparisons (nominality of the factor assumed):
71             $aov->compare(independent => 1, parametric => 1, flag => 1, alpha => .05, dump => 1); # Indep. obs. F- (or t-)tests
72             $aov->compare(independent => 0, parametric => 1, flag => 1, alpha => .05, dump => 1); # Paired obs. F (or t-)tests
73             $aov->compare(independent => 1, parametric => 0, flag => 1, alpha => .05, dump => 1); # Wilcoxon (between-variables) sum-of-ranks (Dwass Procedure)
74             $aov->compare(independent => 0, parametric => 0, flag => 1, alpha => .05, dump => 1); # Friedman-type (within-variables) sum-of-ranks
75            
76             print $aov->table(precision_p => 3, precision_s => 3);
77            
78             $aov->unload('g3'); # back to 2 datasets (g1 and g2)
79            
80             =head1 DESCRIPTION
81            
82             =for html
"If your predictor variables are categorical (ordered or unordered) and your response variables are continuous, your design is called an ANOVA (for ANalysis Of VAriance"—Gotelli & Ellison (2004, p. 171).
83            
84             With that idea in mind, in order to actually perform an ANOVA, you really only need to define an analysis as based on (1) ordered or unordered predictors, (2) independent or repeated measurement of their effects on response variables (i.e., from different or the same data-sources), and then (3) whether parametric or nonparametric assumptions can be made about how the factors impact on the response variables. This module facilitates selecting the right type of ANOVA, by a mere true/false setting of three arguments based on the three latter concepts-- attempting to meet just about every possible combination of these analysis specs. More specifically ...
85            
86             By setting the Boolean (0, 1) value of three parameters (B, B and B), this module returns and memorizes results from oneway parametric or non-parametric analyses-of-variance (ANOVAs) for either nominal groups or ordinal levels of an independent factor, and for either independent or dependent (repeated measures) observations within each group/level of that factor.
87            
88             Parametric tests are of the traditional Fisher-type. Non-parametric tests comprise the Kruskal-Wallis, Jonckheere-Terpstra, Friedman and Page tests; all rank-based tests (with default accounting for ties in ranks).
89            
90             Other, related routines are offered: for parametrically testing equality of variances (O'Brien and Levene tests); for estimating proportion of variance accounted for (I-squared) and effect-size (I-squared); and for making some rudimentary I pairwise comparisons by independent/dependent I-tests.
91            
92             Reliability of the implemented methods has been tested against at least two different published exemplars of the methods; and by comparing output with one or another open-source or commercial statistics package. That this module's stats and tests match these examplars is tested during installation (at least via CPAN, or when making a "manual" installation).
93            
94             The API has been stable over all versions, but, ahead of versioning to 1.0, it might well be expected to change. News of method unreliabilities and/or limitations are welcome. Ones from Cathal Seoghie re version 0.01, and Patrick H. Degnan re version 0.07, have already helped this module's development.
95            
96             =head1 METHODS
97            
98             =head2 INTERFACE
99            
100             Object-oriented. No subs are explicitly exported, no arguments are set for cross-method application. The class-object holds the myriad of statistics produced by the last ANOVA run.
101            
102             =head3 new
103            
104             $aov = Statistics::ANOVA->new()
105            
106             Create a new Statistics::ANOVA object for accessing the subs.
107            
108             =head2 HANDLING DATA
109            
110             =head3 load
111            
112             $aov->load('aname', @data1)
113             $aov->load('aname', \@data1)
114             $aov->load(['aname', @data1], ['another_name', @data2])
115             $aov->load(['aname', \@data1], ['another_name', \@data2])
116             $aov->load({'aname' => \@data1, 'another_name' => \@data2})
117            
118             I: C
119            
120             Accepts data for analysis in any of the above-shown forms, but always with the requirement that:
121            
122             =over
123            
124             =item 1.
125            
126             a single set of observations (the "group" or "level") is given a unique name, and
127            
128             =item 2.
129            
130             you do not mix the methods, e.g., a hashref here, an arrayref there.
131            
132             =back
133            
134             The reason for these options is that there are as many as it is practically and intuitively possible to make in Perl's Statistics modules that it's a cost and pain to traverse them; so multiple structures are permitted.
135            
136             =over
137            
138             =item 1. sample_name => AREF:
139            
140             provide C value> pairs of data keyed by a stringy name, each with referenced array of values.
141            
142             =item 2. data => AREF
143            
144             a reference to an array of referenced arrays, where each of the latter arrays consists of a sample name occupying the first index, and then its sample data, as an array or yet another referenced array; e.g., [ ['group A', 20, 22, 18], ['group B', 18, 20, 16] ]
145            
146             =item 3. { sample_name_A => AREF, sample_name_B => AREF}
147            
148             a hash reference of named array references of data. This is the preferred method - the one that is first checked in the elongated C clause that parses all this variety.
149            
150             =back
151            
152             The data are loaded into the class object by name, within a hash named C, as flat arrays. So it's all up to you then what statistics and how follow from using this package.
153            
154             The names of the data are up to you, the user; whatever can be set as the key in a hash. But if you intend to do trend analysis, you should, as a rule, give only I names to your groups/levels, defining their ordinality (with respect to the limitations on algorithms presently offered for trend analysis).
155            
156             Each call Ls any previous loads.
157            
158             Returns the Statistics::ANOVA object - nothing but its blessed self.
159            
160             =cut
161            
162             sub load {
163 26     26 1 9953 my $self = shift;
164 26         78 $self->unload();
165 26         91 $self->add(@_);
166 26         89 return;
167             }
168             *load_data = \&load; # Alias
169            
170             =head3 add, add_data
171            
172             $aov->add('another_name', \@data2);
173             $aov->add(['another_name', \@data2]);
174             $aov->add({'another_name' => \@data2});
175            
176             Same as L except that any previous loads are not Led. Again, the hash-referenced list is given preferential treatment.
177            
178             =cut
179            
180             sub add {
181 43     43 1 1614 my $self = shift;
182 43         47 my ( $name, $data ) = ();
183            
184 43 100       118 if ( ref $_[0] eq 'HASH' ) {
    100          
185 25         32 while ( ( $name, $data ) = each %{ $_[0] } ) {
  108         5747  
186 83 50       173 if ( ref $data ) {
187 83         184 $self->SUPER::add( $name, $data );
188             }
189             }
190             }
191             elsif ( ref $_[0] eq 'ARRAY' ) {
192 4         9 $self->add( _aref2href( $_[0] ) );
193             }
194             else {
195 14         13 $name = shift;
196 14 50       30 $data =
    100          
197             ref $_[0] eq 'ARRAY' ? $_[0]
198             : scalar(@_) ? \@_
199             : croak 'No list of data for ANOVA';
200 14         29 $self->SUPER::add( $name, $data );
201             }
202 43         1083 return;
203             }
204             *add_data = \&add; # Alias
205            
206             =head3 unload
207            
208             $aov->unload() # bye to everything
209             $aov->unload('g1') # so long data named "g1"
210            
211             I: C
212            
213             With nil or no known arguments, 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.
214            
215             Alternatively, supply one or more names of already loaded data to clobber just them out of existence; preserving any other loads.
216            
217             =cut
218            
219             sub unload {
220 35     35 1 3727 my ($self) = shift;
221 35 100       82 if ( scalar @_ ) {
222 5         9 foreach (@_) {
223 5         13 $self->SUPER::unload( name => $_ );
224             }
225             }
226             else {
227 30         137 $self->SUPER::unload();
228             }
229 35         426 $self->{'_cleared'} = 1;
230 35         39 return 1;
231             }
232             *delete_data = \&unload; # Alias
233            
234             =head3 I
235            
236             Any data-points/observations sent to L or L that are undefined or not-a-number are marked for purging before being anova-tested or tested pairwise. The data arrays accessed as above, will still show the original values. When, however, you call one of the anova or pairwise methods, the data must and will be purged of these invalid values before testing.
237            
238             When the C parameter equals 1 when sent to L or L, each list is simply purged of any undefined or invalid values. This also occurs for the equality of variances tests.
239            
240             When C parameter equals 0 when sent to L and L, each list is purged of any value at all indices that, in any list, contain invalid values. So if two lists are (1, 4, 2) and (2, ' ', 3), the lists will have to become (1, 2) and (2, 3) to account for the bung value in the second list, and to keep all the observations appropriately paired.
241            
242             The number of indices that were subject to purging is cached thus: $aov->{'purged'}. The L method can also reveal this value.
243            
244             The C method in L is used for checking validity of values. (Although Params::Classify::is_number might be stricter, looks_like_number benchmarks at least a few thousand %s faster.)
245            
246             =head2 PROBABILITY TESTING
247            
248             One generic method L (a.k.a. aov, test) is used to access the possible combitinations of parametric or nonparametric tests, for independent or dependent/related observations, and for categorical or ordinal analysis. Accessing the different statistical tests depends on setting I parameters on a true/false basis: I, I and I.
249            
250             The attribute C refers to whether or not each level of the variable was yielded by independent or related sources of data; e.g., If the same people provided you with responses under the various factors, or if the factors were tested by different participants apiece; when respectively C => 0 or 1.
251            
252             The following describes the particular tests you get upon each possible combination of these alternatives.
253            
254             =head3 1. INDEPENDENT groups/levels
255            
256             =head4 1.10 PARAMETRIC test for NOMINAL groups
257            
258             %res = $aov->anova(independent => 1, parametric => 1, ordinal => 0)
259            
260             Offers the standard Fisher-type ANOVA for independent measures of the different levels of a factor.
261            
262             =head4 1.11 PARAMETRIC test for ORDINAL levels
263            
264             $aov->anova(independent => 1, parametric => 1, ordinal => 1) # test linear trend
265             $aov->anova(independent => 1, parametric => 1, ordinal => -1) # test non-linear trend
266            
267             If the independent/treatment/between groups variable is actually measured on a continuous scale/is a quantitative factor, assess their B: Instead of asking "How sure can we be that the means-per-group are equal?", ask "How sure can we be that there is a departure from flatness of the means-per-level?".
268            
269             The essential difference is that in place of the the between (treatment) mean sum-of-squares in the numerator is the linear sum of squares in which each "group" mean is weighted by the deviation of the level-value (the name of the "group") from the mean of the levels (and divided by the sum of the squares of these deviations).
270            
271             If the number of observations per level is unequal, the module applies the simple I approach. This is recommended as a general rule by Maxwell and Delaney (1990), given that the I approach might erroneously suggest a linear trend (unequal means) when, in fact, the trend is curvilinear (and by which the means balance out to equality); unless "there are strong theoretical reasons to believe that the only true population trend is linear" (p. 234). (But then you might be theoretically open to either. While remaining as the default, a future option might access the I approach.)
272            
273             To test if there is the possibility of a B, give the value of -1 to the C argument.
274            
275             Note that the contrast coefficients are calculated directly from the values of the independent variable, rather than using a look-up table. This respects the actual distance between values, but requires that the names of the sample data, of the groups (or levels), are I names when Led - i.e., such that the data-keys can be summed and averaged.
276            
277             =head4 1.20 NONPARAMETRIC test for NOMINAL groups (Kruskal-Wallis test)
278            
279             %res = $aov->anova(independent => 1, parametric => 0, ordinal => 0)
280            
281             Performs a one-way independent groups ANOVA using the non-parametric B sum-of-ranks method for a single factor with 2 or more levels. By default, instead of an I-value, there is an I-value. The I

-value is read off the chi-square distribution. The test is generally considered to be unreliable if there are no more than 3 groups and all groups comprise 5 or fewer observations. An estimate of I can, alternatively be returned, if the optional argument B => 1.

282            
283             By default, this method accounts for and corrects for ties in ranks across the levels, but if C = 0, I is uncorrected. The correction involves giving each tied score the mean of the ranks for which it is tied (see Siegal, 1956, p. 188ff).
284            
285             =head4 1.21 NONPARAMETRIC test for ORDINAL levels (Jonckheere-Terpstra test)
286            
287             $aov->anova(independent => 1, parametric => 0, ordinal => 1)
288            
289             Performs the B nonparametric test for independent but ordered levels. The method returns:
290            
291             $res{'j_value'} : the observed value of J
292             $res{'j_exp'} : the expected value of J
293             $res{'j_var'} : the variance of J
294             $res{'z_value'} : the normalized value of J
295             $res{'p_value'} : the one-tailed probability of observing a value as great as or greater than z_value.
296            
297             =head3 2. DEPENDENT groups/levels (REPEATED MEASURES)
298            
299             =head4 2.10 PARAMETRIC test for NOMINAL groups
300            
301             %res = $aov->anova(independent => 0, parametric => 1, ordinal => 0, multivariate => 0|1)
302            
303             Performs parametric repeated measures analysis of variance. This uses the traditional univariate, or "mixed-model," approach, with sphericity assumed (i.e., equal variances of all factor differences, within each factor and all possible pairs of factors). The assumption is met when there are only two levels of the repeated measures factor; but unequal variances might be a problem when there are more than two levels. No methods are presently applied to account for the possibility of non-sphericity.
304            
305             =head4 2.11 PARAMETRIC test for ORDINAL levels
306            
307             [Not implemented.]
308            
309             =head4 2.20 NONPARAMETRIC test for NOMINAL groups (Friedman test)
310            
311             %res = $aov->anova(independent => 0, parametric => 0, ordinal => 0)
312            
313             Performs the B nonparametric analysis of variance - for two or more dependent (matched, related) groups. The statistical attributes now within the class object (see L) pertain to this test, e.g., $aov->{'chi_value'} gives the chi-square statistic from the Friedman test; and $aov->{'p_value'} gives the associated I

-value (area under the right-side, upper tail of the distribution). If B => 1, then, instead of the I-value, and I

-value read off the I-square distribution, you get the I-value equivalent, with the I

-value read off the I-distribution.

314            
315             =cut
316            
317             =head4 2.21 NONPARAMETRIC test for ORDINAL levels (Page test)
318            
319             %res = $aov->anova(independent => 0, parametric => 0, ordinal => 1, tails => 1|2)
320            
321             This implements the B (1963) analysis of variance by ranks for repeated measures of ordinally scaled variables; so requires - numerically named variables. The statistical attributes now within the class object (see L) pertain to this test, and are chiefly:
322            
323             $res{'l_value'} : the observed test statistic (sum of ordered and weighted ranks)
324             $res{'l_exp'} : expected value of the test statistic
325             $res{'l_var'} : variance of the test statistic (given so many groups and observations)
326             $res{'z_value'} : the standardized l_value
327             $res{'p_value'} : the 2-tailed probability associated with the z_value (or 1-tailed if tails => 1).
328             $res{'r_value'} : estimate of the Spearman rank-order correlation coefficient
329             based on the observed and predicted order of each associated variable per observation.
330            
331             =head3 anova
332            
333             $aov->anova(independent => 1|0, parametric => 1|0, ordinal => 0|1)
334            
335             I: aov, test
336            
337             Generic method to access all anova functions by specifying TRUE/FALSE values for C, C and C.
338            
339             Independent Parametric Ordinal What you get
340             1 1 0 Fisher-type independent groups ANOVA
341             1 1 1 Fisher-type independent groups ANOVA with trend analysis
342             1 0 0 Kruskal-Wallis independent groups ANOVA
343             1 0 1 Jonckheere-Terpstra independent groups trend analysis
344             0 1 0 Fisher-type dependent groups ANOVA (univariate or multivariate)
345             0 1 1 (Fisher-type dependent groups ANOVA with trend analysis; not implemented)
346             0 0 0 Friedman's dependent groups ANOVA
347             0 0 1 Page's dependent groups trend analysis
348            
349             All methods return nothing but the class object after feeding it with the relevant statistics, which you can access by name, as follows:
350            
351             $res{'f_value'} (or $res{'chi_value'}, $res{'h_value'}, $res{'j_value'}, $res{'l_value'} and/or $res{'z_value'})
352             $res{'p_value'} : associated with the test statistic
353             $res{'df_b'} : between-groups/treatment/numerator degree(s) of freedom
354             $res{'df_w'} : within-groups/error/denominator degree(s) of freedom (also given with F-equivalent Friedman test)
355             $res{'ss_b'} : between-groups/treatment sum of squares
356             $res{'ss_w'} : within-groups/error sum of squares
357             $res{'ms_b'} : between-groups/treatment mean squares
358             $res{'ms_w'} : within-groups/error mean squares
359            
360             =cut
361            
362             sub anova {
363 41     41 1 14214 my ( $self, %args ) = @_;
364 41         85 foreach (qw/independent parametric/) {
365 82 50       201 $args{$_} = 1 if !defined $args{$_};
366             }
367 41 100       84 $args{'ordinal'} = 0 if !defined $args{'ordinal'};
368            
369 41 100       121 if ( !$self->{'_cleared'} ) {
370 2         21 $self->{$_} = undef foreach
371             qw/df_b df_w f_value chi_value h_value j_value j_exp j_var l_value l_exp l_var z_value p_value ss_b ss_w ms_b ms_w eta_sq omega_sq purged/;
372 2         4 $self->{'_cleared'} = 1;
373             }
374            
375 41 100       66 if ( $args{'independent'} ) {
376 23         66 _aov_indep( $self, %args );
377             }
378             else {
379 18         50 _aov_rmdep( $self, %args );
380             }
381 41 100       128 return wantarray ? %{ $self->{'_stat'} } : $self;
  9         57  
382             }
383             *aov = \&anova;
384             *test = \&anova;
385            
386             sub _aov_indep {
387 23     23   41 my ( $self, %args ) = @_;
388 23         82 my $data = $self->get_hoa_numonly_indep(%args);
389             croak 'Not enough variables for performing ANOVA'
390 23 50       3005 if scalar keys %{$data} < 2;
  23         66  
391 23 50   82   57 if ( any { !scalar @{ $data->{$_} } } keys %{$data} ) {
  82         71  
  82         117  
  23         101  
392 0         0 croak 'Empty data following purge of invalid value(s)';
393             }
394 23 100       89 if ( $args{'parametric'} ) {
395 16 100       35 if ( !$args{'ordinal'} ) {
396             (
397             $self->{'_stat'}->{'f_value'},
398             $self->{'_stat'}->{'df_b'}, $self->{'_stat'}->{'df_w'},
399             $self->{'_stat'}->{'ss_b'}, $self->{'_stat'}->{'ss_w'},
400             $self->{'_stat'}->{'ms_b'}, $self->{'_stat'}->{'ms_w'},
401 11         23 $self->{'_stat'}->{'p_value'},
402            
403             ) = _aov_indep_param_cat($data);
404 11         19 $self->{'_dfree'} = 0;
405             }
406             else {
407 5 100       9 if ( $args{'ordinal'} == 1 ) {
408 3         11 $self->_aov_indep_param_ord_linear($data);
409             }
410             else {
411 2         6 $self->_aov_indep_param_ord_nonlinear($data);
412             }
413             }
414             }
415             else {
416 7 50       26 $args{'correct_ties'} = 1 if !defined $args{'correct_ties'};
417 7 100       16 if ( !$args{'ordinal'} ) {
418 4 100       17 $args{'f_equiv'} = 0 if !defined $args{'f_equiv'};
419             $self->_aov_indep_dfree_cat( $data, $args{'correct_ties'},
420 4         21 $args{'f_equiv'} );
421             }
422             else {
423 3 50       10 $args{'tails'} = 2 if !defined $args{'tails'};
424             (
425             $self->{'_stat'}->{'j_value'}, $self->{'_stat'}->{'j_exp'},
426             $self->{'_stat'}->{'j_var'}, $self->{'_stat'}->{'z_value'},
427             $self->{'_stat'}->{'p_value'}
428             )
429             = _aov_indep_dfree_ord( $data, $args{'correct_ties'},
430 3         11 $args{'tails'} );
431             }
432             }
433 23         87 return;
434             }
435            
436             sub _aov_rmdep {
437 18     18   37 my ( $self, %args ) = @_;
438 18         78 my $data = $self->get_hoa_numonly_across(%args);
439 18         2181 my $n_bt = scalar keys %{$data};
  18         29  
440 18 50       45 croak 'Not enough variables for performing ANOVA'
441             if $n_bt < 2;
442 18         60 my $n_wt = $self->equal_n( data => $data );
443 18 50 33     361 croak
444             'Number of observations per variable need to be equal and greater than 1 for repeated measures ANOVA'
445             if !$n_wt or $n_wt == 1;
446 18 100       35 if ( $args{'parametric'} ) {
447 10 100       22 if ( !$args{'ordinal'} ) {
448             (
449             $self->{'_stat'}->{'f_value'}, $self->{'_stat'}->{'df_b'},
450             $self->{'_stat'}->{'df_w'}, $self->{'_stat'}->{'ss_b'},
451             $self->{'_stat'}->{'ss_w'}, $self->{'_stat'}->{'ms_b'},
452 9         22 $self->{'_stat'}->{'ms_w'}, $self->{'_stat'}->{'p_value'}
453             ) = _aov_rmdep_cat_param( $data, $n_bt, $n_wt );
454 9         15 $self->{'_dfree'} = 0;
455             }
456             else {
457 1         3 _aov_rmdep_ord_param( $data, $n_bt, $n_wt );
458             }
459             }
460             else {
461 8 100       19 if ( !$args{'ordinal'} ) {
462 6 100       13 $args{'correct_ties'} = 1 if !defined $args{'correct_ties'};
463 6 50       11 $args{'f_equiv'} = 0 if !defined $args{'f_equiv'};
464 6 100       9 if ( $args{'f_equiv'} ) {
465             (
466             $self->{'_stat'}->{'f_value'},
467             $self->{'_stat'}->{'df_b'},
468             $self->{'_stat'}->{'df_w'},
469             $self->{'_stat'}->{'p_value'}
470             )
471 1         3 = _aov_rmdep_cat_dfree_fequiv( $data, $args{'correct_ties'} );
472 1         2 $self->{'_dfree'} = 1;
473             }
474             else {
475             (
476             $self->{'_stat'}->{'chi_value'},
477             $self->{'_stat'}->{'df_b'}, $self->{'_stat'}->{'count'},
478             $self->{'_stat'}->{'p_value'},
479            
480 5         12 ) = _aov_rmdep_cat_dfree( $data, $args{'correct_ties'} );
481 5         11 $self->{'_dfree'} = 1;
482             }
483             }
484             else {
485 2 50       7 $args{'tails'} = 2 if !defined $args{'tails'};
486             (
487             $self->{'_stat'}->{'l_value'}, $self->{'_stat'}->{'l_exp'},
488             $self->{'_stat'}->{'l_var'}, $self->{'_stat'}->{'z_value'},
489             $self->{'_stat'}->{'p_value'}, $self->{'_stat'}->{'r_value'}
490 2         9 ) = _aov_rmdep_ord_dfree( $data, $args{'tails'} );
491 2         6 $self->{'_dfree'} = 1;
492             }
493             }
494 18         42 return;
495             }
496            
497             sub _aov_indep_param_cat {
498 16     16   16 my ($data) = @_;
499 16         43 my ( $ss_w, $df_w ) = _sumsq_w_indep_param($data);
500 16 50 33     50 croak 'No within-groups data for performing ANOVA' if !$ss_w || !$df_w;
501 16         31 my $ss_b = _sumsq_b_indep_param_cat($data);
502 16         43 my $df_b = _df_b_indep_param_cat($data); # a - 1
503 16         19 my $ms_b = $ss_b / $df_b;
504 16         15 my $ms_w = $ss_w / $df_w;
505 16         16 my $f_value = $ms_b / $ms_w;
506 16         216 my $p_value = fdtrc( $df_b, $df_w, $f_value );
507 16         78 return ( $f_value, $df_b, $df_w, $ss_b, $ss_w, $ms_b, $ms_w, $p_value );
508             }
509            
510             sub _aov_indep_param_ord_linear {
511 3     3   4 my ( $self, $data ) = @_;
512 3         8 my ( $ss_w, $df_w ) = _sumsq_w_indep_param($data);
513 3 50 33     9 croak 'No within-groups data for performing ANOVA' if !$ss_w || !$df_w;
514 3         7 my $ss_l = _sumsq_b_indep_param_ord($data);
515 3         7 my $df_b = _df_b_indep_param_ord_linear($data); # a - 1
516 3         5 my $ms_w = $ss_w / $df_w;
517 3         2 my $f_value = $ss_l / $ms_w;
518 3         42 my $p_value = fdtrc( $df_b, $df_w, $f_value ); # Math::Cephes function
519             (
520             $self->{'_stat'}->{'f_value'}, $self->{'_stat'}->{'df_b'},
521             $self->{'_stat'}->{'df_w'}, $self->{'_stat'}->{'ss_b'},
522             $self->{'_stat'}->{'ss_w'}, $self->{'_stat'}->{'ms_w'},
523 3         15 $self->{'_stat'}->{'p_value'}, $self->{'_dfree'}
524             ) = ( $f_value, $df_b, $df_w, $ss_l, $ss_w, $ms_w, $p_value, 0 );
525 3         6 return;
526             }
527            
528             sub _aov_indep_param_ord_nonlinear {
529 2     2   4 my ( $self, $data ) = @_;
530 2         5 my ( $ss_w, $df_w ) = _sumsq_w_indep_param($data);
531 2 50 33     9 croak 'No within-groups data for performing ANOVA' if !$ss_w || !$df_w;
532 2         6 my $df_b = _df_b_indep_param_ord_nonlinear($data);
533 2         6 my $ss_b = _sumsq_b_indep_param_ord_nonlinear($data); # a - 2
534 2         4 my $ms_b = $ss_b / $df_b;
535 2         3 my $ms_w = $ss_w / $df_w;
536 2         4 my $f_value = $ms_b / $ms_w;
537 2         10 my $p_value = fdtrc( $df_b, $df_w, $f_value ); # Math::Cephes function
538             (
539             $self->{'_stat'}->{'f_value'}, $self->{'_stat'}->{'df_b'},
540             $self->{'_stat'}->{'df_w'}, $self->{'_stat'}->{'ss_b'},
541             $self->{'_stat'}->{'ss_w'}, $self->{'_stat'}->{'ms_b'},
542             $self->{'_stat'}->{'ms_w'}, $self->{'_stat'}->{'p_value'},
543 2         12 $self->{'_dfree'}
544             ) = ( $f_value, $df_b, $df_w, $ss_b, $ss_w, $ms_b, $ms_w, $p_value, 0 );
545 2         4 return;
546             }
547            
548             sub _aov_indep_dfree_cat {
549 4     4   5 my ( $self, $data, $correct_ties, $f_equiv ) = @_;
550 4         7 eval { require Statistics::ANOVA::KW; };
  4         1259  
551 4 50       2610 croak
552             'Don\'t know how to run Kruskall-Wallis test. Maybe you need to install Statistics::ANOVA::KW.'
553             if $@;
554 4         21 my $kw = Statistics::ANOVA::KW->new();
555 4         45 $kw->load_data($data);
556 4 100       626 if ($f_equiv) {
557 1         4 my ( $f_value, $df_b, $df_w, $p_value ) =
558             $kw->fprob_test( correct_ties => $correct_ties );
559             (
560             $self->{'_stat'}->{'f_value'}, $self->{'_stat'}->{'df_b'},
561             $self->{'_stat'}->{'df_w'}, $self->{'_stat'}->{'p_value'},
562 1         11 $self->{'_dfree'}
563             ) = ( $f_value, $df_b, $df_w, $p_value, 0 );
564             }
565             else {
566 3         11 my ( $chi_value, $df, $count, $p_value ) =
567             $kw->chiprob_test( correct_ties => $correct_ties );
568             (
569             $self->{'_stat'}->{'h_value'}, $self->{'_stat'}->{'df_b'},
570             $self->{'_stat'}->{'count'}, $self->{'_stat'}->{'p_value'},
571 3         2405 $self->{'_dfree'}
572             ) = ( $chi_value, $df, $count, $p_value, 1 );
573             }
574 4         27 return;
575             }
576            
577             sub _aov_indep_dfree_ord {
578 3     3   4 my ( $data, $correct_ties, $tails ) = @_;
579 3         3 eval { require Statistics::ANOVA::JT; };
  3         1111  
580 3 50       8035 croak
581             'Don\'t know how to run Jonckheere-Terpstra test. Maybe you need to install Statistics::ANOVA::JT.'
582             if $@;
583 3         21 my $jt = Statistics::ANOVA::JT->new();
584 3         35 $jt->load_data($data);
585 3         300 my $j_obs = $jt->observed();
586 3         1716 my $j_exp = $jt->expected();
587 3         186 my $j_var = $jt->variance( correct_ties => $correct_ties );
588 3         894 my ( $z_value, $p_value ) = $jt->zprob_test(
589             correct_ties => $correct_ties,
590             tails => $tails
591             );
592 3         7423 return ( $j_obs, $j_exp, $j_var, $z_value, $p_value );
593             }
594            
595             sub _aov_rmdep_cat_param {
596 9     9   9 my ( $data, $n_bt, $n_wt, ) = @_;
597 9         27 my ( $ss_b, $ss_w, $df_b, $df_w ) =
598             _sumsq_bw_rmdep_param_uni( $data, $n_bt, $n_wt );
599 9         14 my $ms_b = $ss_b / $df_b;
600 9         9 my $ms_w = $ss_w / $df_w;
601 9         9 my $f_value = $ms_b / $ms_w;
602 9         131 my $p_value = fdtrc( $df_b, $df_w, $f_value ); # Math::Cephes
603 9         52 return ( $f_value, $df_b, $df_w, $ss_b, $ss_w, $ms_b, $ms_w, $p_value );
604             }
605            
606             sub _aov_rmdep_ord_param {
607 1     1   162 carp
608             ':-( Parametric trend analysis for dependent/repeated measures is not implemented';
609 1         114 return;
610             }
611            
612             sub _aov_rmdep_cat_dfree {
613 5     5   7 my ( $data, $correct_ties ) = @_;
614 5         4 eval { require Statistics::ANOVA::Friedman; };
  5         892  
615 5 50       1970 croak
616             'Don\'t know how to do Friedman ANOVA. Perhaps you need to install Statistics::ANOVA::Friedman.'
617             if $@;
618 5         16 my ( $chi, $df, $count, $p_value ) =
619             Statistics::ANOVA::Friedman->chiprob_test(
620             data => $data,
621             correct_ties => $correct_ties
622             );
623 5         2151 return ( $chi, $df, $count, $p_value );
624             }
625            
626             sub _aov_rmdep_cat_dfree_fequiv {
627 1     1   2 my ( $data, $correct_ties ) = @_;
628 1         1 eval { require Statistics::ANOVA::Friedman; };
  1         5  
629 1 50       3 croak
630             'Don\'t know how to do Friedman ANOVA. Perhaps you need to install Statistics::ANOVA::Friedman.'
631             if $@;
632 1         3 my ( $f_value, $df_b, $df_w, $p_value ) =
633             Statistics::ANOVA::Friedman->fprob_test(
634             data => $data,
635             correct_ties => $correct_ties
636             );
637 1         213 return ( $f_value, $df_b, $df_w, $p_value );
638             }
639            
640             sub _aov_rmdep_ord_dfree {
641 2     2   3 my ( $data, $tails ) = @_;
642 2         7 eval { require Statistics::ANOVA::Page; };
  2         1055  
643 2 50       4379 croak
644             'Don\'t know how to do Page ANOVA. Perhaps you need to install Statistics::ANOVA::Page.'
645             if $@;
646 2         14 my $page = Statistics::ANOVA::Page->new();
647 2         26 $page->load_data($data);
648 2         230 my $l_obs = $page->observed();
649 2         551 my $l_exp = $page->expected();
650 2         185 my $l_var = $page->variance();
651 2         131 my ( $z_value, $p_value ) = $page->zprob_test( tails => $tails );
652 2         702 my $r_value = $page->observed_r();
653 2         521 return ( $l_obs, $l_exp, $l_var, $z_value, $p_value, $r_value, 1 );
654             }
655            
656             =head3 Tests for equality of variances
657            
658             =head4 obrien
659            
660             $aov->obrien()
661            
662             I: obrien_test
663            
664             Performs B (1981) test for equality of variances within each variable: based on transforming each observation in relation to its variance and its deviation from its mean; and performing an ANOVA on these values (for which the mean is equal to the variance of the original observations). The procedure is recognised to be robust against violations of normality (unlike I-max) (Maxwell & Delaney, 1990).
665            
666             The statistical attributes now within the class object (see L) pertain to this test, e.g., $aov->{'f_value'} gives the I-statistic for O'Brien's Test; and $aov->{'p_value'} gives the I

-value associated with the I-statistic for O'Brien's Test.

667            
668             =cut
669            
670             sub obrien {
671 3     3 1 267 my ( $self, %args ) = @_;
672            
673             #ref $self->{'data'} eq 'HASH' ? %{$self->{'data'}} : croak 'No reference to a hash of data for performing ANOVA';
674 3         15 my $tdata = $self->get_hoa_numonly_indep(%args); # List-wise clean-up
675             croak 'Not enough variables for performing ANOVA'
676 3 50       315 if scalar( keys( %{$tdata} ) ) <= 1;
  3         10  
677 3 50   11   10 if ( any { !scalar @{ $tdata->{$_} } } keys %{$tdata} ) {
  11         7  
  11         16  
  3         20  
678 0         0 croak 'Empty data following purge of invalid value(s)';
679             }
680 3         9 my ( $m, $v, $n, $sname, $sdata, @r, @data ) = ();
681 3         5 $self->{'obrien'} = {};
682            
683             # Traverse each sample of data:
684 3         3 while ( ( $sname, $sdata ) = each %{$tdata} ) {
  14         296  
685            
686             # For each var, compute the sample mean and the unbiased sample variance:
687             ( $m, $v, $n ) =
688 11         8 ( mean( @{$sdata} ), variance( @{$sdata} ), count( @{$sdata} ) );
  11         22  
  11         507  
  11         430  
689            
690             # Transform each observation:
691 11         60 foreach ( @{$sdata} ) {
  11         14  
692 55         88 push @r,
693             (
694             (
695             ( ( $n - 1.5 ) * $n * ( ( $_ - $m )**2 ) ) -
696             ( .5 * $v * ( $n - 1 ) )
697             ) / ( ( $n - 1 ) * ( $n - 2 ) )
698             );
699             }
700 11         20 $self->{'obrien'}->{$sname} = [@r];
701 11         12 @r = ();
702            
703             # Check that each variable mean of the O'Briens are equal to the variance of the original data:
704 11 50       8 if (
705 11         26 sprintf( '%.2f', mean( @{ $self->{'obrien'}->{$sname} } ) ) !=
706             sprintf( '%.2f', $v ) )
707             {
708 0         0 croak "Mean for sample $sname does not equal variance";
709             }
710             }
711            
712             # Perform an ANOVA using the O'Brien values as the DV:
713             (
714             $self->{'_stat'}->{'f_value'},
715             $self->{'_stat'}->{'df_b'}, $self->{'_stat'}->{'df_w'},
716             $self->{'_stat'}->{'ss_b'}, $self->{'_stat'}->{'ss_w'},
717             $self->{'_stat'}->{'ms_b'}, $self->{'_stat'}->{'ms_w'},
718             $self->{'_stat'}->{'p_value'},
719            
720 3         9 ) = _aov_indep_param_cat( $self->{'obrien'} );
721 3         10 $self->{'_dfree'} = 0;
722 3 100       9 return wantarray ? %{ $self->{'_stat'} } : $self;
  2         15  
723             }
724             *obrien_test = \&obrien; # Alias
725            
726             =head4 levene
727            
728             $aov->levene()
729            
730             I: levene_test
731            
732             Performs B (1960) test for equality of variances within each variable: an ANOVA of the absolute deviations, i.e., absolute value of each observation less its mean.
733            
734             The statistical attributes now within the class object (see L) pertain to this test, e.g., $aov->{'f_value'} gives the I-statistic for Levene's Test; and $aov->{'p_value'} gives the I

-value associated with the I-statistic for Levene's Test.

735            
736             =cut
737            
738             sub levene {
739 2     2 1 910 my ( $self, %args ) = @_;
740            
741             #ref $self->{'data'} eq 'HASH' ? %{$self->{'data'}} : croak 'No reference to an associative array for performing ANOVA';
742 2         13 my $tdata = $self->get_hoa_numonly_indep(%args); # List-wise clean-up
743             croak 'Not enough variables for performing ANOVA'
744 2 50       295 if scalar( keys( %{$tdata} ) ) <= 1;
  2         10  
745 2 50   7   8 if ( any { !scalar @{ $tdata->{$_} } } keys %{$tdata} ) {
  7         7  
  7         10  
  2         13  
746 0         0 croak 'Empty data following purge of invalid value(s)';
747             }
748 2         6 my ( $m, $v, $n, @d ) = ();
749 2         4 $self->{'levene'} = {};
750            
751             # Traverse each sample of data:
752 2         4 while ( my ( $sname, $sdata ) = each %{$tdata} ) {
  9         34  
753            
754             # For each variable, compute the sample mean and the unbiased sample variance:
755 7         5 $m = mean( @{$sdata} );
  7         19  
756 7         209 $v = variance( @{$sdata} );
  7         16  
757 7         391 $n = count( @{$sdata} );
  7         13  
758            
759             # For each observation, compute the absolute deviation:
760 7         50 my $m = mean( @{$sdata} );
  7         11  
761 7         165 push @d, abs( $_ - $m ) foreach @{$sdata};
  7         39  
762 7         20 $self->{'levene'}->{$sname} = [@d];
763 7         12 @d = ();
764             }
765            
766             # Perform an ANOVA using the abs. deviations as the DV:
767             (
768             $self->{'_stat'}->{'f_value'},
769             $self->{'_stat'}->{'df_b'}, $self->{'_stat'}->{'df_w'},
770             $self->{'_stat'}->{'ss_b'}, $self->{'_stat'}->{'ss_w'},
771             $self->{'_stat'}->{'ms_b'}, $self->{'_stat'}->{'ms_w'},
772             $self->{'_stat'}->{'p_value'},
773            
774 2         11 ) = _aov_indep_param_cat( $self->{'levene'} );
775 2         4 $self->{'_dfree'} = 0;
776 2 50       13 return wantarray ? %{ $self->{'_stat'} } : $self;
  0         0  
777             }
778             *levene_test = \&levene; # Alias
779            
780             =head2 MEASURING EFFECT
781            
782             Follow-up parametric ANOVAs. Note that for the one-way ANOVAs here tested, eta-squared is the same as partial eta-squared.
783            
784             =head3 eta_squared
785            
786             $etasq = $aov->eta_squared(independent => BOOL, parametric => BOOL, ordinal => BOOL);
787            
788             Returns the effect size estimate (partial) eta-squared, calculated using sums-of-squares via L. Also feeds $aov with the value, named 'eta_sq'.
789            
790             =cut
791            
792             sub eta_squared {
793 2     2 1 3935 my ( $self, @args ) = @_;
794 2         7 eval { require Statistics::ANOVA::EffectSize; };
  2         1019  
795 2 50       18 croak
796             'Don\'t know how to do ANOVA effect-sizes. Perhaps you need to install Statistics::ANOVA::EffectSize.'
797             if $@;
798 2         7 my $etasq = Statistics::ANOVA::EffectSize->eta_sq_partial_by_ss(
799             $self->anova(@args) );
800 2         5 $self->{'_stat'}->{'eta_sq'} = $etasq;
801 2         6 return $etasq;
802             }
803            
804             =head3 omega_squared
805            
806             Returns the effect size estimate (partial) omega-squared, calculated using mean sums-of-squares via L. Also feeds $aov with the value, named 'omega_sq'.
807            
808             =cut
809            
810             sub omega_squared {
811 1     1 1 591 my ( $self, %args ) = @_;
812 1         2 eval { require Statistics::ANOVA::EffectSize; };
  1         5  
813 1 50       4 croak
814             'Don\'t know how to do ANOVA effect-sizes. Perhaps you need to install Statistics::ANOVA::EffectSize.'
815             if $@;
816 1         1 my $n = sum0( map { count( @{$_} ) } @{ $self->get_aoa() } );
  4         82  
  4         9  
  1         8  
817 1         15 my $omg_sq = Statistics::ANOVA::EffectSize->omega_sq_partial_by_ss(
818             $self->anova(%args) );
819 1         3 $self->{'_stat'}->{'omega_sq'} = $omg_sq;
820 1         2 return $omg_sq;
821             }
822            
823             =head2 IDENTIFYING RELATIONSHIPS/DIFFERENCES
824            
825             =head3 compare
826            
827             $aov->compare(independent => 1|0, parametric => 1|0, tails => 2|1, flag => 0|1, alpha => .05,
828             adjust_p => 0|1, adjust_e => 1|0|2, use_t => 0|1, dump => 0|1, str => 0|1)
829            
830             Performs all possible pairwise comparisons, with the Bonferroni approach to control experiment-wise error-rate. The particular tests depend on whether or not you want parametric (default) or nonparametric tests, and if the observations have been made independently (between groups, the default) or by repeated measures. See L.
831            
832             =cut
833            
834             sub compare {
835 5     5 1 2857 my ( $self, %args ) = @_;
836 5         6 eval { require Statistics::ANOVA::Compare; };
  5         1431  
837 5 50       19 croak
838             'Don\'t know how to do ANOVA comparisons. Perhaps you need to install Statistics::ANOVA::Compare.'
839             if $@;
840 5         29 my $cmp = Statistics::ANOVA::Compare->new();
841 5         55 $cmp->share($self);
842 5         1189 return $cmp->run(%args);
843             }
844            
845             =head3 confidence
846            
847             $itv_str = $aov->(independent => 1|0, alpha => .05, name => 'aname', limits => 0) # get interval for single variable as string
848             $lim_aref = $aov->(independent => 1|0, alpha => .05, name => 'aname', limits => 1) # get upper & lower limits for single variable as aref
849             $itv_href = $aov->(independent => 1|0, alpha => .05, name => ['aname', 'bname'], limits => 0) # get interval for 2 variables as hashref keyed by variable names
850             $lim_href = $aov->(independent => 1|0, alpha => .05, name => ['aname','bname'], limits => 1) # get upper & lower limits for 2 variables as hashref of variable-named arefs
851             $itv_href = $aov->(independent => 1|0, alpha => .05, name => undef, limits => 0) # get intervals for all variables as hashref keyed by variable names
852             $lim_href = $aov->(independent => 1|0, alpha => .05, name => undef, limits => 1) # upper & lower limits for all variables as hashref
853            
854             Computes confidence intervals using (by default) the pooled estimate of variability over groups/levels, rather than the standard error within each group/level, as described by Masson and Loftus (2003). For a between groups design, the confidence interval (as usual) indicates that, at a certain level of probability, the true population mean is likely to be within the interval returned. For a within-subjects design, as any effect of the variability between subjects is eliminated, the confidence interval (alternatively) indicates the reliability of the how the sample means are distributed as an estimate of the how the population means are distributed.
855            
856             In either case, there is an assumption that the variances within each condition are the same between the conditions (homogeneity of variances assumption).
857            
858             Actual algorithm depends on whether the measures are obtained from indepedently (between-groups) (independent => 1) or by repeated measures (independent => 0) (i.e., whether between-groups or within-groups design). Default is between-groups.
859            
860             The option C can be set to equal 0 so that the (typical) standard error of the mean is used in place of the mean-square error. This is one option to use when the variances are unequal.
861            
862             The option C can, optionally, include a referenced array naming the particular conditions that should be included when calculating I. By default, this is all the conditions, using I from the omnibus ANOVA. This is one option to handle the case of unequal variances between conditions.
863            
864             =cut
865            
866             sub confidence {
867 2     2 1 919 my ( $self, %args ) = @_;
868            
869             croak 'Need to run ANOVA to obtain requested statistic'
870             if !defined $self->{'_stat'}->{'df_w'}
871 2 50 33     11 || !defined $self->{'_stat'}->{'ms_w'};
872            
873 2         5 my $data = $self->get_hoa_numonly_indep(); # List-wise clean-up of all data
874             croak 'Not enough variables for performing ANOVA'
875 2 50       222 if scalar( keys( %{$data} ) ) <= 1;
  2         6  
876 2 50   6   5 if ( any { !scalar @{ $data->{$_} } } keys %{$data} ) {
  6         3  
  6         14  
  2         5  
877 0         0 croak 'Empty data following purge of invalid value(s)';
878             }
879            
880             # Init key params:
881 2 50       6 my $indep = defined $args{'independent'} ? $args{'independent'} : 1;
882 2         6 my $alpha = _init_alpha( $args{'alpha'} ); # default = .05
883 2         154 my $tcrit = abs( stdtri( $self->{'_stat'}->{'df_w'}, $alpha / 2 ) );
884 2 50       5 my $limits = delete $args{'limits'} or 0;
885 2 50       4 my $use_mse = defined $args{'use_mse'} ? $args{'use_mse'} : 1;
886             my @names =
887             defined $args{'name'}
888             ? ref $args{'name'}
889 0         0 ? @{ $args{'name'} }
890             : ( $args{'name'} )
891 2 50       6 : keys( %{$data} );
  0 50       0  
892             my @conditions =
893 2 50       12 ref $args{'conditions'} ? @{ $args{'conditions'} } : @names;
  0         0  
894 2         3 my ( $erv, $itv, %confints ) = ();
895            
896 2         3 foreach (@names) {
897 2 50       3 if ($use_mse) {
898 2         1 my $mse;
899 2         14 $mse = $self->{'_stat'}->{'ms_w'};
900 2         3 $erv = sqrt( $mse / count( @{ $data->{$_} } ) );
  2         6  
901             }
902             else {
903             $erv =
904 0         0 stddev( @{ $data->{$_} } ) / sqrt( count( @{ $data->{$_} } ) );
  0         0  
  0         0  
905             }
906 2         15 $itv = $erv * $tcrit;
907 2 50       5 if ($limits) {
908             $confints{$_} = [
909 0         0 mean( @{ $data->{$_} } ) - $itv,
910 0         0 mean( @{ $data->{$_} } ) + $itv
  0         0  
911             ];
912             }
913             else {
914 2         4 $confints{$_} = $itv;
915             }
916             }
917 2 50       14 return scalar( keys(%confints) ) > 1 ? \%confints : $confints{ $names[0] };
918             }
919            
920             =head2 ACCESSING RESULTS
921            
922             =head3 string
923            
924             $str = $aov->string(mse => 1, eta_squared => 1, omega_squared => 1, precision_p => integer, precision_s => integer)
925            
926             Returns a statement of result, in the form of C; or, for Friedman test C (to the value of I, if any); and so on for other test statistics. Optionally also get MSe, eta_squared and omega_squared values appended to the string, where relevant. These and the test statistic are "sprintf"'d to the I specified (or, by default, not at all).
927            
928             =cut
929            
930             sub string {
931 0     0 1 0 my ( $self, %args ) = @_;
932 0         0 my $str;
933             my $p_value =
934             $args{'precision_p'}
935             ? sprintf(
936             '%.' . $args{'precision_p'} . 'f',
937             $self->{'_stat'}->{'p_value'}
938             )
939 0 0       0 : $self->{'_stat'}->{'p_value'};
940 0   0     0 my $precision_s = $args{'precision_s'} || 0;
941 0 0 0     0 if ( defined $self->{'_stat'}->{'f_value'} && !$self->{'_dfree'} ) {
    0          
    0          
    0          
    0          
942 0         0 $str .= "F($self->{'_stat'}->{'df_b'}, $self->{'_stat'}->{'df_w'}) = ";
943 0         0 $str .= _precisioned( $precision_s, $self->{'_stat'}->{'f_value'} );
944 0         0 $str .= ", p = $p_value,";
945             $str .=
946             ' MSe = '
947             . _precisioned( $precision_s, $self->{'_stat'}->{'ms_w'} ) . ','
948 0 0       0 if $args{'mse'};
949             $str .=
950             ' eta^2_p = '
951             . _precisioned( $precision_s, $self->eta_squared() ) . ','
952 0 0       0 if $args{'eta_squared'};
953             $str .=
954             ' omega^2_p = '
955             . _precisioned( $precision_s, $self->omega_squared() ) . ','
956 0 0       0 if $args{'omega_squared'};
957 0         0 chop($str);
958             }
959             elsif ( defined $self->{'_stat'}->{'h_value'} ) { # Kruskal-Wallis statistic
960 0         0 $str .= "H($self->{'_stat'}->{'df_b'}) = ";
961 0         0 $str .= _precisioned( $precision_s, $self->{'_stat'}->{'h_value'} );
962 0         0 $str .= ", p = $p_value";
963             }
964             elsif ( defined $self->{'_stat'}->{'j_value'} )
965             { # Jonckheere-Terpstra statistic
966 0         0 $str .= "J = ";
967 0         0 $str .= _precisioned( $precision_s, $self->{'_stat'}->{'j_value'} );
968 0         0 $str .= ", p = $p_value";
969             }
970             elsif ( defined $self->{'_stat'}->{'l_value'} ) { # Page statistic
971 0         0 $str .= "L = ";
972 0         0 $str .= _precisioned( $precision_s, $self->{'_stat'}->{'l_value'} );
973 0         0 $str .= ", p = $p_value";
974             }
975             elsif ( defined $self->{'_stat'}->{'chi_value'} ) { # Friedman statistic
976 0         0 $str .=
977             "chi^2($self->{'_stat'}->{'df_b'}, N = $self->{'_stat'}->{'count'}) = ";
978 0         0 $str .= _precisioned( $precision_s, $self->{'_stat'}->{'chi_value'} );
979 0         0 $str .= ", p = $p_value";
980             }
981             else {
982 0         0 croak 'Need to run omnibus test (anova) to obtain results string';
983             }
984 0         0 return $str;
985             }
986            
987             =head3 table
988            
989             $table = $aov->table(precision_p => integer, precision_s => integer);
990            
991             Returns a table listing the degrees of freedom, sums of squares, and mean squares for the tested "factor" and "error" (between/within variables), and the I- and I

-values. The test statistics are "sprintf"'d to the I specified (or, by default, not at all); the p value's precision can be specified by I.

992            
993             Up to this version, if calculating any of these values was not essential to calculation of the test statistic, the value will simply appear as a blank in the table. If the omnibus test last made was non-parametric, and no I-value was calculated, then the table returned is entirely an empty string.
994            
995             Formatting with right-justification where appropriate is left for user-joy.
996            
997             =cut
998            
999             sub table {
1000 8     8 1 10 my ( $self, %args ) = @_;
1001 8         10 my $tbl = q{};
1002 8   50     24 my $precision_p = $args{'precision_p'} || 0;
1003 8   50     21 my $precision_s = $args{'precision_s'} || 0;
1004            
1005             # F-table:
1006 8 100 66     31 if ( defined $self->{'_stat'}->{'f_value'} && !$self->{'_dfree'} ) {
1007 4         12 $tbl .= "\t$_" foreach ( 'df', 'SumSq', 'MeanSq', 'F', 'Pr(>F)' );
1008 4 50       10 $tbl .= "\teta^2_p" if defined $self->{'_stat'}->{'eta_sq'};
1009 4 50       5 $tbl .= "\tomega^2_p" if defined $self->{'_stat'}->{'omega_sq'};
1010 4         5 $tbl .= "\n";
1011 4         7 $tbl .= "$_\t" foreach ( 'Factor', $self->{'_stat'}->{'df_b'} );
1012             $tbl .= _precisioned( $precision_s, $_ )
1013 4         10 . "\t" foreach (
1014             $self->{'_stat'}->{'ss_b'},
1015             $self->{'_stat'}->{'ms_b'},
1016             $self->{'_stat'}->{'f_value'}
1017             );
1018 4         5 for my $es (qw/eta_sq omega_sq/) {
1019             $tbl .= "\t" . _precisioned( $precision_s, $self->{'_stat'}->{$es} )
1020 8 50       14 if defined $self->{'_stat'}->{$es};
1021             }
1022 4         5 $tbl .= _precisioned( $precision_p, $self->{'_stat'}->{'p_value'} );
1023 4         4 $tbl .= "\n";
1024 4         10 $tbl .= "$_\t" foreach ( 'Error', $self->{'_stat'}->{'df_w'} );
1025             $tbl .= _precisioned( $precision_s, $_ ) . "\t"
1026 4         8 foreach ( $self->{'_stat'}->{'ss_w'}, $self->{'_stat'}->{'ms_w'} );
1027 4         4 $tbl .= "\n";
1028             }
1029 8         13 return $tbl;
1030             }
1031            
1032             =head3 dump
1033            
1034             $aov->dump(title => 'ANOVA test', precision_p => integer, precision_s => integer, mse => 1, eta_squared => 1, omega_squared => 1, verbose => 1)
1035            
1036             Prints the string returned by L, or, if specified with the attribute I => 1, the table returned by L; and the string as well if I => 1. A newline - "\n" - is appended at the end of the print of the string. Above this string or table, a title can also be printed, by giving a value to the optional C attribute. </td> </tr> <tr> <td class="h" > <a name="1037">1037</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1038">1038</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> If I<verbose> => 1, then any curiosities arising in the calculations are noted at the end of other dumps. At the moment, this is only the number of observations that might have been purged were they identified as undefined or not-a-number upon loading/adding. </td> </tr> <tr> <td class="h" > <a name="1039">1039</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1040">1040</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1041">1041</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1042">1042</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub dump { </td> </tr> <tr> <td class="h" > <a name="1043">1043</a> </td> <td class="c0" > <a href="#1044"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1043-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1043-1"> 1 </a> </td> <td > 0 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1044">1044</a> </td> <td class="c0" > <a href="#1045"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1044-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> print "$args{'title'}\n" if $args{'title'}; </td> </tr> <tr> <td class="h" > <a name="1045">1045</a> </td> <td class="c0" > <a href="#1046"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1045-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( $args{'table'} ) { </td> </tr> <tr> <td class="h" > <a name="1046">1046</a> </td> <td class="c0" > <a href="#1047"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> print $self->table(%args); </td> </tr> <tr> <td class="h" > <a name="1047">1047</a> </td> <td class="c0" > <a href="#1050"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1047-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> print $self->string(%args), "\n" if $args{'string'}; </td> </tr> <tr> <td class="h" > <a name="1048">1048</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1049">1049</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1050">1050</a> </td> <td class="c0" > <a href="#1054"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> print $self->string(%args), "\n"; </td> </tr> <tr> <td class="h" > <a name="1051">1051</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1052">1052</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> print "Observations purged as undefined or not-a-number: " </td> </tr> <tr> <td class="h" > <a name="1053">1053</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> . $self->{'purged'} . "\n" </td> </tr> <tr> <td class="h" > <a name="1054">1054</a> </td> <td class="c0" > <a href="#1055"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1054-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1054-1"> 0 </a> </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if $self->{'purged'} && $args{'verbose'}; </td> </tr> <tr> <td class="h" > <a name="1055">1055</a> </td> <td class="c0" > <a href="#1082"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return; </td> </tr> <tr> <td class="h" > <a name="1056">1056</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1057">1057</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1058">1058</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head2 STATISTICS </td> </tr> <tr> <td class="h" > <a name="1059">1059</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1060">1060</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 ss_total </td> </tr> <tr> <td class="h" > <a name="1061">1061</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1062">1062</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ss_tot = $aov(independent => BOOL, ordinal => BOOL); </td> </tr> <tr> <td class="h" > <a name="1063">1063</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ($ss_tot, $s_b, $ss_w) = $aov(independent => BOOL, ordinal => BOOL); </td> </tr> <tr> <td class="h" > <a name="1064">1064</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1065">1065</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Returns the total sum-of-squares, being the sum of the between- and within-groups sums-of-squares, and so definable as the "corrected" total sum-of-squares. Called in array context, also returns the between- and within-groups sums-of-squares themselves. </td> </tr> <tr> <td class="h" > <a name="1066">1066</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1067">1067</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1068">1068</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1069">1069</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub ss_total { </td> </tr> <tr> <td class="h" > <a name="1070">1070</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1070-1"> 1 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1070-1"> 1 </a> </td> <td > 191 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1071">1071</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1071-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> $args{'independent'} = 1 if !defined $args{'independent'}; </td> </tr> <tr> <td class="h" > <a name="1072">1072</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1072-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> $args{'ordinal'} = 0 if !defined $args{'ordinal'}; </td> </tr> <tr> <td class="h" > <a name="1073">1073</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1074">1074</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1075">1075</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 3 </td> <td class="s"> my ( $ss_b, $ss_w ) = (); </td> </tr> <tr> <td class="h" > <a name="1076">1076</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1076-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> if ( $args{'independent'} ) { </td> </tr> <tr> <td class="h" > <a name="1077">1077</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 3 </td> <td class="s"> $ss_w = _sumsq_w_indep_param($data); </td> </tr> <tr> <td class="h" > <a name="1078">1078</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1078-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 3 </td> <td class="s"> if ( !$args{'ordinal'} ) { </td> </tr> <tr> <td class="h" > <a name="1079">1079</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> $ss_b = _sumsq_b_indep_param_cat($data); </td> </tr> <tr> <td class="h" > <a name="1080">1080</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1081">1081</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1082">1082</a> </td> <td class="c0" > <a href="#1083"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1082-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( $args{'ordinal'} == 1 ) { </td> </tr> <tr> <td class="h" > <a name="1083">1083</a> </td> <td class="c0" > <a href="#1086"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $ss_b = _sumsq_b_indep_param_ord($data); </td> </tr> <tr> <td class="h" > <a name="1084">1084</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1085">1085</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1086">1086</a> </td> <td class="c0" > <a href="#1091"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $ss_b = _sumsq_b_indep_param_ord_nonlinear($data); </td> </tr> <tr> <td class="h" > <a name="1087">1087</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1088">1088</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1089">1089</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1090">1090</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1091">1091</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $n_bt = scalar keys %{$data}; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1092"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1092">1092</a> </td> <td class="c0" > <a href="#1094"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1092-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak 'Not enough variables for performing ANOVA' </td> </tr> <tr> <td class="h" > <a name="1093">1093</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if $n_bt < 2; </td> </tr> <tr> <td class="h" > <a name="1094">1094</a> </td> <td class="c0" > <a href="#1095"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $n_wt = $self->equal_n( data => $data ); </td> </tr> <tr> <td class="h" > <a name="1095">1095</a> </td> <td class="c0" > <a href="#1098"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1095-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1095-1"> 0 </a> </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak </td> </tr> <tr> <td class="h" > <a name="1096">1096</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'Number of observations per variable need to be equal and greater than 1 for repeated measures ANOVA' </td> </tr> <tr> <td class="h" > <a name="1097">1097</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if !$n_wt or $n_wt == 1; </td> </tr> <tr> <td class="h" > <a name="1098">1098</a> </td> <td class="c0" > <a href="#1122"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> ( $ss_b, $ss_w ) = _sumsq_bw_rmdep_param_uni( $data, $n_bt, $n_wt ); </td> </tr> <tr> <td class="h" > <a name="1099">1099</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1100">1100</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1100-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> return wantarray ? ( ( $ss_b + $ss_w ), $ss_b, $ss_w ) : $ss_b + $ss_w; </td> </tr> <tr> <td class="h" > <a name="1101">1101</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1102">1102</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1103">1103</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 ss_b </td> </tr> <tr> <td class="h" > <a name="1104">1104</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1105">1105</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ss_b = $anova->ss_b(independent => BOOL, ordinal => BOOL); </td> </tr> <tr> <td class="h" > <a name="1106">1106</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1107">1107</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Returns the between-groups (aka treatment, effect, factor) sum-of-squares for the given data and the independence of the groups, and whether or not they have an ordinal relationship. </td> </tr> <tr> <td class="h" > <a name="1108">1108</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1109">1109</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1110">1110</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1111">1111</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub ss_b { </td> </tr> <tr> <td class="h" > <a name="1112">1112</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1112-1"> 2 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1112-1"> 1 </a> </td> <td > 23 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1113">1113</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1113-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> $args{'independent'} = 1 if !defined $args{'independent'}; </td> </tr> <tr> <td class="h" > <a name="1114">1114</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1114-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> $args{'ordinal'} = 0 if !defined $args{'ordinal'}; </td> </tr> <tr> <td class="h" > <a name="1115">1115</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1116">1116</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> my $ss; </td> </tr> <tr> <td class="h" > <a name="1117">1117</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1117-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> if ( $args{'independent'} ) { </td> </tr> <tr> <td class="h" > <a name="1118">1118</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1118-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> if ( !$args{'ordinal'} ) { </td> </tr> <tr> <td class="h" > <a name="1119">1119</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> $ss = _sumsq_b_indep_param_cat($data); </td> </tr> <tr> <td class="h" > <a name="1120">1120</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1121">1121</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1122">1122</a> </td> <td class="c0" > <a href="#1123"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1122-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( $args{'ordinal'} == 1 ) { </td> </tr> <tr> <td class="h" > <a name="1123">1123</a> </td> <td class="c0" > <a href="#1126"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $ss = _sumsq_b_indep_param_ord($data); </td> </tr> <tr> <td class="h" > <a name="1124">1124</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1125">1125</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1126">1126</a> </td> <td class="c0" > <a href="#1131"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $ss = _sumsq_b_indep_param_ord_nonlinear($data); </td> </tr> <tr> <td class="h" > <a name="1127">1127</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1128">1128</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1129">1129</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1130">1130</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1131">1131</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $n_bt = scalar keys %{$data}; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1132"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1132">1132</a> </td> <td class="c0" > <a href="#1134"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1132-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak 'Not enough variables for performing ANOVA' </td> </tr> <tr> <td class="h" > <a name="1133">1133</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if $n_bt < 2; </td> </tr> <tr> <td class="h" > <a name="1134">1134</a> </td> <td class="c0" > <a href="#1135"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $n_wt = $self->equal_n( data => $data ); </td> </tr> <tr> <td class="h" > <a name="1135">1135</a> </td> <td class="c0" > <a href="#1138"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1135-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1135-1"> 0 </a> </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak </td> </tr> <tr> <td class="h" > <a name="1136">1136</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'Number of observations per variable need to be equal and greater than 1 for repeated measures ANOVA' </td> </tr> <tr> <td class="h" > <a name="1137">1137</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if !$n_wt or $n_wt == 1; </td> </tr> <tr> <td class="h" > <a name="1138">1138</a> </td> <td class="c0" > <a href="#1176"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> ($ss) = _sumsq_bw_rmdep_param_uni( $data, $n_bt, $n_wt ); </td> </tr> <tr> <td class="h" > <a name="1139">1139</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1140">1140</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> return $ss; </td> </tr> <tr> <td class="h" > <a name="1141">1141</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1142">1142</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1143">1143</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 ss_w </td> </tr> <tr> <td class="h" > <a name="1144">1144</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1145">1145</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ss_w = $anova->ss_w(independent => BOOL); </td> </tr> <tr> <td class="h" > <a name="1146">1146</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1147">1147</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Returns the within-groups (aka error) sum-of-squares for the given data and according to whether the data per group are independent or dependent. </td> </tr> <tr> <td class="h" > <a name="1148">1148</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1149">1149</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1150">1150</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1151">1151</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub ss_w { </td> </tr> <tr> <td class="h" > <a name="1152">1152</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1152-1"> 3 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1152-1"> 1 </a> </td> <td > 526 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1153">1153</a> </td> <td class="c3" > 3 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1153-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 10 </td> <td class="s"> $args{'independent'} = 1 if !defined $args{'independent'}; </td> </tr> <tr> <td class="h" > <a name="1154">1154</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 9 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1155">1155</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> my $ss; </td> </tr> <tr> <td class="h" > <a name="1156">1156</a> </td> <td class="c3" > 3 </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1156-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> if ( $args{'independent'} ) { </td> </tr> <tr> <td class="h" > <a name="1157">1157</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> $ss = _sumsq_w_indep_param($data); </td> </tr> <tr> <td class="h" > <a name="1158">1158</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1159">1159</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1160">1160</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 1 </td> <td class="s"> my $n_bt = scalar keys %{$data}; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1161">1161</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1161-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> croak 'Not enough variables for performing ANOVA' if $n_bt < 2; </td> </tr> <tr> <td class="h" > <a name="1162">1162</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> my $n_wt = $self->equal_n( data => $data ); </td> </tr> <tr> <td class="h" > <a name="1163">1163</a> </td> <td class="c3" > 1 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1163-1"> 50 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1163-1"> 33 </a> </td> <td >   </td> <td >   </td> <td > 21 </td> <td class="s"> croak </td> </tr> <tr> <td class="h" > <a name="1164">1164</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'Number of observations per variable need to be equal and greater than 1 for repeated measures ANOVA' </td> </tr> <tr> <td class="h" > <a name="1165">1165</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if !$n_wt or $n_wt == 1; </td> </tr> <tr> <td class="h" > <a name="1166">1166</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 3 </td> <td class="s"> ( $_, $ss ) = _sumsq_bw_rmdep_param_uni( $data, $n_bt, $n_wt ); </td> </tr> <tr> <td class="h" > <a name="1167">1167</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1168">1168</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 8 </td> <td class="s"> return $ss; </td> </tr> <tr> <td class="h" > <a name="1169">1169</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1170">1170</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1171">1171</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 df_b </td> </tr> <tr> <td class="h" > <a name="1172">1172</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1173">1173</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1174">1174</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1175">1175</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub df_b { </td> </tr> <tr> <td class="h" > <a name="1176">1176</a> </td> <td class="c0" > <a href="#1177"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1176-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1176-1"> 1 </a> </td> <td > 0 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1177">1177</a> </td> <td class="c0" > <a href="#1178"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1177-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $args{'independent'} = 1 if !defined $args{'independent'}; </td> </tr> <tr> <td class="h" > <a name="1178">1178</a> </td> <td class="c0" > <a href="#1179"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1178-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $args{'ordinal'} = 0 if !defined $args{'ordinal'}; </td> </tr> <tr> <td class="h" > <a name="1179">1179</a> </td> <td class="c0" > <a href="#1180"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1180">1180</a> </td> <td class="c0" > <a href="#1181"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $df; </td> </tr> <tr> <td class="h" > <a name="1181">1181</a> </td> <td class="c0" > <a href="#1182"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1181-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( $args{'independent'} ) { </td> </tr> <tr> <td class="h" > <a name="1182">1182</a> </td> <td class="c0" > <a href="#1183"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1182-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( !$args{'ordinal'} ) { </td> </tr> <tr> <td class="h" > <a name="1183">1183</a> </td> <td class="c0" > <a href="#1186"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $df = _df_b_indep_param_cat($data); </td> </tr> <tr> <td class="h" > <a name="1184">1184</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1185">1185</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1186">1186</a> </td> <td class="c0" > <a href="#1187"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1186-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( $args{'ordinal'} == 1 ) { </td> </tr> <tr> <td class="h" > <a name="1187">1187</a> </td> <td class="c0" > <a href="#1190"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $df = _df_b_indep_param_ord_linear($data); </td> </tr> <tr> <td class="h" > <a name="1188">1188</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1189">1189</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1190">1190</a> </td> <td class="c0" > <a href="#1197"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $df = _df_b_indep_param_ord_nonlinear($data); </td> </tr> <tr> <td class="h" > <a name="1191">1191</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1192">1192</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1193">1193</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1194">1194</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> #_aov_indep_dfree_ord </td> </tr> <tr> <td class="h" > <a name="1195">1195</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1196">1196</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1197">1197</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $n_bt = scalar keys %{$data}; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1198"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1198">1198</a> </td> <td class="c0" > <a href="#1200"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1198-1"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak 'Not enough variables for performing ANOVA' </td> </tr> <tr> <td class="h" > <a name="1199">1199</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if $n_bt < 2; </td> </tr> <tr> <td class="h" > <a name="1200">1200</a> </td> <td class="c0" > <a href="#1201"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $n_wt = $self->equal_n( data => $data ); </td> </tr> <tr> <td class="h" > <a name="1201">1201</a> </td> <td class="c0" > <a href="#1204"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1201-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1201-1"> 0 </a> </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak </td> </tr> <tr> <td class="h" > <a name="1202">1202</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 'Number of observations per variable need to be equal and greater than 1 for repeated measures ANOVA' </td> </tr> <tr> <td class="h" > <a name="1203">1203</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> if !$n_wt or $n_wt == 1; </td> </tr> <tr> <td class="h" > <a name="1204">1204</a> </td> <td class="c0" > <a href="#1206"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> ($df) = _df_b_indep_dfree_cat($data); </td> </tr> <tr> <td class="h" > <a name="1205">1205</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1206">1206</a> </td> <td class="c0" > <a href="#1225"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return $df; </td> </tr> <tr> <td class="h" > <a name="1207">1207</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1208">1208</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1209">1209</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _df_b_indep_param_cat { </td> </tr> <tr> <td class="h" > <a name="1210">1210</a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1210-1"> 16 </a> </td> <td >   </td> <td > 15 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1211">1211</a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 15 </td> <td class="s"> return ( scalar keys %{$data} ) - 1; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 23 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1212">1212</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1213">1213</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1214">1214</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _df_b_indep_param_ord_linear { </td> </tr> <tr> <td class="h" > <a name="1215">1215</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1215-1"> 3 </a> </td> <td >   </td> <td > 4 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1216">1216</a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 7 </td> <td class="s"> return ( scalar keys %{$data} ) - 1; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 3 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1217">1217</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1218">1218</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1219">1219</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _df_b_indep_param_ord_nonlinear { </td> </tr> <tr> <td class="h" > <a name="1220">1220</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1220-1"> 2 </a> </td> <td >   </td> <td > 2 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1221">1221</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> return ( scalar keys %{$data} ) - 2; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1222">1222</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1223">1223</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1224">1224</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _df_b_indep_dfree_cat { </td> </tr> <tr> <td class="h" > <a name="1225">1225</a> </td> <td class="c0" > <a href="#1226"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1225-1"> 0 </a> </td> <td >   </td> <td > 0 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1226">1226</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return ( scalar keys %{$data} ) - 1; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1238"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1227">1227</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1228">1228</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1229">1229</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 grand_mean </td> </tr> <tr> <td class="h" > <a name="1230">1230</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1231">1231</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $mean = $anova->grand_mean(); </td> </tr> <tr> <td class="h" > <a name="1232">1232</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1233">1233</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Returns the mean of all observations. </td> </tr> <tr> <td class="h" > <a name="1234">1234</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1235">1235</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1236">1236</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1237">1237</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub grand_mean { </td> </tr> <tr> <td class="h" > <a name="1238">1238</a> </td> <td class="c0" > <a href="#1239"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1238-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1238-1"> 1 </a> </td> <td > 0 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1239">1239</a> </td> <td class="c0" > <a href="#1240"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1240">1240</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return mean( map { @{ $data->{$_} } } keys %{$data} ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1252"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1241">1241</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1242">1242</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1243">1243</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 grand_sum </td> </tr> <tr> <td class="h" > <a name="1244">1244</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1245">1245</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $sum = $anova->grand_sum($data); </td> </tr> <tr> <td class="h" > <a name="1246">1246</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1247">1247</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Returns the sum of all observations. </td> </tr> <tr> <td class="h" > <a name="1248">1248</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1249">1249</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1250">1250</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1251">1251</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub grand_sum { </td> </tr> <tr> <td class="h" > <a name="1252">1252</a> </td> <td class="c0" > <a href="#1253"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1252-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1252-1"> 1 </a> </td> <td > 0 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1253">1253</a> </td> <td class="c0" > <a href="#1254"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1254">1254</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return sum0( map { @{ $data->{$_} } } keys %{$data} ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1266"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1255">1255</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1256">1256</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1257">1257</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =head3 grand_n </td> </tr> <tr> <td class="h" > <a name="1258">1258</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1259">1259</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $count = $anova->grand_n(); </td> </tr> <tr> <td class="h" > <a name="1260">1260</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1261">1261</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> Returns the number of all observations. </td> </tr> <tr> <td class="h" > <a name="1262">1262</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1263">1263</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> =cut </td> </tr> <tr> <td class="h" > <a name="1264">1264</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1265">1265</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub grand_n { </td> </tr> <tr> <td class="h" > <a name="1266">1266</a> </td> <td class="c0" > <a href="#1267"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1266-1"> 0 </a> </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1266-1"> 1 </a> </td> <td > 0 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1267">1267</a> </td> <td class="c0" > <a href="#1268"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> my $data = _get_data( $self, %args ); </td> </tr> <tr> <td class="h" > <a name="1268">1268</a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return count( map { @{ $data->{$_} } } keys %{$data} ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="# "> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c0" > <a href="#1277"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1269">1269</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1270">1270</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1271">1271</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # Private methods </td> </tr> <tr> <td class="h" > <a name="1272">1272</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1273">1273</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _get_data { </td> </tr> <tr> <td class="h" > <a name="1274">1274</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1274-1"> 6 </a> </td> <td >   </td> <td > 10 </td> <td class="s"> my ( $self, %args ) = @_; </td> </tr> <tr> <td class="h" > <a name="1275">1275</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> my ($data) = (); </td> </tr> <tr> <td class="h" > <a name="1276">1276</a> </td> <td class="c3" > 6 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1276-1"> 50 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1276-1"> 66 </a> </td> <td >   </td> <td >   </td> <td > 36 </td> <td class="s"> if ( ref $args{'data'} ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#-2"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1277">1277</a> </td> <td class="c0" > <a href="#1287"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> $data = delete $args{'data'}; </td> </tr> <tr> <td class="h" > <a name="1278">1278</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1279">1279</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> elsif ( not defined $args{'independent'} or $args{'independent'} == 1 ) { </td> </tr> <tr> <td class="h" > <a name="1280">1280</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 15 </td> <td class="s"> $data = $self->get_hoa_numonly_indep(%args); </td> </tr> <tr> <td class="h" > <a name="1281">1281</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1282">1282</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1283">1283</a> </td> <td class="c3" > 1 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 5 </td> <td class="s"> $data = $self->get_hoa_numonly_across(%args); </td> </tr> <tr> <td class="h" > <a name="1284">1284</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1285">1285</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1286">1286</a> </td> <td class="c3" > 6 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1286-1"> 50 </a> </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1286-1"> 17 </a> </td> <td >   </td> <td > 638 </td> <td class="s"> if ( any { !scalar @{ $data->{$_} } } keys %{$data} ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 17 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 12 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 17 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 51 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 29 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1287">1287</a> </td> <td class="c0" > <a href="#1381"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak 'Empty data following purge of invalid value(s)'; </td> </tr> <tr> <td class="h" > <a name="1288">1288</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1289">1289</a> </td> <td class="c3" > 6 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 18 </td> <td class="s"> return $data; </td> </tr> <tr> <td class="h" > <a name="1290">1290</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1291">1291</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1292">1292</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _sumsq_b_indep_param_cat { </td> </tr> <tr> <td class="h" > <a name="1293">1293</a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1293-1"> 21 </a> </td> <td >   </td> <td > 26 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1294">1294</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my @group_ns_and_means = </td> </tr> <tr> <td class="h" > <a name="1295">1295</a> </td> <td class="c3" > 71 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 1061 </td> <td class="s"> map { [ count( @{ $data->{$_} } ), mean( @{ $data->{$_} } ) ] } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 71 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 159 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 71 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 475 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1296">1296</a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 26 </td> <td class="s"> keys %{$data}; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 34 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1297">1297</a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 443 </td> <td class="s"> my $grand_mean = mean( map { @{ $data->{$_} } } keys %{$data} ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 71 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 53 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 71 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 126 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 32 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1298">1298</a> </td> <td class="c3" > 21 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 1140 </td> <td class="s"> return sum0( map { $_->[0] * ( $_->[1] - $grand_mean )**2 } </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 71 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 189 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1299">1299</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> @group_ns_and_means ); </td> </tr> <tr> <td class="h" > <a name="1300">1300</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1301">1301</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1302">1302</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _sumsq_b_indep_param_ord { # linear between-group sum-of-squares </td> </tr> <tr> <td class="h" > <a name="1303">1303</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1303-1"> 5 </a> </td> <td >   </td> <td > 8 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1304">1304</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 7 </td> <td class="s"> my @names = keys( %{$data} ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 11 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1305">1305</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> croak </td> </tr> <tr> <td class="h" > <a name="1306">1306</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> "Check names for variables: All need to be numerical for trend analysis" </td> </tr> <tr> <td class="h" > <a name="1307">1307</a> </td> <td class="c3" > 5 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1307-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> if grep { !looks_like_number($_) } @names; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 30 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1308">1308</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 7 </td> <td class="s"> my $mean_t = mean(@names); # mean of the ordinal values </td> </tr> <tr> <td class="h" > <a name="1309">1309</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $sum_sample_contrasts = </td> </tr> <tr> <td class="h" > <a name="1310">1310</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 76 </td> <td class="s"> sum( map { mean( @{ $data->{$_} } ) * ( $_ - $mean_t ) } @names ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 190 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 28 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1311">1311</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> my $sumsquared_coeffs = </td> </tr> <tr> <td class="h" > <a name="1312">1312</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 138 </td> <td class="s"> sum( map { ( $_ - $mean_t )**2 / count( @{ $data->{$_} } ) } @names ) </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 64 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 16 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 27 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1313">1313</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ; # unweighted </td> </tr> <tr> <td class="h" > <a name="1314">1314</a> </td> <td class="c3" > 5 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 71 </td> <td class="s"> return $sum_sample_contrasts**2 / $sumsquared_coeffs; </td> </tr> <tr> <td class="h" > <a name="1315">1315</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1316">1316</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1317">1317</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _sumsq_b_indep_param_ord_nonlinear { </td> </tr> <tr> <td class="h" > <a name="1318">1318</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1318-1"> 2 </a> </td> <td >   </td> <td > 3 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1319">1319</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> return _sumsq_b_indep_param_cat($data) - _sumsq_b_indep_param_ord($data); </td> </tr> <tr> <td class="h" > <a name="1320">1320</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1321">1321</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1322">1322</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _sumsq_w_indep_param { # within-group SS (and DF): </td> </tr> <tr> <td class="h" > <a name="1323">1323</a> </td> <td class="c3" > 24 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1323-1"> 24 </a> </td> <td >   </td> <td > 25 </td> <td class="s"> my $data = shift; </td> </tr> <tr> <td class="h" > <a name="1324">1324</a> </td> <td class="c3" > 24 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 36 </td> <td class="s"> my ( $ss_w, $df_w ) = ( 0, 0 ); </td> </tr> <tr> <td class="h" > <a name="1325">1325</a> </td> <td class="c3" > 24 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 21 </td> <td class="s"> foreach ( keys %{$data} ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 24 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 61 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1326">1326</a> </td> <td class="c3" > 80 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 351 </td> <td class="s"> my $mean = mean( @{ $data->{$_} } ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 80 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 143 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1327">1327</a> </td> <td class="c3" > 80 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 1718 </td> <td class="s"> $ss_w += ( $_ - $mean )**2 foreach @{ $data->{$_} }; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 80 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 295 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1328">1328</a> </td> <td class="c3" > 80 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 69 </td> <td class="s"> $df_w += ( count( @{ $data->{$_} } ) - 1 ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 80 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 119 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1329">1329</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1330">1330</a> </td> <td class="c3" > 24 </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1330-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 195 </td> <td class="s"> return wantarray ? return ( $ss_w, $df_w ) : $ss_w; </td> </tr> <tr> <td class="h" > <a name="1331">1331</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1332">1332</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1333">1333</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _sumsq_bw_rmdep_param_uni </td> </tr> <tr> <td class="h" > <a name="1334">1334</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> { # error and treatment sums-of-squares for rm anovas (univariate method) </td> </tr> <tr> <td class="h" > <a name="1335">1335</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1335-1"> 10 </a> </td> <td >   </td> <td > 11 </td> <td class="s"> my ( $data, $n_bt, $n_wt ) = @_; </td> </tr> <tr> <td class="h" > <a name="1336">1336</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 20 </td> <td class="s"> my ( $ss_b, $ss_w, $df_b, $df_w, $i, @i_means, %i_data, %j_means ) = (); </td> </tr> <tr> <td class="h" > <a name="1337">1337</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1338">1338</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> # Mean over each index: </td> </tr> <tr> <td class="h" > <a name="1339">1339</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 43 </td> <td class="s"> for ( $i = 0 ; $i < $n_wt ; $i++ ) { </td> </tr> <tr> <td class="h" > <a name="1340">1340</a> </td> <td class="c3" > 82 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 1140 </td> <td class="s"> push @{ $i_data{$i} }, $data->{$_}->[$i] foreach keys %{$data}; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 82 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 117 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 293 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 362 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1341">1341</a> </td> <td class="c3" > 82 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 61 </td> <td class="s"> $i_means[$i] = mean( @{ $i_data{$i} } ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 82 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 127 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1342">1342</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1343">1343</a> </td> <td class="c3" > 10 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1343-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 159 </td> <td class="s"> croak 'No means to divide by' if !scalar @i_means; </td> </tr> <tr> <td class="h" > <a name="1344">1344</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 51 </td> <td class="s"> my $grand_mean = sum0(@i_means) / scalar @i_means; </td> </tr> <tr> <td class="h" > <a name="1345">1345</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1346">1346</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 10 </td> <td class="s"> foreach ( keys %{$data} ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 20 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1347">1347</a> </td> <td class="c3" > 34 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 24 </td> <td class="s"> $j_means{$_} = mean( @{ $data->{$_} } ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 34 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 56 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1348">1348</a> </td> <td class="c3" > 34 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 816 </td> <td class="s"> $ss_b += ( $j_means{$_} - $grand_mean )**2; </td> </tr> <tr> <td class="h" > <a name="1349">1349</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1350">1350</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 16 </td> <td class="s"> $ss_b *= $n_wt; </td> </tr> <tr> <td class="h" > <a name="1351">1351</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1352">1352</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 8 </td> <td class="s"> foreach ( keys %{$data} ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 36 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1353">1353</a> </td> <td class="c3" > 34 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 63 </td> <td class="s"> for ( $i = 0 ; $i < $n_wt ; $i++ ) { </td> </tr> <tr> <td class="h" > <a name="1354">1354</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> $ss_w += </td> </tr> <tr> <td class="h" > <a name="1355">1355</a> </td> <td class="c3" > 293 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 444 </td> <td class="s"> ( $data->{$_}->[$i] - $i_means[$i] - $j_means{$_} + $grand_mean ) </td> </tr> <tr> <td class="h" > <a name="1356">1356</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> **2; </td> </tr> <tr> <td class="h" > <a name="1357">1357</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1358">1358</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1359">1359</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 12 </td> <td class="s"> $df_b = $n_bt - 1; </td> </tr> <tr> <td class="h" > <a name="1360">1360</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 12 </td> <td class="s"> $df_w = $df_b * ( $n_wt - 1 ); </td> </tr> <tr> <td class="h" > <a name="1361">1361</a> </td> <td class="c3" > 10 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 48 </td> <td class="s"> return ( $ss_b, $ss_w, $df_b, $df_w ); </td> </tr> <tr> <td class="h" > <a name="1362">1362</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1363">1363</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1364">1364</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _aref2href { </td> </tr> <tr> <td class="h" > <a name="1365">1365</a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1365-1"> 4 </a> </td> <td >   </td> <td > 4 </td> <td class="s"> my $aref = shift; </td> </tr> <tr> <td class="h" > <a name="1366">1366</a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s"> my %hash = (); </td> </tr> <tr> <td class="h" > <a name="1367">1367</a> </td> <td class="c3" > 4 </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1367-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 11 </td> <td class="s"> $aref = [$aref] if !ref $aref->[0]; </td> </tr> <tr> <td class="h" > <a name="1368">1368</a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> foreach ( @{$aref} ) { </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 7 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1369">1369</a> </td> <td class="c3" > 6 </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1369-1"> 100 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 9 </td> <td class="s"> if ( ref $_->[1] ) { </td> </tr> <tr> <td class="h" > <a name="1370">1370</a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 11 </td> <td class="s"> $hash{ $_->[0] } = $_->[1]; </td> </tr> <tr> <td class="h" > <a name="1371">1371</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1372">1372</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1373">1373</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> my $name = shift( @{$_} ); </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1374">1374</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 2 </td> <td class="s"> $hash{$name} = [ @{$_} ]; </td> </tr> <tr> <td class="h" > <a > </a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 6 </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1375">1375</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1376">1376</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1377">1377</a> </td> <td class="c3" > 4 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 11 </td> <td class="s"> return \%hash; </td> </tr> <tr> <td class="h" > <a name="1378">1378</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1379">1379</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1380">1380</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _pcorrect { # (1 - ( 1 - p)^N ) </td> </tr> <tr> <td class="h" > <a name="1381">1381</a> </td> <td class="c0" > <a href="#1393"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1381-1"> 0 </a> </td> <td >   </td> <td > 0 </td> <td class="s"> return 1 - ( 1 - $_[0] )**$_[1]; </td> </tr> <tr> <td class="h" > <a name="1382">1382</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1383">1383</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1384">1384</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _precisioned { </td> </tr> <tr> <td class="h" > <a name="1385">1385</a> </td> <td class="c3" > 24 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1385-1"> 50 </a> </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1385-1"> 24 </a> </td> <td >   </td> <td > 97 </td> <td class="s"> return $_[0] </td> </tr> <tr> <td class="h" > <a > </a> </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#-2"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s">   </td> </tr> <tr> <td class="h" > <a name="1386">1386</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> ? sprintf( '%.' . $_[0] . 'f', $_[1] ) </td> </tr> <tr> <td class="h" > <a name="1387">1387</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> : ( defined $_[1] ? $_[1] : q{} ); # don't lose any zero </td> </tr> <tr> <td class="h" > <a name="1388">1388</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1389">1389</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1390">1390</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub _init_alpha { </td> </tr> <tr> <td class="h" > <a name="1391">1391</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td class="c3" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1391-1"> 2 </a> </td> <td >   </td> <td > 3 </td> <td class="s"> my $val = shift; </td> </tr> <tr> <td class="h" > <a name="1392">1392</a> </td> <td class="c3" > 2 </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1392-1"> 50 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td > 4 </td> <td class="s"> if ( defined $val ) { </td> </tr> <tr> <td class="h" > <a name="1393">1393</a> </td> <td class="c0" > <a href="#1394"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--branch.html#1393-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--condition.html#1393-1"> 0 </a> </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> if ( $val > 0 && $val < 1 ) { </td> </tr> <tr> <td class="h" > <a name="1394">1394</a> </td> <td class="c0" > <a href="#1397"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> return $val; </td> </tr> <tr> <td class="h" > <a name="1395">1395</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1396">1396</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1397">1397</a> </td> <td class="c0" > <a href="#1406"> 0 </a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 0 </td> <td class="s"> croak "Alpha value should be between 0 and 1, not '$val'."; </td> </tr> <tr> <td class="h" > <a name="1398">1398</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1399">1399</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1400">1400</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> else { </td> </tr> <tr> <td class="h" > <a name="1401">1401</a> </td> <td class="c3" > 2 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td > 9 </td> <td class="s"> return $ALPHA_DEFAULT; </td> </tr> <tr> <td class="h" > <a name="1402">1402</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1403">1403</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1404">1404</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1405">1405</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> sub cluster { </td> </tr> <tr> <td class="h" > <a name="1406">1406</a> </td> <td class="c0" > <a href="#1407"> 0 </a> </td> <td >   </td> <td >   </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1406-1"> 0 </a> </td> <td class="c0" > <a href="blib-lib-Statistics-ANOVA-pm--subroutine.html#1406-1"> 0 </a> </td> <td >   </td> <td class="s"> croak 'cluster() method is deprecated. See Statistics::ANOVA::Cluster'; </td> </tr> <tr> <td class="h" > <a name="1407">1407</a> </td> <td class="c0" > 0 </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> return; </td> </tr> <tr> <td class="h" > <a name="1408">1408</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> } </td> </tr> <tr> <td class="h" > <a name="1409">1409</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1410">1410</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> 1; </td> </tr> <tr> <td class="h" > <a name="1411">1411</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> </td> </tr> <tr> <td class="h" > <a name="1412">1412</a> </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td >   </td> <td class="s"> __END__ </td> </tr> </table> </body> </html>