Contents
- What is heteroscedasticity?
- Why does heteroscedasticity matter?
- How to detect heteroscedasticity
- Visual inspection
- Formal tests
- How to fix heteroscedasticity
- Solution 1: add the missing variable
- Solution 2: weighted least squares
- Solution 3: logarithmic transformation
- Solution 4: robust standard errors
- Testing and fixing in Python
- A field example: farm income and farm size
- How to report heteroscedasticity tests
- Frequently asked questions
- What is heteroscedasticity in simple terms?
- Which test for heteroscedasticity is best?
- Does heteroscedasticity make the coefficients wrong?
- Is heteroscedasticity a problem in time series?
- Should WLS or robust standard errors be preferred?
- Can heteroscedasticity be ignored in large samples?
- References
Versi bahasa Indonesia: Pahami Heteroskedastisitas dan Cara Mengatasinya
Short answer: heteroscedasticity occurs when the variance of regression residuals is not constant across observations, for example when errors grow larger as X grows larger. The OLS coefficients remain unbiased, but they are no longer efficient and their standard errors are wrong, so t-tests, F-tests, and p-values become unreliable. It can be detected with a residual plot and with the Glejser, Breusch-Pagan, or White test, and it can be fixed by adding an omitted variable, transforming variables into logarithms, applying weighted least squares (WLS), or reporting robust standard errors.
What is heteroscedasticity?
A regression model splits every observation into a predicted part and an error: Yactual = a + b1X1 + … + bnXn + error. Ideally, the error is random. Randomness signals that the model has extracted every systematic pattern from the data and that what remains cannot be processed further.
Heteroscedasticity breaks that ideal. The size of the error still follows a pattern related to the independent variables. If the absolute error can be written as |e| = c + d1X1 + … + dnXn, then part of the information in the data has not yet been captured by the main equation. The opposite condition, constant error variance, is called homoscedasticity and is one of the classical assumptions of ordinary least squares (OLS).
Agricultural and economic data are especially prone to this problem. Large farms vary more in output than small farms; rich households vary more in spending than poor households. Consequently, residuals fan out as farm size or income rises.
Why does heteroscedasticity matter?
The consequences are frequently misunderstood. The coefficients themselves are still unbiased, so the estimated line is not systematically wrong. However, OLS is no longer the most efficient estimator, and the conventional formula for standard errors is incorrect. Thus, t-statistics and F-statistics may be inflated or deflated, and a variable may appear significant when it is not, or the reverse. Any conclusion based on hypothesis tests needs to be revisited.
How to detect heteroscedasticity
Visual inspection
Plot the residuals (or their absolute values) against the predicted values or against each independent variable. A random cloud suggests homoscedasticity. A funnel shape, where the spread widens or narrows systematically, suggests heteroscedasticity.

Formal tests
Several tests share the same null hypothesis of constant variance. The Glejser test regresses the absolute residuals on the independent variables. The Breusch-Pagan test regresses the squared residuals on the independent variables. The White test adds squares and cross-products of the predictors, which makes it sensitive to nonlinear patterns. The Park test uses the logarithm of squared residuals. In each case, a p-value below 0.05 indicates heteroscedasticity.

In the example dataset, the Glejser test in EViews produces a probability of the F-statistic below 0.05. Thus, the null hypothesis is rejected, and the model suffers from heteroscedasticity.
How to fix heteroscedasticity
Solution 1: add the missing variable
A patterned error often means that a relevant variable is missing from the model. That omitted variable explains why the error grows with X. When theory points to such a variable and data are available, adding it addresses the root cause rather than the symptom.
Solution 2: weighted least squares
The regression usually taught first is OLS. Weighted least squares differs in one word: weight. The OLS model Y = a + b1X1 + … + bnXn becomes, under WLS, a model in which each observation is multiplied by a weight w. OLS is simply the special case in which every weight equals one. Under WLS, observations with large error variance receive small weights, and observations with small variance receive large weights.
The appropriate weight is the inverse of the error variance, 1/σi², or the inverse of the standard deviation when working with the square root. This principle explains why many textbooks recommend dividing the model by an independent variable or by its square: such a division is a WLS weight in disguise. In EViews, selecting the variance option means that observations are divided by the variance, whereas selecting the inverse variance option means that they are multiplied by it; the same logic applies to the standard deviation options.

Before weighting, the OLS model is Y = −993.62 + 0.355X, and the Glejser test confirms heteroscedasticity. After WLS with the variance of Y as the basis for the weight, the model becomes Y = −595.65 + 0.3161X, and the Glejser test is no longer significant.

