0/70 completed
Econometrics Interactive

Panel Data Analysis

Analyze data with multiple entities observed over time. Control for unobserved heterogeneity using fixed and random effects.

๐Ÿ“Š Panel Data Structure

Panel data = same entities tracked over multiple time periods. Combines cross-sectional and time-series dimensions.

Advantages

  • โ€ข Control for unobserved individual effects
  • โ€ข More observations = more power
  • โ€ข Study dynamics over time
  • โ€ข Reduce omitted variable bias
PlayerS1S2S3
Player 19.66.911.0
Player 231.528.934.3
Player 328.732.230.8

Panel Parameters

Number of Players 5
3 10
Number of Seasons 4
2 8
Player Effect (ฯƒ) 10
0 20
Time Trend 2
0 5

๐Ÿ“Š Panel Dimensions

N (players) 5
T (periods) 4
Total Obs (Nร—T) 20

Player Trajectories

Each line = one player. Parallel upward trend = time effect. Vertical spread = player fixed effects.

Fixed Effects Intuition

Within Variation

Compare each player to their own average. Removes time-invariant differences.

"How does this player's performance change when X changes?"

Between Variation

Compare averages across players. Confounded by unobserved differences.

"High scorers may just be better, not more skilled at X"

๐Ÿ“ˆ Model Comparison

Pooled OLS

Ignores panel structure

โš ๏ธ Omitted variable bias

โœ“ Simple baseline

Fixed Effects

Controls for time-invariant individual effects

โš ๏ธ Can't estimate time-invariant vars

โœ“ Most common for causal inference

Random Effects

Assumes individual effects uncorrelated with X

โš ๏ธ Biased if assumption violated

โœ“ More efficient if valid

R Code Equivalent

# Panel data analysis with plm
library(plm)

# Convert to panel data frame
pdata <- pdata.frame(df, index = c("player_id", "season"))

# Pooled OLS (ignores panel structure)
pooled <- plm(pts ~ usage + matchup, data = pdata, model = "pooling")

# Fixed Effects (within estimator)
fe_model <- plm(pts ~ usage + matchup, data = pdata, model = "within")

# Random Effects
re_model <- plm(pts ~ usage + matchup, data = pdata, model = "random")

# Hausman test: FE vs RE
phtest(fe_model, re_model)  # p < 0.05 โ†’ use FE

# Two-way fixed effects (player + time)
twoway_fe <- plm(pts ~ usage + matchup, data = pdata, 
                 model = "within", effect = "twoways")

โœ… Key Takeaways

  • โ€ข Panel = entities ร— time periods
  • โ€ข Fixed effects control for unobserved heterogeneity
  • โ€ข Uses "within" variation (each entity vs itself)
  • โ€ข Hausman test: FE vs RE
  • โ€ข Can add time fixed effects too
  • โ€ข More power than cross-section or time series alone

Pricing Models & Frameworks Tutorial

Built for mastery ยท Interactive learning