Meaning of the plots obtained in lm in R

I ran a linear regression using the following code:

install.packages(‘ISLR’)
rm(list = ls())
library(ISLR)
model =lm(mpg ~ horsepower, Auto)
par(mar = c(1,1,1,1))
plot(Auto$horsepower, Auto$mpg,ylab = “mpg”,xlab = “horsepower”)
abline(model)
plot(model)

The plot(model) commands gives the following graphs:

Can someone help me understand the meaning of the plots obtained? What could they alternately be and what would it then mean?

@Harshita_Dudhe, the first plot is basically the line of best fit on top of mpg vs. horsepower plot. Assuming you have already created the model, this can be generated separately by:

plot(Auto$horsepower, Auto$mpg,ylab = "mpg",xlab = "horsepower")
abline(model)

The rest of the plots display parameters pertaining to the model itself – meta-information of the model, if you will. To be honest, most of the terms are beyond my basic understanding of statistics, but the section 4.2 here will hopefully give you a start.

@Harshita_Dudhe

Hope this will helpful :smile:

  1. Residual vs Fitted – The plot gives an idea of whether there is any curvature in the data. If the line is strongly curved, a quadratic or other model may be better.

  2. Scale -Location– The plot is used to check if the variance is constant (ie, if the standard deviation among the residuals appears to be about constant). Fitted Vs root of(standadise residuals )

  3. Residual vs Leverage This plot is used to check to see if there were any overly influential points .

  4. Normal Q-Q The plot is to check whether the residuals are normally distributed.

3 Likes