Skip to main content

5.5) Fitting A Linear Model (cont'd)


At this point, some investigators would perform null-hypothesis tests for normality and homoskedasticity. If this is you, then the vector of residuals can be extracted from the model object using the function residuals(), and there are functions such as shapiro.test() and qqnorm() for testing them.

Continuing with the model GRASS.lm:

  • Having worked out what the residual plots are showing, you should be dissatisfied with that initial model! Try some transformations to achieve normally-distributed residuals. Hint: You may need to transform one or more of the predictor variables as well as the response.
  • When you are happy that the residuals have constant variance and are normally distributed, use summary() on your model to view the estimated coefficients and summary.aov() to see an ANOVA table. Notice how the P-values from the two tables are different. This is because the ANOVA table shows the value of adding each term in turn to the model (known as sequential sums of squares), and P-values for the probability that the latest term is a significant improvement to the model, whereas the coefficient significance values are based on t-tests for the (a-priori) null hypotheses that each of them equals zero. This is a case of applying two different methods to the same object: summary.lm() and summary.aov().