# Tests of heteroscedasticity in linear regression models

I am unfamiliar with the implementation used in the R package GVLMA. What are some basic tests of heteroscedasticity in linear regression models and how or where are they implemented?

• Don't test, just graph it. – AdamO Jun 30 '15 at 19:54
• In econometrics, various tests are often used. Maybe the most prominent one is the Breusch-Pagan test, implenented in car::ncvTest and lmtest::bptest. A particular flavour of this test is the White test. – Achim Zeileis Jun 30 '15 at 23:07

While I'm not as familiar with the gvlma package, we typically test for non-constant variance (heteroscedasticity) by checking residual plots. In R, this is easy to do simply by using the plot() function on the result of a lm() fit. Here's an example using a subset of the diamonds dataset:

library(ggplot2); data(diamonds);
diamonds <- subset(diamonds, carat < 1)

fit <- lm(data = diamonds, price ~ carat)
plot(fit)


We see from the residuals vs. fitted plot (the first plot that's generated using the plot() function) that the variance of the residuals increase as the fitted values increase:

This is the sign of heteroscedasticity.

Of course, this was a very simple regression. But the same technique can be applied to multiple linear regression. For example, we can do:

fit2 <- lm(data = diamonds, price ~ carat + cut)
plot(fit2)


And we see the same problem from the residuals vs. fitted plot.

I hope this answers your question? You should know what to do next when there is non-constant variance in your response.

• This gives you an idea indeed, but there are also formal tests, such as GQ, White, etc. – rbm Jun 30 '15 at 17:49

GVLMA uses a directional test: Basically, it is calculated by fitting a regression model for the squared residuals against the ordered $x$ values and determining if there is a trend. This test is not powered to detect any difference if the residuals have symmetric behavior (often the case). A more robust version might use a smoothing spline for the ordered $x$ to visualize trends, or a semivariogram.

Lastly, you might just use a robust error estimator, like the Huber-White sandwich error, that gives you valid confidence intervals for the betas even when there is hetereoscedasticity. This is useful if your main objective is inference.