Search

Search papers and lessons

Fixed Effects Model

Level 3 · 12 min read

A fixed effects model gives each unit its own constant, then measures the effect of a change over time inside each unit, so anything fixed about the unit drops out.

On this page

  • Colour = topic mix
  • Discrete math
  • Probability
  • Calculus
  • Linear algebra
  • Methods
  • Econometrics
  • Sign in to see your progress

TL;DR

Suppose you follow the same workers, firms or countries over several years. Each one has traits that never change, such as its location or its culture, and these traits can distort a simple comparison across units. A fixed effects model gives each unit its own constant term to absorb those traits. It then estimates the effect from changes within each unit over time, so anything fixed about the unit drops out.

Where you'll see it: in labour economics (does a training programme raise the wages of the same workers?), in policy evaluation across regions, and in any study that tracks the same units repeatedly.

Intuition

Compare each unit with itself

Imagine two cities. City A is rich and has a new tram line. City B is poor and has none. A simple comparison of the two cities mixes up the tram with everything else that makes A rich. A better question is: in each city, did the rate of jobs change after its own tram opened? Each city becomes its own control. Things that stay the same in a city, such as its geography, cannot explain a change inside that city.

That is the idea of fixed effects. Each unit gets its own baseline, its "fixed effect", and the regression only uses how the unit moves away from that baseline.

Why it exists

Ordinary regression on panel data (see Panel Data) pools all the observations together, as if every row came from one unit (a "pooled" regression). If a trait that is unobserved, such as a firm's management quality, is both high for some firms and related to the treatment, the estimate is contaminated. This is the omitted variable bias problem. A trait that is constant within each unit can be removed by subtracting each unit's own average, so the bias from that trait disappears.

The picture below shows the logic. Each unit has its own line, and the lines are shifted by the unit's fixed trait. The fixed effect model removes the shifts and keeps only the slope inside each unit.

flowchart LR
  A["Raw data: units differ in level and in slope"] --> B["Subtract each unit's own average"]
  B --> C["Only within-unit changes remain"]
  C --> D["Regress demeaned outcome on demeaned treatment"]
  D --> E["Slope = effect of treatment inside units"]

The math

Let ii index units (such as workers) and tt index periods (such as years). Let yity_{it} be the outcome, xitx_{it} the treatment or regressor, and εit\varepsilon_{it} the remaining error. The fixed effects model is

yit=αi+β xit+εit.y_{it} = \alpha_i + \beta\, x_{it} + \varepsilon_{it}.

Here αi\alpha_i is the fixed effect of unit ii: a constant that captures everything about the unit that does not change over time. The coefficient β\beta is the effect of a one-unit change in xx on yy, and it is the quantity we want.

Averaging over time within unit ii, with TT periods and yˉi=1T∑tyit\bar{y}_i = \frac{1}{T}\sum_t y_{it}, gives

yˉi=αi+β xˉi+εˉi.\bar{y}_i = \alpha_i + \beta\, \bar{x}_i + \bar{\varepsilon}_i.

Subtracting this from the original equation removes αi\alpha_i:

yit−yˉi=β (xit−xˉi)+(εit−εˉi).y_{it} - \bar{y}_i = \beta\,(x_{it} - \bar{x}_i) + (\varepsilon_{it} - \bar{\varepsilon}_i).

This is the within transformation. The estimator of β\beta is then the ordinary least-squares slope (the line that minimises the sum of squared vertical gaps, see Linear Regression) through the demeaned data:

β^FE=∑i∑t(xit−xˉi)(yit−yˉi)∑i∑t(xit−xˉi)2.\hat{\beta}_{\text{FE}} = \frac{\sum_{i}\sum_{t} (x_{it} - \bar{x}_i)(y_{it} - \bar{y}_i)}{\sum_{i}\sum_{t} (x_{it} - \bar{x}_i)^2}.

What the assumption means

The estimator is consistent (it homes in on the true β\beta as the number of units grows) when the error is uncorrelated with the regressor within each unit, once the fixed effect is removed. Written in words: after accounting for each unit's own baseline, the treatment should not move with the unobserved shocks in the same period. This is weaker than assuming the unit traits are unrelated to the treatment, which is exactly what fixed effects is designed to allow.

What is lost

