Generating a diagnostic plot of a fitted model
Diagnostics are methods to evaluate assumptions of the regression, which can be used to determine whether a fitted model adequately represents the data. In the following recipe, we will introduce how to diagnose a regression model through the use of a diagnostic plot.
Getting ready
You need to have completed the previous recipe by computing a linear model of the x
and y1
variables from the quartet, and have the model assigned to the lmfit
variable.
How to do it...
Perform the following step to generate a diagnostic plot of the fitted model:
- Plot the diagnostic plot of the regression model:
> par(mfrow=c(2,2)) > plot(lmfit)
Diagnostic plots of the regression model
How it works...
The plot
function generates four diagnostic plots of a regression model:
- The upper-left plot shows residuals versus fitted values. Within the plot, residuals represent the vertical distance from a point to the regression line. If all points fall exactly...