Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Two-way analysis of variance

`anova2`

performs two-way analysis
of variance (ANOVA) with balanced designs. To perform two-way ANOVA
with unbalanced designs, see `anovan`

.

`p = anova2(y,reps)`

`p = anova2(y,reps,displayopt)`

```
[p,tbl]
= anova2(___)
```

```
[p,tbl,stats]
= anova2(___)
```

returns
the `p`

= anova2(`y`

,`reps`

)*p*-values for a balanced two-way ANOVA for comparing
the means of two or more columns and two or more rows of the observations
in `y`

.

`reps`

is the number of replicates for each
combination of factor groups, which must be constant, indicating a
balanced design. For unbalanced designs, use `anovan`

.
The `anova2`

function tests the main effects for
column and row factors and their interaction effect. To test the interaction
effect, `reps`

must be greater than 1.

`anova2`

also displays the standard ANOVA
table.

enables the ANOVA table display when `p`

= anova2(`y`

,`reps`

,`displayopt`

)`displayopt`

is `'on'`

(default)
and suppresses the display when `displayopt`

is `'off'`

.

`[`

returns a `p`

,`tbl`

,`stats`

]
= anova2(___)`stats`

structure,
which you can use to perform a multiple comparison test. A multiple
comparison test enables you to determine which pairs of group means
are significantly different. To perform this test, use `multcompare`

, providing the `stats`

structure
as input.

[1] Hogg, R. V., and J. Ledolter. *Engineering
Statistics*. New York: MacMillan, 1987.