Heteroskedasticity
Heteroskedasticity means that the variance of the errors of a model is not constant: it changes with the explanatory variables or over time. Its opposite, homoskedasticity, is an assumption of ordinary least squares. In finance it is the rule rather than the exception: the residuals of a regression of a stock on the market are larger in turbulent markets, and the spread of company profits grows with the size of the company.
Heteroskedasticity leaves the coefficients of a least squares regression unbiased, but their usual standard errors are wrong, so t-statistics and p-values mislead and a factor can look significant when it is not. White (1980) gave standard errors that stay valid whatever form it takes, and a test for it; Breusch and Pagan (1979) test whether the variance of the residuals depends on the regressors.
The formula for the Breusch-Pagan test is as follows:
\[\text{LM} = n \cdot R^{2}\]Where n is the number of observations and \(R^{2}\) the R-squared of a regression of the squared residuals on the regressors. Under homoskedasticity it follows a chi-squared distribution with as many degrees of freedom as there are regressors, so a large statistic, with a p-value below the significance level, rejects a constant variance.
When the variance changes over time and depends on its own past, it is conditional heteroskedasticity, which is what makes volatility cluster. Engle (1982) modelled it with the ARCH model. The Finance Toolkit tests a regression for heteroskedasticity with the Breusch-Pagan, White and Goldfeld-Quandt tests, tests returns for conditional heteroskedasticity with the ARCH-LM test and models it with the GARCH family.
Example · AAPL, SPY · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "SPY"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
benchmark_ticker=None,
)
toolkit.econometrics.get_heteroskedasticity_test(method="white")
Which returns:
| Item | Value |
|---|---|
| White Statistic | 6.2187 |
| P-Value | 0.0446 |
| Reject Homoskedasticity (5%) | 1 |
References
- Paper White, H. (1980). “A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity.” Econometrica, 48(4), 817-838.
- Paper Breusch, T.S. & Pagan, A.R. (1979). “A Simple Test for Heteroscedasticity and Random Coefficient Variation.” Econometrica, 47(5), 1287-1294.
- Paper Engle, R.F. (1982). “Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation.” Econometrica, 50(4), 987-1007.