🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Heteroscedasticity — Detection, Consequences, Solutions

Regression AnalysisDiagnostics🟢 Free Lesson

Heteroscedasticity

Regression Analysis

When Error Variance Isn't Constant

Heteroscedasticity violates a core OLS assumption, biasing standard errors and invalidating hypothesis tests. Detection through Breusch-Pagan and White tests, along with robust standard errors, ensures reliable inference.

  • Income Analysis — Variance in spending increases with income levels
  • Healthcare — Treatment effect variability differs across patient subgroups
  • Finance — Volatility clustering in stock returns creates non-constant error variance

When errors grow louder with the signal, robust methods keep inference on track.


What You'll Learn

  • 1Describe the classic mechanisms that generate non-constant error variance
  • 2Explain exactly which parts of the OLS output heteroscedasticity damages
  • 3Run the Breusch-Pagan and White tests and read their null hypotheses correctly
  • 4Choose between robust standard errors, weighted least squares and a variance-stabilising transform

Heteroscedasticity means the variance of the error term is not constant across observations. It violates the homoscedasticity assumption of OLS. The assumption is not a technicality: it is what makes the ordinary least squares standard errors the smallest possible among linear unbiased estimators, and what gives the t and F reference distributions their calibration.

Why Variance Usually Changes With the Level

Non-constant variance is the norm rather than the exception in applied work, and four mechanisms account for most of it.

  • Scale effects. Spending, revenue, and consumption are proportional to income. If the percentage error is constant, the absolute error grows with the mean, and the error variance grows with the square of the mean.
  • Mean-variance coupling in counts. Poisson and binomial outcomes have variance tied to the mean, so fitted values near 0.5 or near a large rate are intrinsically noisier than fitted values elsewhere.
  • Mixing populations. Combining households with and without children, or firms of very different size, creates subgroups with different spreads inside a single regression.
  • Ceiling and floor effects. Scores bounded at 0 and 100 compress near the limits and spread in the middle, producing a spindle shape rather than a fan.

Any of these leaves the coefficient estimates untouched while quietly corrupting the uncertainty around them.

What Breaks, and What Does Not

Under heteroscedasticity the OLS estimator stays unbiased and consistent as long as the regressors are exogenous — the first-order Gauss-Markov condition is unaffected. What fails is the variance of that estimator. The true sampling variance becomes the sandwich form

where is the diagonal matrix of the non-constant error variances. The classical formula assumes and therefore substitutes a matrix that is too simple in one direction or the other.

In cross-sectional data the usual direction is optimistic: with positive correlation between error variance and a regressor, the classical standard errors are too small, t-statistics are too large, and the true rejection rate of a 5 percent test can reach 10 to 15 percent. The practical consequence is a regression table that looks more decisive than the data warrant. Two things do not change: fitted values remain the best linear unbiased predictions of the mean, and still describes the share of variation explained. Heteroscedasticity is an inference problem, not a fit problem.

A worked illustration: a coefficient of 2.58 with a classical standard error of 0.42 gives t = 6.14 and a 95 percent interval from 1.76 to 3.40. Recomputed with HC3 robust standard errors of 0.66, the same coefficient gives t = 3.91 and an interval from 1.29 to 3.87. The conclusion survives, but the honest interval is 60 percent wider, and in a borderline case it would not.

Visual Diagnostics First

Formal tests are corroborating evidence; the plots are where you build the intuition.

  1. Residuals against fitted values. A symmetric cloud of constant width is what you want. A funnel opening to the right means variance rises with the mean; a funnel closing to the right means the opposite. Curvature, not spread, signals a functional form problem instead.
  2. Scale-location plot. Plot the square root of the absolute standardised residuals against fitted values with a smooth line. A rising line is direct evidence of increasing spread, and the smoothing makes the pattern easier to see than in the raw scatter.
  3. Residuals against each regressor. Spread that changes with one particular variable tells you which weight or transform to use.
  4. Residuals by group. When the data have natural categories, boxplots of residuals per category reveal unequal within-group variance immediately.

Formal Tests and Their Null Hypotheses

The Breusch-Pagan test regresses the squared residuals on the original regressors and forms

where counts the regressors excluding the constant. The null hypothesis is homoscedasticity: the squared residuals have no linear relationship with the regressors. Rejection means the error variance varies systematically with at least one regressor.

The White test extends the auxiliary regression by adding squared regressors and their pairwise products, so it detects non-linear variance patterns too. Its degrees of freedom equal the number of terms in that expanded regression. The trade-off is that the auxiliary regression can become unwieldy with many predictors, and the test has low power when the true pattern is simple.

