Whenever we do a linear regression, we need to check whether the assumed assumptions for the model are correct. One of the best ways to do this is through diagnostic charts. See the example below:
ajuste <- lm(Petal.Width ~ Petal.Length, data=iris)
library(ggfortify)
autoplot(ajuste)
There are four diagnostic graphs produced by the autoplot
function. Some of the points in these graphs are identified as deviating from the assumptions made. For example, in the QQ plot above, points 115, 135 and 142 are identified as out of order for waste if they were distributed according to normal.
Is there any way to do this automatically in R? How can I get the output of autoplot
(or the native function itself plot
of R) and identify, for each graph plotted, which points violate the hypotheses of the model?