12 ANOVA
Overview
Here we’ll introduce ANOVA (analysis of variance) using lm()
, including the use of multiple predictors (multiple-way ANOVA), the assessment of interactions and the assessment of the residuals.
Objectives
Upon completion of this lesson, you should be able to:
- Fit ANOVA models using
lm()
and interpret the output usingsummary()
,anova()
, andTukeyHSD()
- Assess model validity using diagnostic plots
- Specify multiple predictors and their interactions
- Calculate predicted values (group means) for complex models
- Visualize interactions using
interaction.plot()
Data and R Code Files
The R code file and data files for this lesson can be found on the Essential R - Notes on learning R page.
12.1 Categorical Predictors: t.test()
vs. oneway.test()
vs. lm()
Here we’ll compare the use of the t-sample t-test t.test()
, the one.way test oneway.test()
and our old friend lm()
for fitting models with categorical predictors.
12.2 Interpreting Output: summary()
, anova()
, aov()
, and TukeyHSD()
Here we’ll introduce anova()
and TukeyHSD()
which help us understand our linear model in ways that complement the output from summary()
12.3 Regression Assumptions in ANOVA
In this video, we’ll consider how we could deal with violations of regression assumptions in ANOVA.
12.4 Models with Multiple Predictors: Specification and Interpretation
In this video we’ll consider how we can combine multiple predictors to increase the utility of our models, and we’ll consider how to interpret the output when we have many parameters reported.
12.5 Interactions Between Predictors: Reading Output and Calculating Group Means
One of the challenges of using mutliple predictor variables is the reality that there can be interactions between them. In this video, we’ll consider how to specify models with interactions, how to test interactions for significance, and how to calculate group means when interactions are present (using our old friend predict()
).
12.6 Visualizing Interactions Between Predictors
Interactions can be difficult to understand - a good plot can greatly simplify this as we’ll see with the use of interaction.plot()
in this video.
12.7 TukeyHSD() and Interactions
We’ve already introduced TukeyHSD()
for testing all pairwise comparisons in our model. He’re we’ll demonstrate why control of the family-wise error provided by TukeyHSD()
is so important - as we’ll see adding an interaction greatly increases the number of pairwise comparisons.
12.8 The HSD.test()
Function
We’ll close out this chapter by introducing the function HSD.test()
from the package “agricolae”. This provides a couple of very useful features for working with ANOVA models.