Skip to main content
v2026.11,986 entries · CC-BY 4.0

What Is Homoscedasticity? Definition, Formula and Examples

Homoscedasticity means a model’s residuals have constant variance. Formula, worked numeric example, Breusch-Pagan test, reporting and code.

Written and maintained by CASRAI Editorial Board

Published

On this page

Homoscedasticity means that the residuals of a statistical model have the same variance for every value of the fitted values and of the predictors. In a regression, the vertical scatter of the data around the fitted line is equally wide at the low end, the middle and the high end of x. When that spread changes systematically, the data are heteroscedastic (also spelled heteroskedastic). The University of Wisconsin-Madison Social Science Computing Cooperative states the assumption in these terms and notes that it is needed for accurate standard errors of the parameter estimates.

This page defines the term, writes out the formula with every symbol explained, and works one complete example by hand with the arithmetic shown, including a Breusch-Pagan test. It then covers how to read the result, common mistakes, a sample reporting sentence, and short code for Excel, R and Python. The data table at the end compares the standard ways to check and handle the assumption.

Definition of homoscedasticity in one paragraph

Homoscedasticity is the assumption that the error term of a model has constant variance. In practice you check it on the residuals, which are the observed values minus the model’s fitted values. If the residuals are about as spread out for small fitted values as for large ones, the assumption looks reasonable. If they fan out, narrow in, or form a horn shape, the NIST/SEMATECH e-Handbook of Statistical Methods says the plot indicates that the assumptions of the analysis are not satisfied. The word is about variance, not about the shape of the distribution: constant spread and a bell-shaped distribution are separate questions. For the visual side of this check, see the companion guide on how to read a residual plot for homoscedasticity.

Homoscedasticity formula

For a simple linear regression with one predictor, the model is yi = β0 + β1xi + εi. Homoscedasticity is a statement about the errors εi:

Var(εi | xi) = σ² for every observation i = 1, …, n

Heteroscedasticity replaces the single constant with one that can differ by observation:

Var(εi | xi) = σi²

  • yi: the observed outcome for observation i.
  • xi: the predictor value for observation i.
  • β0, β1: the intercept and slope of the population line.
  • εi: the unobserved error. You never see it, so you estimate it with the residual ei = yi − ŷi, where ŷi is the fitted value.
  • σ²: the one common error variance under homoscedasticity.
  • σi²: the error variance that is allowed to change from observation to observation under heteroscedasticity.

The Breusch-Pagan statistic

The Breusch-Pagan test (Breusch and Pagan, 1979, Econometrica 47(5), 1287-1294) turns the definition into a test. In its widely implemented studentized form (Koenker), you square the residuals, regress them on the predictors, and compute:

LM = n × R²aux

Here n is the number of observations and R²aux is the R² of the auxiliary regression ei² = α0 + α1xi + ui. Under the null hypothesis, LM follows a chi-square distribution with k degrees of freedom, where k is the number of predictors. The statsmodels documentation states the null as “homoscedasticity implies that alpha=0”, meaning the residual variance does not depend on the predictors.

When a model has non-constant variance and you know how it varies, weights can be used. The R manual for lm describes weights as an optional vector that, when supplied, fits by weighted least squares, with weights inversely proportional to the variances; leaving it out gives ordinary least squares. In symbols, wi ∝ 1/σi².

Homoscedasticity examples with real numbers

The two small data sets below use the same ten x values (1 to 10). Dataset A is built so that the scatter grows with x. Dataset B has residuals of similar size throughout. Both are constructed for this page for illustration; ten points is far too few for a real analysis. Every number was computed from the values shown.

Example 1: a heteroscedastic pattern (Dataset A)

Step 1, fit the line. The y values are 2.1, 3.8, 3.2, 4.1, 5.9, 5.2, 8.6, 6.3, 11.0, 6.4. Their sum is 56.6, so ȳ = 5.66, and x̄ = 5.5. With Sxx = Σ(x − x̄)² = 82.5 and Sxy = Σ(x − x̄)(y − ȳ) = 58.7, the slope is b1 = 58.7 / 82.5 = 0.7115 and the intercept is b0 = 5.66 − 0.7115 × 5.5 = 1.7467.

Step 2, compute residuals. Each fitted value is 1.7467 + 0.7115x, and each residual is y − fitted.

x y Fitted ŷ Residual e Squared residual e²
1 2.1 2.458 −0.358 0.128
2 3.8 3.170 0.630 0.397
3 3.2 3.881 −0.681 0.464
4 4.1 4.593 −0.493 0.243
5 5.9 5.304 0.596 0.355
6 5.2 6.016 −0.816 0.665
7 8.6 6.727 1.873 3.507
8 6.3 7.439 −1.139 1.297
9 11.0 8.150 2.850 8.121
10 6.4 8.862 −2.462 6.061

Step 3, compare the spread. The squared residuals for x = 1 to 5 sum to 1.587, a mean of 0.317. For x = 6 to 10 they sum to 19.651, a mean of 3.930. The average squared residual is 12.4 times larger in the upper half. A plot of residuals against fitted values would show the fan shape described in the residual-plot guide.

