Robust standard errors, and when they are not enough
Today let's understand robust standard errors clearly: when a regression's own standard error can be trusted, and when it cannot.
A retail chain tracks weekly online ad spend and weekly sales across its 50 stores. Ad spend is in hundreds of dollars, sales in thousands. Look at how far sales scatter from the trend as ad spend rises.
The scatter fans out. Stores spending a little sit close to the trend line, but stores spending a lot land far above it or far below it. That widening fan is what this lesson is about.
Unequal spread, not unequal effect
The pattern in that scatter has a name. When the spread of the outcome around its trend changes across a predictor's range, statisticians call it heteroskedasticity: hetero for unequal, skedasticity for spread. When the spread stays about the same everywhere, that is homoskedasticity.
Build the 50 stores and look at the numbers directly.
The true effect, 0.15, is the number sitting right there in 10 + 0.15 * ad_spend: every extra hundred dollars of ad spend adds 0.15 thousand dollars to sales, on average. Because this is simulated data, you get to know that truth exactly, instead of having to guess at it.
Ad spend itself is right-skewed: most stores spend modestly, and a few spend heavily, up near 25. Now fit the trend, and compare how far sales scatter from it when ad spend is low against when it is high.
Among the 25 stores spending the least, sales scatter around the trend with a standard deviation of 2.17. Among the 25 spending the most, that scatter widens to 5.66, about 2.6 times as much. The upward trend itself is not in question here. What is in question is how far you can trust the standard error attached to it.