Home › Research Methodology › Heteroskedasticity Explained
Below, we explain heteroskedasticity in plain language and show it clearly in real data from ScholarsColab.
Homoskedasticity vs heteroskedasticity at a glance
| Homoskedasticity | Heteroskedasticity | |
|---|---|---|
| Spread of values | The same everywhere | Changes with another variable |
| On a scatter plot | An even band of points | A funnel or fan shape |
| Everyday example | Daily rainfall error of a good gauge | Spending varies more among high earners than low earners |
| Effect on regression | Standard errors are correct | Standard errors, p-values and intervals can be wrong |
Worked example: does the h-index vary more over a research career?
We detect and fix heteroskedasticity in a real regression, notebook-style. Every result is calculated live, and you can run the same code yourself.
The data: one row per ScholarsColab mentor with at least five dated papers, giving their discipline, career length, number of papers, h-index and total citations. The file is anonymised: no names or identifiers, rows are shuffled and citation totals are rounded.
Step 1: Load the data
import numpy as np
import pandas as pd
from datetime import date
# The ScholarsColab Research Methods Index (mentors level): anonymised, updated daily
DATA = "https://scholarscolab.in/wp-json/scholarscolab/v1/research-methods-data?level=mentors"
mentors = pd.read_csv(DATA, comment="#") # lines starting with # hold the citation
def p_text(p):
return "< 0.001" if p < 0.001 else f"= {p:.3f}"
print(mentors.shape)
mentors.head()(891, 6)
| discipline | first_year | career_years | papers | h_index | total_citations | |
|---|---|---|---|---|---|---|
| 0 | Engineering & computer science | 2014 | 13 | 81 | 6 | 80 |
| 1 | Medicine & health | 2009 | 18 | 45 | 4 | 60 |
| 2 | Engineering & computer science | 2015 | 12 | 97 | 5 | 50 |
| 3 | Engineering & computer science | 1998 | 29 | 100 | 100 | 29550 |
| 4 | Medicine & health | 2020 | 7 | 37 | 25 | 2510 |
Step 2: Fit a regression and plot its residuals
We regress h-index on career length (years since a researcher’s first paper), then plot each residual (actual minus predicted) against the predicted value.
import statsmodels.formula.api as smf
import matplotlib.pyplot as plt
model = smf.ols("h_index ~ career_years", data=mentors).fit()
print(f"h_index = {model.params['Intercept']:.2f} + {model.params['career_years']:.3f} × career_years")
fig, ax = plt.subplots(figsize=(8, 4.5))
ax.scatter(model.fittedvalues, model.resid, s=12, alpha=0.4)
ax.axhline(0, color="grey")
ax.set_xlabel("Fitted h-index")
ax.set_ylabel("Residual")
plt.show()h_index = 3.80 + 0.425 × career_years
Step 3: Confirm it with a table
bands = pd.cut(mentors["career_years"], [0, 5, 10, 15, 20, 30, 70],
labels=["1–5", "6–10", "11–15", "16–20", "21–30", "31+"])
mentors.groupby(bands, observed=True)["h_index"].agg(["count", "median", "std"]).round(1)| count | median | std | |
|---|---|---|---|
| 1–5 | 116 | 3.0 | 2.7 |
| 6–10 | 172 | 5.0 | 6.0 |
| 11–15 | 264 | 7.0 | 8.9 |
| 16–20 | 156 | 9.0 | 10.1 |
| 21–30 | 98 | 15.0 | 17.3 |
| 31+ | 85 | 13.0 | 15.4 |
Step 4: Test it formally
from statsmodels.stats.diagnostic import het_breuschpagan
lm, lm_p, f, f_p = het_breuschpagan(model.resid, model.model.exog)
print(f"Breusch-Pagan test: LM = {lm:.1f}, p {p_text(lm_p)}")Breusch-Pagan test: LM = 35.8, p < 0.001
The Breusch-Pagan test checks whether the size of the residuals depends on the predictors. The p-value is < 0.001, so the test confirms heteroskedasticity: the size of the residuals depends on career length.
Step 5: Fix the standard errors
robust = smf.ols("h_index ~ career_years", data=mentors).fit(cov_type="HC3")
print(f"Ordinary standard error of the slope: {model.bse['career_years']:.4f}")
print(f"Robust (HC3) standard error: {robust.bse['career_years']:.4f}")Ordinary standard error of the slope: 0.0316 Robust (HC3) standard error: 0.0434
How to detect and fix heteroskedasticity
- Plot the residuals of your regression against the predicted values; a funnel shape is the classic sign.
- Use a formal test if needed: Breusch-Pagan or White’s test.
- Transform the outcome (for example, log or square root) when the spread grows with the size of values.
- Use heteroskedasticity-robust standard errors (also called White or HC standard errors).
- Consider a better-suited model, such as weighted least squares or a count model for count data.
Common mistakes reviewers point out
- Never checking the residuals of a regression.
- Reporting ordinary standard errors when heteroskedasticity is obvious.
- Removing high values as “outliers” when they are a genuine part of the pattern.
- Confusing heteroskedasticity with non-linearity; both can appear in residual plots and need different fixes.
Frequently asked questions
What is heteroskedasticity in simple terms?
It means the spread of values or errors is not constant: for example, it gets larger as another variable increases.
Why is heteroskedasticity a problem?
Standard regression assumes errors have the same spread everywhere. When they do not, standard errors, p-values and confidence intervals can be misleading, even though the coefficients themselves may be unbiased.
How do you test for heteroskedasticity?
Plot residuals against predicted values, and use tests such as the Breusch-Pagan test or White’s test.
How do you fix heteroskedasticity?
Common fixes are transforming the outcome (for example, taking logs), using robust standard errors, or using weighted least squares.
Is it heteroskedasticity or heteroscedasticity?
Both spellings are correct and mean the same thing; “heteroscedasticity” is more common in statistics, “heteroskedasticity” in economics.
Use this data in your own work
ScholarsColab (2026). ScholarsColab Research Methods Index [Data set]. Vidhilekha Soft Solutions Pvt Ltd. Retrieved 15 October 2026, from https://scholarscolab.in/research-methodology/. Licensed under CC BY 4.0.Download the data (CSV) →Need help applying this to your research?
Discuss your research problem with a PhD mentor, hand the whole project to a research project manager, or post your project and let matched experts apply.
Mentors whose published work uses this approach:
Professor Sanjeev GuptaCentral University of Himachal Pradesh1 related paper · View profile →
Tan Kwan HongSingapore University of Social Sciences1 related paper · View profile →
Arsene KellyUniversity of Dschang3 related papers · View profile →
Kazeem IsahCentre for Econometrics and Applied Research3 related papers · View profile →