Step 4, run the Breusch-Pagan test. Regress e² on x. The auxiliary line is e² = −1.934 + 0.738x. The total sum of squares of e² around its mean (2.124) is 72.571 and the residual sum of squares of the auxiliary fit is 27.673, so R²aux = 1 − 27.673 / 72.571 = 0.6187. Then:

LM = n × R²aux = 10 × 0.6187 = 6.19, with 1 degree of freedom (one predictor).

The 5% critical value of a chi-square distribution with 1 degree of freedom is 3.841. Since 6.19 exceeds it, the p-value is below .05; the exact value is p = .013. The test rejects constant variance for Dataset A.

Example 2: a homoscedastic pattern (Dataset B)

Dataset B has y values 2.4, 3.1, 3.0, 4.6, 4.8, 5.9, 7.4, 6.9, 8.3, 9.6. The fitted line is ŷ = 1.26 + 0.7891x. The residuals run from −0.673 to 0.616 with no trend in their size. The mean squared residual is 0.157 for x = 1 to 5 and 0.209 for x = 6 to 10, a ratio of 1.3 rather than 12.4. The auxiliary regression gives R²aux = 0.0241, so LM = 10 × 0.0241 = 0.24, p = .623. There is no evidence against constant variance, which is the pattern homoscedasticity describes.

Both datasets are small, so treat the p-values as illustrations of the arithmetic. The statsmodels documentation, citing Greene, cautions that the LM version of the test can overstate significance in small and moderate samples and recommends the F version in that situation.

How to interpret the result

A homoscedasticity check has two parts: a picture and a number. Use them together. The table below summarises how the sources read each outcome.

What you see How to read it Source
Residuals vs fitted values form an even band around zero Consistent with equal variance for every fitted value. SSCC, NIST
Residuals fan out or form a horn shape Variance changes with the fitted value; the NIST handbook calls the horn a typical plot showing the assumptions are not satisfied. NIST
Scale-location smooth line is not flat A violation of equal variance (SSCC plots the square root of the absolute standardized residuals against the fitted values). SSCC
Breusch-Pagan p-value is small Evidence of heteroscedasticity; the test regresses residuals on the fitted values or predictors. SSCC, statsmodels
Breusch-Pagan p-value is not small No evidence against constant variance in the form the test checks; it is not proof that the variance is constant. Editorial reading of the null hypothesis in statsmodels

The p-value is a cut-off convention, not a measure of how much heteroscedasticity there is. For a sense of size, look at the plot or at the ratio of residual variances, as in Step 3 above.

Assumptions and common mistakes

  • Checking the wrong thing. The assumption concerns the variance of the residuals (errors), not the variance of the raw outcome variable and not the shape of the distribution.
  • Trusting a horn-shaped plot from a mis-specified model. The NIST handbook cautions that a residual plot is only reliable if the functional part of the model adequately describes the systematic variation. A horn can appear because the model form is wrong, so fix the model before drawing conclusions.
  • Omitting the constant in the test. In statsmodels, the exog_het matrix must contain a constant.
  • Ignoring test defaults. het_breuschpagan uses robust=True by default, the Koenker studentized version, which assumes iid errors. Setting robust=False gives the original Breusch-Pagan test, which assumes normal residuals.
  • Stopping after the first fix. The SSCC regression diagnostics page lists checking other assumptions, changing the model formula or adding interactions, using a generalized linear model, and weighted least squares as remedies, and says to re-check all assumptions afterwards, since a change to the model can alter every diagnostic.
  • Treating the assumption as optional. With heteroscedastic errors the usual standard errors are unreliable, which affects every confidence interval and test built on them. Heteroscedasticity-consistent (robust) standard errors, introduced by White (1980), are a common response; see the guide to robust standard errors HC0 to HC3.

What to do when the assumption fails

The sources agree on the broad menu rather than on one fix. Weighted least squares gives less weight to noisier observations; see weighted least squares for the method. Transforming the outcome is another route; the guide on log and other data transformations explains when this is used. Robust standard errors leave the coefficients as they are and change how their uncertainty is estimated. For the test itself, in more detail, see the Breusch-Pagan test guide.

How to report homoscedasticity (APA-style example)

Report the test used, the statistic with its degrees of freedom and sample size, the p-value, and what you did about the result. For Dataset A a sentence in the common style for chi-square results would read:

A Breusch-Pagan test indicated that the residual variance was not constant, χ²(1, N = 10) = 6.19, p = .013, so weighted least squares was used.

For Dataset B:

A Breusch-Pagan test found no evidence of heteroscedasticity, χ²(1, N = 10) = 0.24, p = .623.

Statistical symbols such as p are normally italicised and the leading zero is dropped for quantities that cannot exceed 1; the guide on how to report p-values covers the formatting in detail. Always follow the target journal’s instructions where they differ from a general style.

How to calculate it in Excel, R or Python

