Analysis of Variance Package
This package provides functions for performing a univariate Analysis of Variance (ANOVA) to examine the differences between groups of means. The function ANOVA can handle models with any number of fixed factors in a crossed design. It can handle both balanced and unbalanced data with or without missing elements. All results are given as type I sums of squares. ANOVA also provides a number of post‐hoc tests for comparisons.
| ANOVA[data] | perform a one‐way analysis of variance |
| ANOVA[data,model,vars] | perform a general ANOVA specified by the given model and vars |
The ANOVA function.
The data must be of the form {{α1,β1,…,y1},{α2,β2,…,y2},…} where αi, βi, and so on are the values of the categorical variables vars associated with the ith response, yi.
The vars argument is a list of symbols representing the categorical variables in the model.
The model argument is a list of main effects and interactions that together specify the model. The interaction terms are given as the product of variables. For example, the full factorial model for a three‐way analysis of variance can be written as {α,β,γ,α β,α γ,β γ,α β γ}, where α, β, γ are the main effects, α β, α γ, β γ are the two‐way interactions, and α β γ is the three‐way interaction. Models can also be written using All to represent all main effects and interactions between the specified categorical variables. The full factorial model for a three‐way analysis of variance can therefore also be written as {α,β,γ,All}.
<<ANOVA`onewaydata = {{1, 7.0}, {1, 5.3}, {1, 5.9}, {1, 6.6}, {1, 4.9}, {2, 4.4}, {2, 6.8}, {2, 7.7}, {2, 8.3}, {2, 6.6}, {3, 8.1}, {3, 10.4}, {3, 8.0}, {3, 6.8}, {3, 9.2}, {4, 5.7}, {4, 3.9}, {4, 6.2}, {4, 5.5}, {4, 6.2}};ANOVA[onewaydata]twowaydata = {{1, 1, 10.1}, {1, 1, 10.5}, {1, 1, 11.3}, {1, 2, 13.1}, {1, 2, 14.7}, {1, 3, 14.1}, {1, 3, 12.6}, {2, 1, 10.7}, {2, 1, 15.3}, {2, 1, 17.9}, {2, 1, 18.0}, {2, 2, 28.7}, {2, 3, 16.0}, {2, 3, 9.2}, {2, 3, 12.1}};ANOVA[twowaydata, {factor1, factor2, All}, {factor1, factor2}]ANOVA[Drop[twowaydata, {-4}], {factor1, factor2, All}, {factor1, factor2}]threewaydata = {{1, 1, 1, 50}, {1, 1, 1, 50}, {1, 1, 1, 54}, {1, 1, 2, 40}, {1, 1, 2, 36}, {1, 1, 2, 40}, {1, 2, 1, 48}, {1, 2, 1, 48}, {1, 2, 1, 44}, {1, 2, 2, 14}, {1, 2, 2, 18}, {1, 2, 2, 14}, {2, 1, 1, 40}, {2, 1, 1, 36}, {2, 1, 1, 36}, {2, 1, 2, 18}, {2, 1, 2, 14}, {2, 1, 2, 18}, {2, 2, 1, 6}, {2, 2, 1, 2}, {2, 2, 1, 2}, {2, 2, 2, 20}, {2, 2, 2, 16}, {2, 2, 2, 20}};ANOVA[threewaydata, {α, β, γ, α β, α γ, β γ}, {α, β, γ}]option name | default value | |
| CellMeans | True | whether to give a list of means for each group |
| WorkingPrecision | MachinePrecision | precision of the arithmetic to use in calculations |
| PostTests | {} | list of post‐hoc tests to perform |
| SignificanceLevel | 0.05 | significance level criteria for post‐hoc tests |
Options for ANOVA.
| Bonferroni | mean comparison test based on the Student t distribution with modified α based on the number of groups |
| Duncan | liberal range test based on the Studentized range distribution |
| StudentNewmanKeuls | conservative range test based on the Studentized range distribution |
| Tukey | mean comparison test based on the Studentized range distribution |
| Dunnett | comparison test of group means against a control, taken to be the first group |
Available tests for the PostTests option.
ANOVA[onewaydata, PostTests -> Tukey]ANOVA[onewaydata, PostTests -> {Tukey, Bonferroni}, SignificanceLevel -> .01, CellMeans -> False]