Logo SQL Growth

What Are Fixed Effects

by DataMarvin
13 hours ago
Views: 10
Illustrative Image

If you've read about Difference-in-Differences or TWFE models, you've probably seen the term "fixed effects" without a clear explanation of what it actually does. This post explains the intuition from scratch — with a concrete example that has nothing to do with color queries.


1. The Core Problem: Confounding You Can't Randomize Away

Imagine you're an analyst at a coffee chain. You want to know whether adding a loyalty program increases average spend per visit. You roll it out to 50 stores and leave another 50 stores as controls.

Simple comparison: loyalty stores average 8.20pervisit,controlstoresaverage8.20 per visit, control stores average 7.40. Looks like a $0.80 lift. But wait.

The 50 stores that got the loyalty program happen to be in higher-income neighborhoods. Customers there probably spend more regardless of the loyalty program. Your $0.80 estimate isn't the effect of loyalty — it's partly the effect of neighborhood.

This is the classic confounding problem. The stores in your treatment group are systematically different from controls in ways that affect your outcome.


2. Fixed Effects: Absorbing What Doesn't Change

Here's the key insight: if you observe the same stores over time — before and after the loyalty program launched — you can use each store as its own control.

The idea is:

Use within-unit variation. Ignore between-unit differences.

A store in a wealthy neighborhood will always have higher baseline spend. But if we track how that store's spend changed after the loyalty program launched, the neighborhood effect cancels out — it's the same neighborhood before and after.

This is what a unit fixed effect does. It absorbs everything about a unit that is constant over time — location, customer demographics, store size, management style — and focuses your estimate on changes within that unit.

Mathematically, including a store fixed effect α_i is equivalent to subtracting each store's time-averaged outcome from the data. You're left with variation that can't be explained by the store's baseline level.


3. Time Fixed Effects: Absorbing What Everyone Experiences Together

Now suppose the loyalty program launched in January — the same month a cold snap hit the whole country, and people started going to coffee shops more often. Spend went up at every store, not just the treated ones.

If you don't account for this, you'll mistakenly credit the loyalty program for a seasonal lift.

A time fixed effect α_t absorbs events that affect all units in the same period — economic conditions, seasons, national promotions, platform-wide algorithm changes. By including it, you're asking: "did treated stores improve more than the overall trend?"


4. Two-Way Fixed Effects: Combining Both

A Two-Way Fixed Effects (TWFE) model includes both unit and time fixed effects simultaneously:

Y_it = α_i + α_t + β · Treat_it + ε_it

  • α_i — controls for everything stable about each unit (store, user, product)
  • α_t — controls for everything that shifts all units at the same time
  • β — the treatment effect estimate, after removing both sources of confounding

Back to the coffee chain: after including store fixed effects (removes baseline differences between stores) and time fixed effects (removes the January cold snap), your estimate of the loyalty program's effect is now cleaner. β captures within-store changes that aren't explained by the overall time trend.


5. The Two-Step Subtraction

Think of it as a two-step subtraction:

Raw outcome − store's average level across time (unit FE) − period's average level across stores (time FE) = residual variation

β is estimated from this residual. Everything that's explainable by "which store it is" or "which time period it is" has already been removed.


6. What Fixed Effects Cannot Do

Fixed effects are powerful, but they have clear limits.

They don't control for time-varying confounders. If wealthier-neighborhood stores also started running their own local promotions at the same time as the loyalty rollout — that's a confound that changes over time, and fixed effects won't absorb it.

They don't solve staggered treatment timing. If the loyalty program rolled out to different stores at different times — this triggers a more subtle problem (covered in the TWFE + staggered adoption post). Standard TWFE can produce biased estimates when treatment timing varies and effects are heterogeneous.

They don't replace randomization. Fixed effects reduce bias from stable unobserved differences. They can't account for selection into treatment that's driven by time-varying factors.


7. When Should You Use Fixed Effects?

Fixed effects are most useful when:

  • You have panel data — the same units observed at multiple points in time
  • You suspect unobserved, stable differences between units are correlated with treatment
  • You can't randomize — you're working with observational data

They're less useful (or actively misleading) when:

  • Treatment assignment is time-varying and heterogeneous across units
  • Your panel is very short — only 2 time periods limits the variation available for estimation
  • The variation you care about is between units, not within units (fixed effects remove between-unit variation by design)

Takeaway

Fixed effects don't add information — they remove noise. By absorbing stable unit-level differences and common time trends, they let your treatment effect estimate focus on the variation that actually matters.

One sentence summary:

Unit fixed effects say "compare each unit to itself over time." Time fixed effects say "compare relative to what everyone else was doing." Together, they isolate the effect of your treatment from most observational confounds.

More

Based on Tags

Recent Popular

Most Popular

  • Why You Shouldn't Peek at Your A/B Test Results

    An Introduction t Sequential AB Testing

    Illustrative Image
  • Stratified Sampling in A/B Testing

    Why Random Isn't Always Enough

    Illustrative Image
  • What Is CUPED

    and Why It Makes Your Experiments Faster

    Illustrative Image