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.
The model, one symbol at a time
Let index the unit — a company, a trader, a country — and index time. Let ("y sub i t") be the outcome for unit at time : a stock return, say. Let be the variable you care about, like leverage. The panel regression is
In words: the outcome for unit at time equals a slope ("beta") times the variable of interest, plus ("alpha sub i"), a number specific to unit that never changes over time, plus leftover noise ("epsilon"). That is the fixed effect — it soaks up everything permanent about unit : industry, management culture, geography, anything that doesn't move over the sample.
You cannot estimate and directly with an ordinary regression when is correlated with — 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:
In words: replace every observation with its deviation from that unit's own average, then run an ordinary regression on the deviations. Because is constant within unit , it appears in and identically and cancels exactly — it never enters the equation you actually estimate. You never even have to know what 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 and return (in percent):
| Firm | Year | ||
|---|---|---|---|
| A | 1 | 2.0 | 8 |
| A | 2 | 3.0 | 6 |
| A | 3 | 4.0 | 4 |
| B | 1 | 5.0 | 12 |
| B | 2 | 6.0 | 10 |
| B | 3 | 7.0 | 8 |
Firm A's averages: , . Firm B's averages: , .
Demeaned data:
| Firm | Year | ||
|---|---|---|---|
| A | 1 | ||
| A | 2 | ||
| A | 3 | ||
| B | 1 | ||
| B | 2 | ||
| B | 3 |
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: .
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 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 (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 : 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.
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 .
- 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 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 — 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