The full academy launches January 2027. Join the waitlist for the $179 founding price.
Waldbauer Academy of Economics

Courses › Graduate Econometrics

Graduate · Module 10 of 15

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.

By Maximus S. Waldbauer · About 6 hours, including the problem set and quiz.

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

What this module covers

  1. The unobserved-effects model
  2. Fixed effects and first differences
  3. Random effects and the Hausman test
  4. Inference in panels
  5. Dynamic panels
  6. Problem set with step-by-step solutions
  7. 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

yit = xit′β + αi + uit

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. 1.Pooled OLS in the unobserved-effects model is inconsistent when
    1. the errors are heteroskedastic across units
    2. the number of periods T is large
    3. the regressors are correlated with the unit effect αi
    4. the model includes time dummies
    Show answer

    Answer: C. The composite error contains αi; correlation between x and αi makes pooled OLS inconsistent.

  2. 2.Fixed effects estimates the coefficient on x using
    1. only variation within units over time
    2. only variation between unit averages
    3. both within and between variation equally
    4. only the first period
    Show answer

    Answer: A. The within transformation removes unit averages, leaving only within-unit variation.

  3. 3.Which regressor’s coefficient cannot be estimated with unit fixed effects?
    1. Hours worked each month
    2. Monthly price
    3. Temperature that month
    4. A café’s fixed location
    Show answer

    Answer: D. Time-invariant variables are removed along with αi.

Problems with step-by-step solutions

  1. 4.For the three-café data, compute the first-difference estimator (no intercept) and compare it with FE.
    Show step-by-step solution
    1. Δx: A 2, B 2, C 0. Δy: A 4, B 3, C −1.
    2. FD slope = ΣΔxΔy/ΣΔx2 = (8 + 6 + 0)/(4 + 4 + 0) = 1.75, identical to FE because T = 2.
  2. 5.Show that the within transformation removes any time-invariant regressor zi.
    Show step-by-step solution
    1. zi − z̄i = zi − zi = 0 for every t.
    2. 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.