Courses › Graduate Econometrics
Panel data
Fixed effects, first differences and random effects, the Hausman test, correlated random effects, inference in panels, and dynamic panels with the Nickell bias and Arellano–Bond estimators.
Panel data follow the same units (people, cafés, firms, cities) over several periods. Their great advantage is that each unit can be compared with itself. Anything about a café that does not change over time, such as its location, its loyal regulars or the quality of its manager, can be removed from the comparison even though it is never measured.
The crash course introduced fixed and random effects. This module develops them properly: the unobserved-effects model and why pooled OLS fails, the within and first-difference transformations, random effects as GLS, the Hausman test and its correlated-random-effects version, inference with clustered errors, and dynamic panels with lagged outcomes, where fixed effects themselves become biased and GMM estimators take over.
By the end of this module you will be able to
- Write the unobserved-effects model and explain when pooled OLS is inconsistent.
- Compute fixed-effects and first-difference estimators and state the strict exogeneity assumption they need.
- Derive random effects as quasi-demeaned GLS and compare it with fixed effects using a Hausman or Mundlak test.
- Choose standard errors that allow for serial correlation within units.
- Explain the Nickell bias in dynamic panels and the Anderson–Hsiao and Arellano–Bond estimators.
What this module covers
- The unobserved-effects model
- Fixed effects and first differences
- Random effects and the Hausman test
- Inference in panels
- Dynamic panels
- Problem set with step-by-step solutions
- Module quiz
Lesson 10.1 Free lesson
The unobserved-effects model
Index units by i = 1, …, N and periods by t = 1, …, T. The basic model is
where αi is an unobserved effect (also called individual heterogeneity or a unit fixed effect) that is constant over time, and uit is the idiosyncratic error. If we simply stack all NT observations and run OLS (pooled OLS), the composite error is vit = αi + uit. Pooled OLS is consistent only if xit is uncorrelated with αi. In most applications it is not: cafés in busy neighbourhoods (high αi) also run more promotions; more able workers (high αi) choose more training.
Even when pooled OLS is consistent, its errors are correlated within units (every vit for café i shares αi), so standard errors must be clustered by unit (Module 5).
Worked example: Promotions and sales at three cafés
Three cafés are observed for two months. Promotions sent per week x and weekly sales y ($100s): café A (1, 10) then (3, 14); café B (2, 20) then (4, 23); café C (5, 31) then (5, 30). Café C is in a busy downtown spot.
Pooled OLS uses all six points: x̄ = 3.33, ȳ = 21.33, Σ(x − x̄)2 = 13.33 and Σ(x − x̄)(y − ȳ) = 62.33, so the slope is 4.68: each promotion appears to add $468 in sales.
But the busy café both runs the most promotions and sells the most for reasons unrelated to promotions. Lesson 2 removes the café effects and finds a much smaller slope.
Two transformations that remove αi
Because αi does not change over time, any transformation that subtracts something constant within a unit eliminates it. Two are standard: subtract the unit’s own time average (the within transformation), or subtract last period’s value (first differences). Both throw away the variation between units and keep only the variation within units over time.
Key ideas
- yit = xit′β + αi + uit; pooled OLS is inconsistent when x is correlated with αi.
- Within-unit comparisons remove every time-invariant characteristic, observed or not.
- Even when pooled OLS is consistent, cluster standard errors by unit.
Practice questions: Panel data
Try these, then open each answer to check your work.
- 1.Pooled OLS in the unobserved-effects model is inconsistent when
- the errors are heteroskedastic across units
- the number of periods T is large
- the regressors are correlated with the unit effect αi
- the model includes time dummies
Show answer
Answer: C. The composite error contains αi; correlation between x and αi makes pooled OLS inconsistent.
- 2.Fixed effects estimates the coefficient on x using
- only variation within units over time
- only variation between unit averages
- both within and between variation equally
- only the first period
Show answer
Answer: A. The within transformation removes unit averages, leaving only within-unit variation.
- 3.Which regressor’s coefficient cannot be estimated with unit fixed effects?
- Hours worked each month
- Monthly price
- Temperature that month
- A café’s fixed location
Show answer
Answer: D. Time-invariant variables are removed along with αi.
Problems with step-by-step solutions
- 4.For the three-café data, compute the first-difference estimator (no intercept) and compare it with FE.
Show step-by-step solution
- Δx: A 2, B 2, C 0. Δy: A 4, B 3, C −1.
- FD slope = ΣΔxΔy/ΣΔx2 = (8 + 6 + 0)/(4 + 4 + 0) = 1.75, identical to FE because T = 2.
- 5.Show that the within transformation removes any time-invariant regressor zi.
Show step-by-step solution
- zi − z̄i = zi − zi = 0 for every t.
- So its demeaned column is all zeros and its coefficient is not identified in FE.
Get the full module
The complete module adds every lesson, interactive graphs, a full problem set with step-by-step solutions, and a quiz. The academy opens in January 2027: join the waitlist for the founding price (lifetime access for $179).
Join the waitlist Try a full module free
More practice: free practice questions for this course.