Open oldoc63 opened 1 year ago
Homoscedasticity is a fancy way of saying that the residuals have equal variation across all values of the predictor variable. A common way to check this is by plotting the residuals against the fitted values.
plt.scatter(fitted_values, residuals)
plt.show()
If the homoscedasticity assumption is met, then this plot will look like a random splatter of points, centered around y=0.
If there are any patterns or asymmetry, that would indicate the assumption is not met and linear regression may not be appropriate.
Once we've calculated the fitted values and residuals for a model, we can check the normality and homoscedasticity assumptions of linear regression.
Normality assumption
The normality assumption states that the residuals should be normally distributed. To check this assumption, we can inspect a histogram of the residuals and make sure that the distribution looks approximately normal (no skew or multiple "humps").
When residuals appear normally distributed, that lead us to conclude that the normality assumption is satisfied.
If the plot instead looked something like the distribution below (which is skewed right), we would be concerned that the normality assumption is not met: