DPredict · Guide test 189
Koenker studentized Breusch–Pagan test
Provides a less normality dependent version of the Breusch–Pagan variance test.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Linear regression (OLS) — How does a numeric outcome depend on one or more predictors?
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Koenker studentized Breusch–Pagan test
Adds curve × (x − 5)².
Error SD grows like exp(h · (x − 5)/5).
Errors in collection order carry φ × the previous error.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how BP varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .002).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- from regressing squared residuals on x
The verdict
BP(1) = 9.77, p = .002
p ≤ α = .050: reject H₀
The default heteroskedasticity check: robust to non-normal errors. If it fires, use HC3 standard errors or model the variance.
- Statistic
- 9.770
- p-value
- 0.0018
Koenker studentized Breusch–Pagan test on 40 (x, y) pairs: BP(1) = 9.77, p = .002. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: homoskedastic regression errors.
Assumptions
Correct mean model; independent observations and finite appropriate moments; normal errors unnecessary for the studentized large sample result.
Formula
Parameters and notation
Regress squared OLS residuals on an intercept and q variance predictors; R² is centered auxiliary R².
Structure of the method
Regress squared OLS residuals on a constant and the chosen variance predictors, then use n times the centered auxiliary R-squared. Studentization changes the original Breusch–Pagan scaling so that its large-sample result does not require normally distributed errors under the stated moment and independence conditions.
Estimated and nuisance parameters
Original mean coefficients, squared residuals, auxiliary coefficients, and auxiliary explained variation are estimated. The tested dimension is the rank of the nonconstant variance design; it is not simply the total number of columns supplied before resolving aliases.
Settings and design choices
Choose the variance specification, constant handling, sample, and studentized variant explicitly. This robustness concerns distributional assumptions about independent errors; it does not automatically cover serially correlated, clustered, or infinite-moment observations. Define any multiple-variance-predictor comparisons in advance.
Fitting and adaptation
Refit the conditional mean and auxiliary model after scientifically justified specification changes. For dependent data, use a specifically justified robust score/Wald or resampling method rather than the unmodified nR-squared reference. If modeling variance for subsequent feasible GLS, validate that variance model independently and account for its estimation.
Sensitivity and robustness
Heavy tails beyond the required moments, high leverage, misspecified means, and weak variance signals affect reliability. Large auxiliary designs consume information and may overfit squared residual noise. Compare the result with graphical variance patterns and robust coefficient inference; a nonrejection is an absence of detected variance structure in the chosen directions, not a universal robustness certificate.
How to use and calibrate
Compare with χ²q asymptotically. This is the studentized Breusch–Pagan/Koenker version.
Example application
Check variance heterogeneity when the error distribution is nonnormal.
Interpretation and pitfalls
Watch out
Serial or clustered dependence still requires a different robust calibration. It is not a universal robust specification test.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
The variance design/order and lag count are prespecified. LM and F versions may both be printed; identify which reference was used.
Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
import statsmodels.api as sm
n=100
x=rng.normal(size=n); z=rng.normal(size=n); y=1+.5*x+.3*z+rng.normal(size=n)
X=sm.add_constant(np.column_stack([x,z])); fit=sm.OLS(y,X).fit(); reduced=sm.OLS(y,X[:,:2]).fit()
from statsmodels.stats.diagnostic import het_breuschpagan
print(het_breuschpagan(fit.resid,fit.model.exog,robust=True))
Output
(np.float64(0.6535592846618421), np.float64(0.7212426568677298), np.float64(0.31906150917801007), np.float64(0.7275907086566993))
Validated — Executed successfully in the validation environment · needs lmtest
set.seed(2026)
n <- 100; x <- rnorm(n); z <- rnorm(n); y <- 1+.5*x+.3*z+rnorm(n)
d <- data.frame(y,x,z); fit <- lm(y~x+z,data=d); reduced <- lm(y~x,data=d)
print(lmtest::bptest(fit,studentize=TRUE))
Output
studentized Breusch-Pagan test data: fit BP = 0.17469, df = 2, p-value = 0.9164
Sources
- lmtest — lmtest · bptestAuthor documentation/source reviewed: lmtest 0.9-40.search.r-project.org
- bptestsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 189, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT189.