Fixed Effects (the Within Estimator)
A panel model is , where is a fixed, unobserved trait of entity (a firm, a person, a country). Fixed effects applies the within transformation: it subtracts each variable's entity mean over time, , which wipes out the time-invariant entirely. So FE stays consistent even when , the exact case that breaks pooled OLS, as long as strict exogeneity of holds. The cost: because demeaning removes anything constant over time, FE cannot estimate the coefficient on any time-invariant regressor (gender, industry, a firm's founding decade). In Stata: `xtset id year` then `xtreg y x, fe`.
Watch the lesson
Open full lesson page →Why it matters
Picture one fitted line drawn through three different firms. A pooled fit ignores who each firm is and lets persistent firm traits leak into the slope. Fixed effects instead gives each entity its own intercept, so identification comes only from how a firm moves relative to its own average over time, not from comparing one firm to another. That within-firm focus is exactly what neutralises stable confounders such as management quality or culture. But it cuts both ways. Anything that never changes for a firm has no within variation left to explain , so its effect simply cannot be recovered. Add time effects for shocks common to all entities in a year, giving two-way FE.
Formulas
Worked examples
Estimate how leverage and firm size relate to return on assets, controlling for all stable firm differences.
Declare the panel with `xtset id year`, then run `xtreg roa lev size, fe vce(cluster id)`. The slopes on `lev` and `size` are now identified purely from within-firm changes over time, so any time-invariant trait (industry, headquarters country, founder) is differenced away rather than biasing the estimates. The `vce(cluster id)` option makes the standard errors robust to serial correlation within each firm.
Try to include a time-invariant industry dummy in the fixed effects model.
Running `xtreg roa lev size i.industry, fe` makes Stata silently omit the industry dummies and report them as dropped, because `industry` never changes within a firm and so has zero within variation. The within transformation has already removed everything constant over time, industry included. To learn the effect of a stable trait you must use a different estimator such as random effects (`xtreg ..., re`) or report group means separately.
Common mistakes
- ✗Believing fixed effects can estimate the coefficient on a time-invariant regressor. It cannot. The within transformation removes everything constant over time, so gender, industry, or founding year are swept out along with and reported as omitted.
- ✗Thinking fixed effects fixes every kind of endogeneity. It only removes bias from the time-invariant . Strict exogeneity of is still required, so simultaneity, measurement error, or a time-varying omitted variable will still bias the estimates.
- ✗Assuming pooled OLS and fixed effects should give similar slopes. They diverge precisely when , which is the usual reason to prefer FE. A large gap is informative, not a red flag.
- ✗Forgetting to cluster standard errors. Default `xtreg, fe` errors assume no serial correlation, which is rarely true in panels. Use `vce(cluster id)` so inference is valid when a firm's shocks persist across years.
Revision bullets
- •FE applies the within transformation: demean each variable by its entity mean to cancel .
- •Consistent even when , as long as is strictly exogenous.
- •It cannot estimate coefficients on time-invariant regressors, they have no within variation.
- •Two-way FE adds for common time shocks via `xtreg y x i.year, fe`.
- •With , fixed effects and first differencing give identical estimates.
- •Always pair with clustered SEs: `xtset id year` then `xtreg y x, fe vce(cluster id)`.
Quick check
Why is the fixed effects (within) estimator consistent when the unobserved effect is correlated with the regressors?
You run `xtreg wage educ tenure i.gender, fe` on worker-year panel data. What happens to the `gender` coefficient?
Connected topics
Sources
- Wooldridge (2019), §14.1Wooldridge, Jeffrey M. Introductory Econometrics: A Modern Approach. 7th ed. Cengage, 2019.Develops the unobserved effects model, the within transformation, and why fixed effects allows arbitrary correlation between and the regressors under strict exogeneity.
- Wooldridge (2019), §14.2Wooldridge, Jeffrey M. Introductory Econometrics: A Modern Approach. 7th ed. Cengage, 2019.Covers the inability of fixed effects to identify time-invariant regressors, the dummy variable regression equivalence, and two-way fixed effects with time dummies.