Excel

Put x in A2:A11 and y in B2:B11. Excel has no built-in Breusch-Pagan function, but the auxiliary regression is two formulas.

C2:  =INTERCEPT($B$2:$B$11,$A$2:$A$11)+SLOPE($B$2:$B$11,$A$2:$A$11)*A2   (fitted, fill down)
D2:  =(B2-C2)^2                                                          (squared residual, fill down)
F2:  =COUNT(A2:A11)*RSQ(D2:D11,A2:A11)                                    (LM = n x R2)
F3:  =CHISQ.DIST.RT(F2,1)                                                 (p-value, 1 df)

With Dataset A, F2 returns 6.19 and F3 returns 0.0129.

R

x <- 1:10
y <- c(2.1, 3.8, 3.2, 4.1, 5.9, 5.2, 8.6, 6.3, 11.0, 6.4)
mod <- lm(y ~ x)
library(lmtest)
bptest(mod)          # studentized (Koenker) Breusch-Pagan: BP = 6.19, df = 1, p = 0.0129
library(car)
ncvTest(mod)         # related score test on the fitted values (default); its statistic differs
plot(mod, which = 3) # scale-location plot

The SSCC page documents car::ncvTest(mod) and ncvTest(mod, ~ x) for the fitted-value and predictor versions. See also the guide on bptest in R.

Python

import statsmodels.api as sm
from statsmodels.stats.diagnostic import het_breuschpagan

x = list(range(1, 11))
y = [2.1, 3.8, 3.2, 4.1, 5.9, 5.2, 8.6, 6.3, 11.0, 6.4]
X = sm.add_constant(x)             # exog must contain a constant
res = sm.OLS(y, X).fit()
lm, lm_p, f, f_p = het_breuschpagan(res.resid, X)   # robust=True by default
print(round(lm, 2), round(lm_p, 4))   # 6.19 0.0129

For more on fitting models this way, see statsmodels OLS.

FAQ

What is homoscedasticity?

It is the condition that the errors of a model have the same variance at every value of the predictors and fitted values. In a regression plot, the scatter around the line has constant width.

What is the opposite of homoscedasticity?

Heteroscedasticity (or heteroskedasticity): the spread of the errors changes with the fitted value or a predictor, for example growing wider as x increases, as in Dataset A.

Why does homoscedasticity matter?

Per the SSCC regression diagnostics page, it is needed for accurate standard errors of the parameter estimates. Standard errors feed confidence intervals and significance tests.

How do you test for homoscedasticity?

Plot the residuals against the fitted values, and run a formal test such as Breusch-Pagan. A small p-value is evidence of heteroscedasticity. The worked example above shows the whole calculation.

Does homoscedasticity mean the data are normally distributed?

No. It concerns constant variance, not the shape of the distribution. The two ideas are checked separately, although the original Breusch-Pagan test (robust=False in statsmodels) additionally assumes normal residuals.

What is the formula for homoscedasticity?

Var(εi | xi) = σ² for all i. The Breusch-Pagan test statistic is LM = n × R² from regressing squared residuals on the predictors.

Sources

  • Social Science Computing Cooperative, University of Wisconsin-Madison. Regression Diagnostics in R, “Homoscedasticity”. sscc.wisc.edu. Read 2026-11-12.
  • statsmodels documentation, statsmodels.stats.diagnostic.het_breuschpagan. statsmodels.org. Read 2026-11-12.
  • R Documentation, stats::lm, “weights” argument. stat.ethz.ch. Read 2026-11-12.
  • NIST/SEMATECH e-Handbook of Statistical Methods, section 4.4.4.2, residuals versus predicted values. itl.nist.gov. Read 2026-11-12.
  • Breusch, T. S., and Pagan, A. R. (1979). A simple test for heteroskedasticity and random coefficient variation. Econometrica, 47(5), 1287-1294.
  • White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. Econometrica, 48(4), 817-838.

Data: Methods for checking and handling unequal residual variance in regression

Compares four common ways to check or handle heteroscedasticity in a regression, with what each flags or does and the software function that implements it, compiled from statistical software documentation and statistics reference pages.

Methods for checking and handling unequal residual variance in regression
MethodRoleWhat it flags or doesSoftware function
Residuals vs fitted plotVisual checkHorn or fan shape indicates the constant-variance assumption is not satisfied; reliable only if the model form fits the systematic variationplot(mod, which = 1) in R
Scale-location plotVisual checkNon-flat smooth line of sqrt(|standardized residuals|) vs fitted values indicates a violationplot(mod, which = 3) in R
Breusch-Pagan testFormal testNull hypothesis: residual variance does not depend on the predictors; small p-value indicates heteroscedasticitycar::ncvTest(mod) in R; statsmodels het_breuschpagan(resid, exog_het, robust=True)
Weighted least squaresRemedyFits with weights inversely proportional to the variances; omitting weights gives ordinary least squareslm(y ~ x, weights = w) in R

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about What Is Homoscedasticity? Definition, Formula and Examples

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →