How to get residual in linear regression model in R

linear_regression
r

#1

I am currently working on linear regression problem

data(airquality)
names(airquality)
plot(Ozone~Solar.R,data=airquality)
mean.Ozone=mean(airquality$Ozone,na.rm=T)
abline(h=mean.Ozone)
model1<-lm(Ozone~Solar.R,data=airquality)
abline(model1,col="red")

now I want to know how I can get the residual and how I can display in the plot


#2

@hinduja1234- you can use the command plot to plot the model1 and then you get the plot in which you can clearly see residual.

Hope this helps!
Regards,
Harry


#3

you can use the function summary(name of the object in which you have stored the data ) to see the residuals and plot (name of the object…) to see the four graphical approaches to evaluate a model.


#4

@hinduja1234

You can try this way also :

a.resid<-resid(model1)

and for plotting u can directly plot it.
ex:

a.mod<-resid(model1)
plot(density(a.mod))#density plot
qqnorm(a.mod)#checking normality with quantile normal plot
qqline(a.mod)

let us know if it helps…
Sai