What is Heteroskedasticity and Why should we care?
Hello folks! It has been a while!
What is Heteroskedasticity and Why should we care?
Hello folks! It has been a while!
➽To give you a perspective, let’s say you run a simple linear model, the next thing we usually do is to see whether our coefficients are statistically significant by checking the p-values, right? Sometimes we may conclude that our coefficients are statistically significant when in-fact are not! It is important that our linear model fulfills all the required assumptions before we can make statements about its results!
➽One of the ordinary least squares (OLS) linear regression assumptions is that all of the observations of the dependent variable come from distributions with the same variance. When the conditional variance of y or e is not constant, we say the response, or the residuals are heteroskedastic. if heteroskedasticity is present, the regular OLS estimator is no longer the best linear unbiased estimator(BLUE), we need to find a better estimator.
Types of heteroskedasticity:
1 Pure heteroskedasticity- We have the correct indepedent variables but the model still shows heteroskedasticity.
2 Impure Heteroskedasticity -This type of heteroskedasticity is caused by a specification error such as an omitted variable. The regression may include too few variables or too many variables which causes a model with inconsistent variance.
⧭ We can detect heteroskedasticity by scatter plots or through statistical tests:
1: Spotting heteroskedascity with scatter plots
(i) Plotting dependant variable against the regressor suspected of heteroskedasticity:
library(PoEdata)
data(food)
model1<-lm(food_exp~income, data = food)
plot(food$income, food$food_exp, type = "p", col="orange",
xlab = "Income", ylab = "Food Expenditure")
abline(model1)

Looking at the above graph, we can clearly see that expenditure on food stays closer to its mean(regression line) at lower incomes but spreads about its mean at higher incomes. This, in a nutshell, is what we refer to as heteroskedasticity.
(ii) Residual plots:
-Plot residuals against regressors we suspect of heteroskedasticity or against fitted values of the model
model1<-lm(food_exp~income, data = food)
res<-residuals(model1)
yhat<-fitted.values(model1)
plot(food$income, res, xlab = "Income", ylab = "residuals")
plot(yhat, res, xlab = "fitted values", ylab = "residuals")

Residuals against Income regressor

Residuals against fitted values
2 heteroskedasticity tests
-The three main tests are:
1 White Test
2 The Breusch-Pagan Test
3 Goldfeld-Quandt Test
Our focus for now is the Breusch-Pagan Test:
#The Breusch-Pagan Test
library(lmtest)
bp<-bptest(model1)
bp

Breusch-Pagan-Heteroskedasticity- Test
We therefore reject the null hypothesis of homoskedasticity since p-value is less than alpha 0.05. The test implies that heteroskedasticity is present in our model so we need to correct the issue.
In the presence of heteroskedascity,
The coefficient estimators are still unbiased under the usual OLS method, but their variance is no longer reliable and this may lead to wrong conclusions based on confidence intervals and hypothesis testing .
So it is important to correct the heteroskedasticity problem so that we can be confident of the significance of our regression coefficients as we may conclude that our model is statistically significant when it is not.
Remedies for Heteroskedasticity
1: Computing Robust Standard Errors
Use robust standard errors instead of regular standard errors.
-Below, I compared the results of the two:
1 Regular standard errors:
#Regular standard errors
library(broom)
library(knitr)
model1<-lm(food_exp~income, data = food)
kable(tidy(model1))

*OLS regular standard errors*
*2 Robust(HC1) standard errors(White Robust standard errors):*
library(lmtest) library(car) cov1<-hccm(model1, type="hc1") model1.HC1<-coeftest(model1, vcov=cov1) kable(tidy(model1.HC1))

*OLS robust standard errors*
What changes did you notice?
- The coefficient estimators remain the same
- The robust standard errors has higher t-statistics and lower p-values
-This tells us how it is important to correct heteroskasticity as it could have serious consequences if not corrected. In the presence of heteroskedasticity, we might conclude a coefficient estimator as statistically significant when it is not in real sense.
- Note that we use coeftest() for robust standard errors but summary() for OLS
- **3** You may also explore Generalized Least Squares(GLS) or Wighted Least squares (WLS) for correcting heteroskedasticity. Unlike the OLS estimates with robust standard errors, GLS or WLS change the coefficients of the estimators.

*OLS and WLS Residuals*
- WLS scatter plot is in red, and OLS in black
In the above graph, which scatter plots show heteroskedasticity? The OLS or WLS? You are right, it is the OLS! The WLS method corrects the heteroskedasticity issue. Homoskedasticity is needed to justify the usual t tests, F tests, and confidence intervals for OLS estimation of the linear regression model.
**4** For impure heteroskedasticity, we may also need to add or remove a variable
-If we allow heteroskedasticity to slide in our models, we face the risk of drawing wrong conclusions when conducting significance tests. so checking for heteresokedasticity and correcting it is a great step towards making reliable statements about the significance of regression coefficients.
Thanks for your time! 메타데이터
- post_id
- 1f61bcdf98aa
- slug
- what-is-heteroskedasticity-and-why-should-we-care-1f61bcdf98aa
- url
- https://medium.com/found-it/what-is-heteroskedasticity-and-why-should-we-care-1f61bcdf98aa
- canonical_url
- https://medium.com/found-it/what-is-heteroskedasticity-and-why-should-we-care-1f61bcdf98aa
- author_url
- https://medium.com/@zamalik336
- status
- ok
- fetched_at
- 2026-06-26 21:52:29