I am very new to residual analysis and ANOVA. To my understanding, in the residual plot, residuals should not show obvious patterns, thus if the pattern is random, it indicates a good fit for a linear model. I have generated some random noise in R and have fitted an ANOVA model and plotted the residuals and now I am trying to understand what the residual plot is telling me about the model and how good it is, but I cannot really analyze the plot in depth and also do not understand whether there is a pattern being shown. Should the pattern be recognized with regards to the horizontal line or any type of pattern should be considered? I will really appreciate it if someone can explain in detail.
P.S. Both of the plots are showing exactly the same thing, just one of them is produced in a "fancier" way!
anova_model <- aov(Measurement ~ Treatment, data=Data)
residuals <- resid(anova_model)
plot(Data$Measurement, residuals, xlab="Measurement", ylab="Residuals")
abline(0,0)
qplot(Data$Measurement, residuals, colour = Data$Treatment,
shape = Data$Treatment, size=I(3.9),
xlab="Measurement Values", ylab="Residuals") +
labs(colour="Treatment Categories", shape = "Treatment Categories")
Model <- data.frame(Fitted = fitted(anova_model),
Residuals = resid(anova_model),
Treatment = Data$Treatment)
ggplot(Model, aes(Fitted, Residuals, colour = Treatment)) + geom_point()
Data
was generated using the following code in R:
X <- matrix(rep(1:5, each=5), nrow=5, ncol=5, byrow=FALSE)
Y <- matrix(rnorm(X, mean=0, sd=1), nrow=5, ncol=5, byrow=FALSE)
Treatment <- as.vector(X)
Measurement <- as.vector(Y)
Data <- data.frame(Measurement,Treatment)
Data$Treatment <- as.factor(Data$Treatment)