JohnBanter
JohnBanter

Reputation: 49

The 4 outputs of a linear model in R

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?

Upvotes: 2

Views: 1685

Answers (1)

James
James

Reputation: 66874

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.

Upvotes: 3

Related Questions