Get startedGet started for free

Post-modeling validation plots + variance

In the last exercise, we found that int_rate does differ by grade. Now we should validate this model, which for linear regression means examining the Residuals vs. Fitted and Normal Q-Q plots.

If you call plot() on a model object in R, it will automatically plot both of those plots plus two more. You'll interpret these plots to evaluate model fit. We discussed how to do this in the video.

Another assumption of ANOVA and linear modeling is homogeneity of variance. Homogeneity means "same", and here that would mean that the variance of int_rate is the same for each level of grade. We can test for homogeneity of variances using bartlett.test(), which takes a formula and a dataset as inputs.

This exercise is part of the course

Experimental Design in R

View Course

Exercise instructions

  • Run the first line of code with par() so the plots will output in a 2 by 2 grid.
  • Call plot() on grade_aov (which has been created for you) to produce the model diagnostic plots.
  • Test for homogeneity of variances using bartlett.test().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# For a 2x2 grid of plots:
par(mfrow=c(___, ___))

# Plot grade_aov
___

# Bartlett's test for homogeneity of variance
___
Edit and Run Code