Last updated in April 2022

Goals for Today

  • Learn how to deal heteroscedasticity
  • Learn how to deal with dependent errors

Heteroskedasticity

Heteroskedasticity

  • Heteroskedasticity is relatively common, e.g. in bounded data.
mod1 = lm(infantMortality ~ tfr, data = un)
plot(mod1, which = 1)

Effects of Heteroskedasticity

  • When the assumption of homoscedasticity is broken two things will happen:


  1. Regression coefficients’ estimates become less efficient.
  2. Standard errors will be biased (usually too narrow confidence intervals, too low p values)


  • To solve this, let’s remind ourself how variance works.

When Homoscedasticity holds

When Homoscedasticity holds

  • If we assume homoskedasticity, we can estimate variance of residuals for every value of x be computing variance of all residuals at once:

\[ SE_\beta = \frac{\sigma^2 \sum(x_i - \bar{x})^2}{[\sum(x_i - \bar{x})^2]^2} = \frac{\sigma^2}{\sum(x_i - \bar{x})^2} \]


  • \(SE_\beta\) = Standard error of regression coefficient
  • \(x_i\) = Observation i of the variable x
  • \(\bar{x}\) = Mean value of x
  • \(sigma^2\) = Variance of residuals

Wild Heteroskedasticity Appears!

  • What if the variances are not identical?

Wild Heteroskedasticity Appears!

  • The overall variance doesn’t match any single group.

Wild Heteroskedasticity Appears!

  • If the assumption of homoscedasticity is violated, we cannot use the total residual variance as an estimate for individual levels.

Robust Standard Errors

  • We simply go through the work of estimating residual variance for each level.

  • From the classic formula:

\[ SE_\beta = \frac{\sigma^2 \sum(x_i - \bar{x})^2}{[\sum(x_i - \bar{x})^2]^2} \]

  • To a new one not assuming homoscedasticity:

\[ SE_\beta = \frac{\sum(x_i - \bar{x})^2*\sigma_i^2}{[\sum(x_i - \bar{x})^2]^2} \]

Robust Standard Errors

\[ SE_\beta = \frac{\sum(x_i - \bar{x})^2*\sigma_i^2}{[\sum(x_i - \bar{x})^2]^2} \]


  • (Heteroscedastic) Robust Standard Error
  • White’s Standard Error
  • Sandwich Error
  • HCO

Variants of Robust Errors

  • The previous formula is the original approach

  • Works well in big samples, biased in small ones.

  • Various corrections proposed:

    • HC1 (original correction, probably the worst one)
    • HC2
    • HC3


- in R all implemented in the estimatr package

InteRmezzo!

What Type of SE to use?

  • For moderately large sample sizes (hundreds and more), little difference between HC1-HC3
  • For very small samples (e.g. 30 observations), HC3 seems best

Why Don’t Use Robust SE All the Time?

Why Don’t Use Robust SE All the Time?

  • Many economists will tell you to do so. But!


  • For small samples, robust SE and tests based on them may be biased (especially, if homoscedasticity holds).
  • Robust SE are less efficient.
  • Violations of homoscedasticity may be sign of a missing predictor or misspecification.


  • In practice, robust SE are very useful (and very underutilized in sociology), but not a panacea.

Bonus: Clustered Standard Errors

Clustered Standard Errors

  • Linear regression assumes independece of errors.
  • Can be violated because of repeated measurments, cluster based sampling, etc.


  • Fortunately robust standard errors can help here (sometimes).
  • Clustered Standard error estimates residual variance for each cluster separately.