Any variable that never changes within a unit has xit−xˉi=0x_{it} - \bar{x}_i = 0. Its coefficient cannot be estimated, because it has been absorbed into αi\alpha_i. A worker's sex or a city's latitude cannot be estimated with unit fixed effects. The model only uses changes.

Worked examples

Example
Example 1: tiny, one unit with two periods

Take one unit observed twice, with y=(3,5)y = (3, 5) and x=(1,2)x = (1, 2).

  1. Average within the unit: yˉ=4\bar{y} = 4 and xˉ=1.5\bar{x} = 1.5.
  2. Demean: y−yˉ=(−1,1)y - \bar{y} = (-1, 1) and x−xˉ=(−0.5,0.5)x - \bar{x} = (-0.5, 0.5).
  3. Slope through the origin: β^=(−0.5)(−1)+(0.5)(1)(−0.5)2+(0.5)2=10.5=2\hat{\beta} = \frac{(-0.5)(-1) + (0.5)(1)}{(-0.5)^2 + (0.5)^2} = \frac{1}{0.5} = 2.

Interpretation: inside this unit, each extra unit of xx goes with an extra 2 units of yy. The intercept α=4−2×1.5=1\alpha = 4 - 2 \times 1.5 = 1 is absorbed and never needs to be estimated directly.

Example
Example 2: the textbook case, two units with different baselines

Two units, each observed at two dates. Unit A has αA=1\alpha_A = 1, and unit B has αB=4\alpha_B = 4. In both, the true effect is β=2\beta = 2, with no noise. The data are:

  • Unit A: x=(1,2)x = (1, 2), y=(3,5)y = (3, 5).
  • Unit B: x=(1,3)x = (1, 3), y=(6,10)y = (6, 10).

Within-unit demeaning:

  1. Unit A: xˉ=1.5\bar{x} = 1.5, yˉ=4\bar{y} = 4, so x~=(−0.5,0.5)\tilde{x} = (-0.5, 0.5) and y~=(−1,1)\tilde{y} = (-1, 1).
  2. Unit B: xˉ=2\bar{x} = 2, yˉ=8\bar{y} = 8, so x~=(−1,1)\tilde{x} = (-1, 1) and y~=(−2,2)\tilde{y} = (-2, 2).
  3. Numerator: (−0.5)(−1)+(0.5)(1)+(−1)(−2)+(1)(2)=0.5+0.5+2+2=5(-0.5)(-1) + (0.5)(1) + (-1)(-2) + (1)(2) = 0.5 + 0.5 + 2 + 2 = 5.
  4. Denominator: 0.25+0.25+1+1=2.50.25 + 0.25 + 1 + 1 = 2.5.
  5. β^FE=5/2.5=2\hat{\beta}_{\text{FE}} = 5 / 2.5 = 2.

Interpretation: the fixed effects estimator recovers the true effect exactly, even though the units have very different baselines.

Now compare with a pooled regression that ignores the units. Pooling gives xˉ=1.75\bar{x} = 1.75 and yˉ=6\bar{y} = 6 across all four points. The deviations of xx from 1.75 are (−0.75,0.25,−0.75,1.25)(-0.75, 0.25, -0.75, 1.25) and those of yy from 6 are (−3,−1,0,4)(-3, -1, 0, 4). The cross-product sum is 2.25−0.25+0+5=72.25 - 0.25 + 0 + 5 = 7 and the sum of squared xx deviations is 0.5625+0.0625+0.5625+1.5625=2.750.5625 + 0.0625 + 0.5625 + 1.5625 = 2.75, so β^pooled=7/2.75≈2.55\hat{\beta}_{\text{pooled}} = 7 / 2.75 \approx 2.55. Unit B has both a higher baseline and higher xx, and pooling mixes that into the slope, giving 2.55 instead of 2. The fixed effects estimate removes this and returns 2.

Example
Example 3: realistic, a training programme and wages

A study follows 500 workers for 6 years. Some workers enrol in a training course in year 3. The outcome is log wages. Pooled regression shows that trained workers earn more. But trained workers may be more motivated, and motivation is a fixed trait that also raises wages.

With worker fixed effects, the model compares each worker's wage before and after the course. Suppose the estimate is β^FE=0.04\hat{\beta}_{\text{FE}} = 0.04. Read as a rough approximation for small changes, this says that completing the course is associated with about 4 percent higher wages for the same worker, after accounting for stable traits such as motivation.

