ε

Panel Data: Fixed & Random Effects

Unobserved heterogeneity, pooled-OLS bias, the within estimator, FE vs RE.

Advanced · 4 modules · Free and browser-based

View the course outline

Course overview

Learn Panel Data: Fixed & Random Effects interactively

This free course uses real Python and statsmodels in your browser. Work through the modules below with explanations, executable examples, interactive controls, and questions.

1 · Panel data & unobserved heterogeneity

What panel data is, why repeated observations on the same entities help, and how an unobserved entity effect αᵢ creates correlation that biases naive regression.

2 · Pooled OLS and its bias

Pooled OLS ignores the panel structure and treats αᵢ as part of the error. We show, in code and with a slider, that this biases β₁ whenever αᵢ correlates with x.

3 · Fixed effects: within transformation & entity dummies

Fixed effects estimate β₁ from within-entity variation only, sweeping out αᵢ. We do it two equivalent ways — entity dummies and hand-coded demeaning — and confirm both kill the bias.

4 · Random effects & choosing FE vs RE

Random effects treats αᵢ as random noise uncorrelated with x, gaining efficiency and time-invariant coefficients — but only if that assumption holds. The Hausman idea tells you which to trust.