2

In R, after creating a linear model using the function model <- lm() and plotting it using plot(model), you will get back 4 graphs each displaying your model differently. Can anyone explain what these graphs mean?

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
JohnBanter
  • 49
  • 3
  • 5
    https://cran.r-project.org/doc/contrib/Robinson-icebreaker.pdf , section 9.3 – jogo Apr 23 '18 at 12:41
  • [Note to moderators: this is one of those questions that might seems inappropriate but I think lots of people, in particular students, will benefit from a good answer located in one place.] – mysteRious Apr 23 '18 at 12:51
  • Yes please I am a student and new to R. A simplified explanation of those 4 models would help a lot – JohnBanter Apr 23 '18 at 13:33

1 Answers1

3

plot.lm can produce 6 different diagnostic plots, controlled by the which parameter. These are:

  1. a plot of residuals against fitted values
  2. a Normal Q-Q plot
  3. a Scale-Location plot of sqrt(| residuals |) against fitted values
  4. a plot of Cook's distances versus row labels
  5. a plot of residuals against leverages
  6. a plot of Cook's distances against leverage/(1-leverage)

By default it will produce numbers 1, 2, 3 and 5, pausing between plots in interactive mode.

You can see them all in one go if you set up the graphics device for multiple plots, eg:

mdl <- lm(hp~disp,mtcars)
par(mfrow=c(3,2))
plot(mdl,which=1:6)

lm diagnostic plots

Interpretation of these plots is a question for Cross Validated, though ?plot.lm gives some basic information.

James
  • 65,548
  • 14
  • 155
  • 193