Solution 3: logarithmic transformation
Taking the natural logarithm of Y, and often of X as well, compresses large values more than small values, which frequently stabilizes the variance. The coefficients then become elasticities or semi-elasticities, which is convenient in production and demand studies.
Solution 4: robust standard errors
When the coefficient estimates are acceptable and only valid inference is required, heteroscedasticity-consistent (White) standard errors provide a simple fix. The coefficients stay the same; only the standard errors, t-statistics, and p-values change. In EViews, this option is available under Estimate, Options, Coefficient covariance matrix.
Testing and fixing in Python
import pandas as pd
import statsmodels.api as sm
from statsmodels.stats.diagnostic import het_breuschpagan
df = pd.read_csv("data.csv")
X = sm.add_constant(df[["X"]])
ols = sm.OLS(df["Y"], X).fit()
lm, lm_p, f, f_p = het_breuschpagan(ols.resid, X)
print("Breusch-Pagan p-value:", round(lm_p, 4))
# Robust (HC3) standard errors
print(sm.OLS(df["Y"], X).fit(cov_type="HC3").summary())
# WLS with weights inversely proportional to X squared
wls = sm.WLS(df["Y"], X, weights=1 / df["X"] ** 2).fit()
print(wls.summary())
The weight 1 / X² assumes that the error standard deviation grows proportionally with X. When the true variance structure is unknown, the weights can be estimated from a regression of the log of squared residuals on X, an approach known as feasible generalized least squares.
A field example: farm income and farm size
Heteroscedasticity is easier to understand through a concrete case. A survey records annual net income and land area for 120 vegetable farmers. Farmers with 0.1 hectare earn incomes that cluster within a narrow range, since there is little room for either large gains or large losses on such a small plot. Farmers with 2 hectares, however, show incomes that range from a heavy loss in a year of price collapse to a large profit in a year of shortage. When income is regressed on land area, the residual plot forms a clear funnel: small spread on the left, wide spread on the right.
In such a case, the Breusch-Pagan test typically returns a large statistic (for example χ² = 18.6; p < 0.001). The slope coefficient for land area remains unbiased, yet its conventional standard error understates the true uncertainty. Re-estimating with robust (HC3) standard errors may raise the standard error by 30% to 50%, and a coefficient that appeared highly significant may become only marginally significant. Alternatively, modeling the logarithm of income per hectare often stabilizes the variance, since the multiplicative nature of farm risk becomes additive on the log scale. Thus, the choice of remedy follows from the economic mechanism that produces the funnel.
How to report heteroscedasticity tests
A transparent report states the test, the statistic, and the decision. For example: “The Breusch-Pagan test indicated heteroscedasticity (χ²(3) = 18.6; p < 0.001). Therefore, the model was re-estimated using heteroscedasticity-consistent (HC3) standard errors. The coefficient of land area remained positive and significant (β = 4.21; robust SE = 1.37; p = 0.003).” When weighted least squares is used, the report should also state the weighting variable and the reason for choosing it. Consequently, the reader can judge whether the remedy matches the source of unequal variance.
Related guides on Catatan Budi: Variance inflation factor (VIF), R-squared vs adjusted vs predicted R-squared, ARCH and GARCH for time series volatility.
Frequently asked questions
What is heteroscedasticity in simple terms?
It is a violation of the regression assumption that every observation has the same error variance. The opposite and desired condition is homoscedasticity.
Which test for heteroscedasticity is best?
Breusch-Pagan is the most common general test, White detects nonlinear patterns, and Glejser is intuitive because it uses absolute residuals. Reporting one formal test together with a residual plot is usually sufficient.
Does heteroscedasticity make the coefficients wrong?
No. The coefficients remain unbiased, but they are inefficient and their standard errors are incorrect, so significance tests become misleading.
Is heteroscedasticity a problem in time series?
Yes. In time series, changing variance often appears as volatility clustering, which is modeled with ARCH and GARCH rather than with WLS.
Should WLS or robust standard errors be preferred?
Robust standard errors are simpler and safer when the variance structure is unknown. WLS is more efficient when the variance structure is known or can be estimated reliably.
Can heteroscedasticity be ignored in large samples?
Not entirely. Large samples do not remove the bias in conventional standard errors. However, robust standard errors perform well in large samples, so reporting them is a simple and widely accepted safeguard.
References
- Gujarati, D. N., and Porter, D. C. (2009). Basic Econometrics (5th ed.). McGraw-Hill.
- White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. Econometrica, 48(4), 817–838.
- Breusch, T. S., and Pagan, A. R. (1979). A simple test for heteroscedasticity and random coefficient variation. Econometrica, 47(5), 1287–1294.
Discussion
No comments yet. Have a question about this topic? Write it below and I will do my best to answer.