Caveats: a pay rise that happened at the same time as enrolment would also be picked up, so the estimate is credible only if nothing else changed for the same workers in those years. The study cannot say anything about the effect of a fixed trait such as education completed before the panel began.

Tradeoffs and failure modes

SituationWhat goes wrongBetter choice
The key regressor barely changes within unitsLittle variation remains, so the estimate is impreciseLonger panels, or a design with larger within-unit changes
You need the effect of a time-invariant traitIt is absorbed into the fixed effect and cannot be estimatedRandom effects, which make a different assumption, or a between-unit comparison
Other shocks hit the same units at the same timeThey are not removed by a unit constantAdd time effects (a constant for each year, shared by all units), or a difference-in-differences design (compare the change in treated units with the change in untreated units)
The treatment is caused by something that changes within unitsThe fixed effect does not solve a time-varying confounder (see Confounding Bias)An [[instrumental-variables
Measurement error in xxDemeaning can amplify the error in the changesCareful measurement, or instruments

A common trap is reading the fixed effects coefficient as a causal effect when the error is still correlated with a time-varying cause. Fixed effects is a strong tool, not a cure for all confounding. The Causal Inference question still has to be answered by the design.

Random effects is the usual alternative. It treats αi\alpha_i as a random draw and uses both within and between variation, so it is more efficient when its assumption holds. It fails when the unit traits are correlated with the regressors, which is exactly the case fixed effects was built for. Choosing between them is a question of which assumption you are more willing to defend.

History

The use of unit-specific constants in combined time-series and cross-section data came into econometrics in the 1950s and 1960s, as researchers began pooling data from many firms, households or countries. The within transformation, which subtracts each unit's average, is the computational heart of the method.

The relationship between fixed effects and random effects was set out more clearly in the 1970s and 1980s. Yair Mundlak's 1978 paper on pooling time-series and cross-section data showed that the two approaches can be written in one framework, which made the choice between them easier to reason about. Fixed effects became standard in applied economics through the 1990s and 2000s, especially for evaluating policies using repeated data on the same units.

Recap

  • Each unit gets a constant αi\alpha_i that absorbs everything about it that does not change.
  • Subtracting each unit's average (the within transformation) removes the constant and leaves only within-unit changes.
  • The slope through those changes is the fixed effects estimate of β\beta, and it is protected from bias by fixed unit traits, though not from time-varying confounders.

This sets up other Panel Data methods, such as difference-in-differences, where the same comparison of units over time is combined with a policy change.

Check yourself

QuestionRecall: what does the fixed effect αi\alpha_i represent?Show answer

It is a constant for unit ii that captures everything about the unit that stays the same over time, such as its location or its underlying culture. Because it is constant, the model removes it by comparing each unit with its own average.

QuestionComputation: one unit has y=(2,6)y = (2, 6) and x=(1,3)x = (1, 3). Find β^FE\hat{\beta}_{\text{FE}} for this single unit.Show answer

Averages are yˉ=4\bar{y} = 4 and xˉ=2\bar{x} = 2. Demeaned values are y~=(−2,2)\tilde{y} = (-2, 2) and x~=(−1,1)\tilde{x} = (-1, 1). The numerator is (−1)(−2)+(1)(2)=4(-1)(-2) + (1)(2) = 4. The denominator is 1+1=21 + 1 = 2. So β^=4/2=2\hat{\beta} = 4/2 = 2.

QuestionWhy: explain why a pooled regression can give a different slope from the fixed effects estimate when units have different baselines.Show answer

Pooling treats all observations as if they shared one baseline. If units with higher baselines also have higher values of xx, the pooled slope picks up that difference between units, not just the effect of xx within a unit. Fixed effects removes the baseline differences, so only within-unit changes drive the slope.

QuestionApplied: a study estimates a fixed effects coefficient on a worker's education level, which does not change over the panel. What happens?Show answer

The coefficient cannot be estimated. Education is constant within each worker, so its demeaned value is zero for every observation. It is absorbed into the worker's fixed effect. To study education, the analyst needs a different design, such as a between-worker comparison or a random effects model, each with its own assumptions.

Sources