We made the same conclusion earlier with the Breusch-Pagan test where we regressed the residuals on commute_time. Here, the line is relatively flat, meaning we failed to find evidence of heteroscedasticity. ggplot(acs, aes(commute_time, res_sqrt)) We will just check commute_time, which had a non-significant p-value in our test earlier. This matches the conclusion we would draw from the Breusch-Pagan test earlier.Ĭheck the residuals against each predictor. The residual variance is decidedly non-constant across the fitted values since the conditional mean line goes up and down, suggesting that the assumption of homoscedasticity has been violated. We must plot the residuals against the fitted values and against each of the predictors. Because we forced all the residuals to be positive by taking their absolute value, instead of looking for whether the band of points is wider or narrow (variance is larger or smaller) at each value of \(x\), we simply look for whether the line goes up or down. We can then create a scale-location plot, where a violation of homoscedasticity is indicated by a non-flat fitted line. To check the assumption of homoescedasticity visually, first add variables of fitted values and of the square root of the absolute value of the standardized residuals ( \(\sqrt\)) to the dataset. It can also exist when variance is unequal across groups (categorical predictors): Heteroscedasticity can follow other patterns too, such as constantly decreasing variance, or variance that increases then decreases then increases again. We often see this pattern when predicting income by age, or some outcome by time in longitudinal data, where variance increases with our predictor. We failed to reject homoscedasticity for commute_time alone, but we would reject it for a combination of age and hours_worked.Ī classic example of heteroscedasticity is a fan shape. # Chisquare = 1.884285, Df = 1, p = 0.16985 ncvTest(mod, ~ age hours_worked) # Non-constant Variance Score Test ncvTest(mod, ~ commute_time) # Non-constant Variance Score Test In the second argument of ncvTest(), we can specify a one-sided formula with one or more variables to test whether the variance is non-constant for these terms. The small p-value leads us to reject the null hypothesis of homoscedasticity and infer that the error variance is non-constant. NcvTest(mod) # Non-constant Variance Score Test The default of ncvTest() is to regress the residuals on the fitted values. Load the car package to use its Breusch-Pagan test in ncvTest(), where “ncv” stands for “non-constant variance”. A small p-value, then, indicates that residual variance is non-constant (heteroscedastic). The Breusch-Pagan test regresses the residuals on the fitted values or predictors and checks whether they can explain any of the residual variance. Use the Breusch-Pagan test to assess homoscedasticity. 4.5.1 Corrections by Residual Distribution Shape.
0 Comments
Leave a Reply. |