A residual plot graphs model residuals against predicted values to reveal whether errors have a consistent spread and structure. An ideal cloud appears relatively formless; visible patterns, gaps, or outliers signal assumptions or data problems requiring investigation. section 4.3.2 section 9.2.2
rats_weather["residuals"] = model.resid
rats_weather["predicted_values"] = model.predict() #1
plt.scatter(
rats_weather["predicted_values"],
rats_weather["residuals"], color="gray", s=5
) #2
plt.axhline(y=0, color="black", linestyle="-") #3
Create the diagnostic by storing residuals and predictions, scattering predictions against residuals, and marking the zero-error line. section 9.2.2
Use the plot to investigate model quality rather than treating it as a standalone verdict:
- Inspect uneven clouds, gaps, or extreme points for nonconstant error spread, unusual observations, or questionable records. section 9.2.2
- Check suspicious records directly; missing weather values filled with zero produced an illegitimate low-prediction observation that was removed. section 9.2.2
- Consider weighted least squares or transforming the dependent variable when residual spread is inconsistent. section 4.3.2


