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:


  1. Fit ANOVA models using lm() and interpret the output using summary(), anova(), and TukeyHSD()
  2. Assess model validity using diagnostic plots
  3. Specify multiple predictors and their interactions
  4. Calculate predicted values (group means) for complex models
  5. 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.

R logo

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.

Video - STAT 485 Lesson: 12.1

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()

Video - STAT 485 Lesson: 12.2

12.3 Regression Assumptions in ANOVA

In this video, we’ll consider how we could deal with violations of regression assumptions in ANOVA.

Video - STAT 485 Lesson: 12.3

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.

Video - STAT 485 Lesson: 12.4

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()).

Video - STAT 485 Lesson: 12.5

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.

Video - STAT 485 Lesson: 12.6

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.

Video - STAT 485 Lesson: 12.7

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.

Video - STAT 485 Lesson: 12.8

Note! Chapter 12 of EssentialR demonstrates how to use HSD.test() for interactions.