Quant Memo
Advanced

Panel Data and Fixed Effects

A way to strip out everything permanent and unobservable about each stock, trader, or country before you estimate the relationship you actually care about — by comparing each unit only to its own history.

Prerequisites: The Classical Linear Regression Assumptions, Endogeneity and Instrumental Variables

Say you want to know whether a company's leverage affects its stock return. You have ten years of data on five hundred companies and you run a regression of returns on leverage. The coefficient comes back significant. Have you learned anything? Maybe — or maybe you've just rediscovered that some industries are permanently more leveraged and permanently riskier for reasons that have nothing to do with leverage itself: capital intensity, regulation, the kind of investor who buys them. If that hidden "industry character" is correlated with both leverage and returns, your coefficient is contaminated by it, and no amount of adding more companies fixes the problem. Panel data — data with a time dimension and a cross-sectional dimension, like many stocks over many years — gives you a tool this cross-section-only regression doesn't have: you can compare a company to itself over time, which cancels out anything about that company that never changes.

An analogy: judging a diet, not a body type

Suppose you want to know whether a diet lowers weight, and your data is one weight measurement from each of a thousand strangers, half on the diet, half not. Tall, naturally heavy-boned people might disproportionately end up on the diet (maybe doctors push it harder on them), which would bias your before/after comparison even with no true effect. But if instead you weigh the same thousand people before and after they start the diet, every person serves as their own control. Their bone structure, height, genetics — anything permanent about them — cancels out automatically, because you're only looking at the change within each person. Fixed effects are exactly this trick, generalized to any repeated-measurement dataset: instead of comparing units to each other, you compare each unit to its own average and work with the deviations.

time return firm A firm B firm C Each firm bounces around its OWN level — fixed effects remove the level, keep the bounce
Three firms sit at three permanently different return levels (their fixed effects). A pooled regression would blame those level differences on whatever variable happens to differ across firms too. A fixed-effects regression subtracts each firm's own average first, leaving only the wiggle within each firm to explain.

The model, one symbol at a time

Let ii index the unit — a company, a trader, a country — and tt index time. Let yity_{it} ("y sub i t") be the outcome for unit ii at time tt: a stock return, say. Let xitx_{it} be the variable you care about, like leverage. The panel regression is

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

In words: the outcome for unit ii at time tt equals a slope β\beta ("beta") times the variable of interest, plus αi\alpha_i ("alpha sub i"), a number specific to unit ii that never changes over time, plus leftover noise εit\varepsilon_{it} ("epsilon"). That αi\alpha_i is the fixed effect — it soaks up everything permanent about unit ii: industry, management culture, geography, anything that doesn't move over the sample.

You cannot estimate αi\alpha_i and β\beta directly with an ordinary regression when αi\alpha_i is correlated with xitx_{it} — that correlation is exactly the contamination from the leverage example. The fix, called the within transformation, is to subtract each unit's own time-average from every variable:

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

In words: replace every observation with its deviation from that unit's own average, then run an ordinary regression on the deviations. Because αi\alpha_i is constant within unit ii, it appears in yˉi\bar y_i and xˉi\bar x_i identically and cancels exactly — it never enters the equation you actually estimate. You never even have to know what αi\alpha_i is; you just have to know it's constant.

Fixed effects control for anything about a unit that is constant over the sample period, by comparing each unit only to its own history. They do nothing for a confound that changes over time along with your variable of interest.

Worked example 1: the within transformation by hand

Three years of data for two firms, leverage xx and return yy (in percent):

FirmYearxxyy
A12.08
A23.06
A34.04
B15.012
B26.010
B37.08

Firm A's averages: xˉA=3.0\bar x_A = 3.0, yˉA=6.0\bar y_A = 6.0. Firm B's averages: xˉB=6.0\bar x_B = 6.0, yˉB=10.0\bar y_B = 10.0.

Demeaned data:

FirmYearxxˉx - \bar xyyˉy - \bar y
A11.0-1.022
A20.00.000
A31.01.02-2
B11.0-1.022
B20.00.000
B31.01.02-2

Notice the level difference between A and B — B has both higher leverage and higher returns on average — has completely vanished. Only the within-firm wiggle survives. A simple OLS slope on the demeaned pairs: β^=(xxˉ)(yyˉ)/(xxˉ)2=[(1)(2)+0+(1)(2)+(1)(2)+0+(1)(2)]/[1+0+1+1+0+1]=8/4=2.0\hat\beta = \sum(x-\bar x)(y-\bar y) / \sum (x - \bar x)^2 = [(-1)(2)+0+(1)(-2)+(-1)(2)+0+(1)(-2)] / [1+0+1+1+0+1] = -8/4 = -2.0.

A pooled regression ignoring firm identity would find leverage and returns move together across firms (B is higher on both), giving a positive slope — the opposite sign, purely because permanently-different firms differ on both axes. The fixed-effects slope of 2.0-2.0 says: within a given firm, as leverage rises one unit, its return falls two points. That is the causal-flavored number you wanted.

Worked example 2: a real magnitude — hedge fund alpha

You track 100 hedge funds over 8 years, regressing monthly excess return on a "size of AUM inflow that month" variable, wanting to know if inflows predict lower forward returns (capacity constraints). Pooled OLS gives β^=0.15\hat\beta = -0.15 (in percent per $100M inflow) but funds that are permanently skilled attract permanently larger inflows and have permanently higher returns — a fixed omitted variable pulling the coefficient toward zero or flipping its sign. After demeaning within each fund (fixed effects), the estimate moves to β^=0.42\hat\beta = -0.42: a much larger, and now believable, capacity-constraint effect, because the "some funds are just better" story has been subtracted out fund by fund. This is the single most common panel-data pattern in finance research: pooled and fixed-effects estimates disagree, and the disagreement itself is diagnostic of a permanent confound.

Regression explorer
amber = residuals
fitted slope 1.133true slope 1.00 0.642SSres 42.0

Drag points around in the explorer above and watch the fitted slope move — now imagine running that same fit twice, once on raw levels and once after subtracting each group's own mean, and compare how differently the line tilts.

What this means in practice

  • Firm and time fixed effects together. Most finance panels add time fixed effects too (a dummy per year), which absorbs anything common to every unit in a given period — a market crash, a rate hike — leaving only firm-and-year-specific variation to identify β\beta.
  • Clustered standard errors are mandatory. Residuals within the same firm over time are almost always correlated (autocorrelation), so standard OLS standard errors are too small. Cluster them by firm, or the fixed-effects estimate will look far more precise than it is.
  • Fixed effects don't work on things that don't vary. If your variable of interest — say, a country's exchange-rate regime — is essentially constant for a given unit across the whole sample, the within transformation destroys nearly all its variation and β\beta becomes very noisy.
  • This is why panel data is prized in empirical asset pricing: it's a cheap, assumption-light way to knock out the biggest class of omitted-variable bias (permanent unit-level differences) without needing a randomized experiment.

The classic confusion: fixed effects remove confounds that are constant over time for a given unit, not confounds in general. If the omitted variable itself changes over time and moves together with xitx_{it} — say, a firm's leverage and its risk appetite trend up together over the sample — the within transformation does nothing to it, because it doesn't cancel in the demeaning step. People see "fixed effects" and treat the result as automatically causal; it only handles the time-invariant half of the confounding problem. The time-varying half needs a different tool, like an instrument or a natural experiment.

Related concepts

Practice in interviews

Further reading

  • Wooldridge, Econometric Analysis of Cross Section and Panel Data, ch. 10
  • Angrist & Pischke, Mostly Harmless Econometrics, ch. 5
ShareTwitterLinkedIn