The Goldfeld-Quandt test is the non-parametric alternative: sort observations by the suspect regressor, drop a middle block, and compare the residual sum of squares from the low segment against the high segment using an F statistic. It is powerful when you already know the direction of the variance change.

TestAlternative it detectsAuxiliary regressionWatch out for
Breusch-PaganLinear variance in the regressorsSquared residuals on XMisses non-linear patterns
WhiteGeneral variance patternsSquared residuals on X, squares and cross productsMany regressors exhaust degrees of freedom
Goldfeld-QuandtMonotone variance in a known variableTwo separate F testsRequires dropping observations
GlejserHeteroscedasticity as a mean modelAbsolute residuals on XNot a formal size-controlled test

A rejection by the White test is not proof of heteroscedasticity alone: because it includes squares and products of the regressors, it can also reject when the mean function is misspecified. That is why the plot and the test must be read together.

Fixing the Problem

The remedy depends on whether you want valid inference, more efficient estimates, or both.

ApproachWhat changesPoint estimatesStandard errorsAssumption you take on
HC0 to HC3 robust SEsNothingUnchangedCorrectedErrors have finite variance
Weighted least squaresRefits with weightsChangeCorrectWeight is proportional to inverse variance
Log or Box-Cox transformRefits on a new scaleChangeCorrect on that scaleVariance grows as a power of the mean
Bootstrap standard errorsResamples the dataUnchangedCorrectedObservations are independent
Model the variance explicitlyJoint mean and variance modelChangeCorrectChosen variance function is right

HC0 divides each squared residual by one; HC1 adds the degrees-of-freedom correction; HC2 divides by to fix an unbiased estimator under leverage; HC3 divides by and behaves best in small samples with influential points. HC3 is the safe default in cross-sectional work.

Weighted least squares is more efficient than robust standard errors if the weights are right, and it changes the coefficients as well as their uncertainty. If the error standard deviation is proportional to a known variable , weights make the transformed errors homoscedastic. Wrong weights make things worse, which is why robust standard errors are the more common prescription when the variance structure is uncertain.

Transformations have a side effect: coefficients become semi-elasticities. Fitting against turns into a percentage change in y for a unit change in x, which is often easier to interpret anyway.

Detection and Correction in Code

python
import numpy as np
import statsmodels.api as sm
from statsmodels.stats.diagnostic import het_breuschpagan, het_white, het_goldfeldquandt
import matplotlib.pyplot as plt

rng = np.random.default_rng(7)
n = 300
x = rng.uniform(1, 10, n)
X = sm.add_constant(x)

y_homo = 2 + 3*x + rng.normal(0, 2.0, n)          # constant variance
y_hetero = 2 + 3*x + rng.normal(0, 0.5*x, n)      # variance grows with x

for y, label in [(y_homo, "homoscedastic"), (y_hetero, "heteroscedastic")]:
    model = sm.OLS(y, X).fit()
    bp, bp_p, _, _ = het_breuschpagan(model.resid, model.model.exog)
    wh, wh_p, _, _ = het_white(model.resid, model.model.exog)
    gq, gq_p, _ = het_goldfeldquandt(y, X, alternative="two-sided")
    print(f"{label:15s} BP p={bp_p:.4f}  White p={wh_p:.4f}  GQ p={gq_p:.4f}")

model = sm.OLS(y_hetero, X).fit()
classic = model.get_robustcov_results(cov_type="HC0")
hc3 = model.get_robustcov_results(cov_type="HC3")
print(f"slope classical SE = {model.bse[1]:.4f}, t = {model.tvalues[1]:.3f}")
print(f"slope HC3       SE = {hc3.bse[1]:.4f}, t = {hc3.tvalues[1]:.3f}")
print("95% CI classical:", np.round(model.conf_int()[1], 3))
print("95% CI HC3      :", np.round(hc3.conf_int()[1], 3))

# Weighted least squares with the known weight 1 / x^2
wls = sm.WLS(y_hetero, X, weights=1/x**2).fit()
print(f"WLS slope = {wls.params[1]:.4f}, SE = {wls.bse[1]:.4f}")

fig, ax = plt.subplots(figsize=(8, 4))
ax.scatter(model.fittedvalues, model.resid, alpha=0.5)
ax.axhline(0, color="red", ls="--")
ax.set_xlabel("Fitted values"); ax.set_ylabel("Residuals")
ax.set_title("Residuals vs fitted: a funnel indicates non-constant variance")
plt.tight_layout(); plt.show()
fit <- lm(y ~ x)

