This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Add-ons & Links / Standard Packages / Statistics /

Statistics`ANOVA`

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 also 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 and comparisons.

The ANOVA function.

The data must be of the form , , , , , , where , , and so on are the values of the factors associated with the response, .

The factors argument of ANOVA must be a list of names representing the factors of the model, one name for each factor.

The model argument of ANOVA must be a list of main effects and interaction effects that together specify the model. The interaction terms are given as the multiplication of factors. For example, the full factorial model for a three-way ANOVA can be written as , , , , , , , where , , are the main effects, , , are the two-way interactions, and is the three-way interaction. For simplicity, models can also be written using All to represent all interaction terms between the specified main effects. The full factorial model for a three-way ANOVA can therefore also be written as , , , All.

This loads the package.

In[1]:= <<Statistics`ANOVA`

In this data set, the first element in each pair gives the value of the factor and the second element gives the response. There are four levels of the factor, each having five responses.

In[2]:= 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}};

This performs a one-way ANOVA.

In[3]:= ANOVA[onewaydata]

Out[3]=

In this unbalanced two-way data set, the first element in each triplet gives the value of the first factor, the second element gives the value of the second factor, and the third element gives the response. There are two levels of the first factor and three levels of the second factor.

In[4]:= 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}};

This performs a full factorial two-way ANOVA.

In[5]:= ANOVA[twowaydata,{factor1, factor2, All}, {factor1, factor2}]

Out[5]=

Dropping the data point {2, 2, 28.7} gives an unbalanced two-way ANOVA with an empty cell.

In[6]:= ANOVA[Drop[twowaydata, {-4}], {factor1, factor2, All}, {factor1, factor2}]

Out[6]=

Here is a balanced three-way data set.

In[7]:= 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}};

Here is a three-way ANOVA without the three-way interaction included.

In[8]:=

Out[8]=

Options for ANOVA.

Available tests to include in the PostTests option.

This performs a one-way ANOVA with a Tukey post-hoc test. In this example, both groups one and four are significantly different from group three at the five-percent level.

In[9]:=

Out[9]=

This performs the same one-way ANOVA as the previous example but with Bonferroni and Tukey post-hoc tests being computed at the one-percent level. The cell means are not being displayed again. In this case, only groups three and four are significantly different.

In[10]:=

Out[10]=

References

Jobson, J. D. (1991). Applied Multivariate Data Analysis Volume 1: Regression and Experimental Design, Springer-Verlag, New York.

Sahai, H. and Ageel, M. (2000). The Analysis of Variance: Fixed, Random and Mixed Models, Birkhauser, Boston.

Searle, S. R. (1987). Linear Models for Unbalanced Data, John Wiley & Sons, New York.