Load the sample data.

popcorn =
5.5000 4.5000 3.5000
5.5000 4.5000 4.0000
6.0000 4.0000 3.0000
6.5000 5.0000 4.0000
7.0000 5.5000 5.0000
7.0000 5.0000 4.5000

The data is from a study of popcorn brands and popper types (Hogg 1987). The columns of the matrix `popcorn`

are brands (Gourmet, National, and Generic). The rows are popper types oil and air. In the study, researchers popped a batch of each brand three times with each popper. The values are the yield in cups of popped popcorn.

Perform a two-way ANOVA. Also compute the statistics that you need to perform a multiple comparison test on the main effects.

stats =
struct with fields:
source: 'anova2'
sigmasq: 0.1389
colmeans: [6.2500 4.7500 4]
coln: 6
rowmeans: [4.5000 5.5000]
rown: 9
inter: 1
pval: 0.7462
df: 12

The `stats`

structure includes

The mean squared error (`sigmasq`

)

The estimates of the mean yield for each popcorn brand (`colmeans`

)

The number of observations for each popcorn brand (`coln`

)

The estimate of the mean yield for each popper type (`rowmeans`

)

The number of observations for each popper type (`rown`

)

The number of interactions (`inter`

)

The *p*-value that shows the significance level of the interaction term (`pval`

)

The error degrees of freedom (`df`

).

Perform a multiple comparison test to see if the popcorn yield differs between pairs of popcorn brands (columns).

Note: Your model includes an interaction term. A test of main effects can be
difficult to interpret when the model includes interactions.
c =
1.0000 2.0000 0.9260 1.5000 2.0740 0.0000
1.0000 3.0000 1.6760 2.2500 2.8240 0.0000
2.0000 3.0000 0.1760 0.7500 1.3240 0.0116

The first two columns of `c`

show the groups that are compared. The fourth column shows the difference between the estimated group means. The third and fifth columns show the lower and upper limits for 95% confidence intervals for the true mean difference. The sixth column contains the *p*-value for a hypothesis test that the corresponding mean difference is equal to zero. All *p*-values (0, 0, and 0.0116) are very small, which indicates that the popcorn yield differs across all three brands.

The figure shows the multiple comparison of the means. By default, the group 1 mean is highlighted and the comparison interval is in blue. Because the comparison intervals for the other two groups do not intersect with the intervals for the group 1 mean, they are highlighted in red. This lack of intersection indicates that both means are different than group 1 mean. Select other group means to confirm that all group means are significantly different from each other.

Perform a multiple comparison test to see the popcorn yield differs between the two popper types (rows).

Note: Your model includes an interaction term. A test of main effects can be
difficult to interpret when the model includes interactions.
c =
1.0000 2.0000 -1.3828 -1.0000 -0.6172 0.0001

The small *p*-value of 0.0001 indicates that the popcorn yield differs between the two popper types (air and oil). The figure shows the same results. The disjoint comparison intervals indicate that the group means are significantly different from each other.