ncvTest(fit)                       # Breusch-Pagan / score test
bptest(fit)                         # studentised Breusch-Pagan, package lmtest
white.test(fit)                    # White's general test

# Heteroscedasticity-consistent standard errors
library(sandwich)
library(lmtest)
coeftest(fit, vcov = vcovHC(fit, type = "HC3"))

# Weighted least squares with inverse-variance weights
w <- 1 / x^2
wls_fit <- lm(y ~ x, weights = w)
summary(wls_fit)

# Stabilising transform as an alternative
log_fit <- lm(log(y) ~ x)
bptest(log_fit)

⚠️Robust standard errors do not fix a misspecified mean

HC3 repairs the covariance matrix of the estimator around the model you fitted. If the true relationship is curved and you fitted a line, robust standard errors will honestly describe the uncertainty of the wrong line. Check functional form first with residuals against fitted values.

Common Mistakes

Reading a significant Breusch-Pagan test as a fatal flaw

Fix: It invalidates the classical standard errors, not the coefficients. Refit with HC3 robust standard errors and continue.

Applying weighted least squares with guessed weights

Fix: Estimate the relationship between residual spread and the regressor, or use robust standard errors instead, which need no variance model.

Ignoring a curved residual pattern and calling it heteroscedasticity

Fix: Curvature is a functional form problem. Add a quadratic term or transform the regressor before touching the variance.

Reporting only the robust table without saying it is robust

Fix: State the covariance estimator, HC0 through HC3 or Newey-West, so readers can reproduce and assess the result.

Best Practices

  • Plot residuals against fitted values and against every regressor before running any test
  • Report HC3 standard errors alongside the classical ones in cross-sectional regressions
  • Decide between inference fixes and efficiency fixes based on whether you know the variance structure
  • On bounded outcomes, check for floor and ceiling compression before adding terms

Key Takeaways

  • Heteroscedasticity leaves OLS coefficients unbiased but makes their standard errors wrong, usually too small in cross-sections
  • The residuals-versus-fitted funnel plot is the primary diagnostic; Breusch-Pagan and White supply the formal evidence
  • The White test adds squares and cross products of the regressors, so it detects non-linear variance but also reacts to mean misspecification
  • HC3 robust standard errors are the default fix because they require no model of the variance
  • Weighted least squares is more efficient when the weights are correct, and worse than OLS when they are not

Interview Questions

Q1: Does heteroscedasticity bias the regression coefficients?

No. As long as the regressors are exogenous, OLS remains unbiased and consistent. What breaks is the estimated variance matrix, so the classical standard errors, t-statistics and confidence intervals are wrong.

Q2: What is the difference between the Breusch-Pagan and White tests?

Breusch-Pagan regresses squared residuals on the original regressors and so detects variance that changes linearly with them. White adds squares and pairwise products, detecting non-linear patterns at the cost of many auxiliary regressors and some sensitivity to mean misspecification.

Q3: When would you choose weighted least squares over robust standard errors?

When you know or can estimate how the variance relates to the regressors. WLS then gives smaller standard errors than OLS with HC corrections. If the variance structure is uncertain, HC3 is safer because a wrong weight can make inference worse than plain OLS.

Q4: How do you interpret a regression where y has been logged?

Coefficients become approximate percentage changes: a one-unit increase in x is associated with a 100 times beta percent change in y. Logging is often motivated precisely because it stabilises variance that grows in proportion to the mean.

Frequently Asked Questions

Is heteroscedasticity ever harmless?

For description and prediction, largely yes: fitted values and are unaffected, and prediction intervals can be repaired directly from the fitted variance. It matters whenever you report t-statistics, confidence intervals, or F tests, which covers almost every published regression.

Does large sample size make the problem disappear?

Not by itself. The classical standard errors remain inconsistent for the true variance of as n grows, so the t-statistics do not converge to their reference distribution. Large samples do make the robust covariance estimators more accurate, and they make formal tests more likely to reject trivial departures.

How is heteroscedasticity different from autocorrelation?

Heteroscedasticity is non-constant variance across observations; autocorrelation is correlation between observations. The sandwich estimator generalises to both: HC variants handle the first, Newey-West handles the second, and clustered standard errors handle arbitrary correlation within blocks.

Should I drop the observations causing the problem?

No. Heteroscedasticity is a property of the population you are modelling, not a defect of individual rows. Removing high-variance observations truncates the outcome and biases the coefficients toward the low-variance region. Weight, transform, or use robust errors instead.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Statistics Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement