Panel econometrics baseline suite¶
The baseline panel module establishes the comparison models used before more specialised causal designs such as Difference-in-Differences, instrumental variables, or synthetic control.
The implementation exposes a common PanelEstimate summary so downstream
analyses do not depend on model-specific result internals.
Models¶
Pooled OLS¶
Pooled OLS treats the panel as a stacked regression:
[ Y_{it} = alpha + D_{it} au + X_{it}'eta + arepsilon_{it}. ]
A treatment coefficient is causal only if the included adjustment set is sufficient for the relevant exchangeability/exogeneity condition. Panel structure alone does not make pooled OLS causal.
In the canonical DGP, policy assignment is related to both observed and latent regional characteristics. Consequently, pooled OLS can be biased even after adjusting for the observed regional covariate.
Entity fixed effects¶
Entity fixed effects estimate
[ Y_{it} = alpha_i + D_{it} au + X_{it}'eta + arepsilon_{it}. ]
The unit intercept (alpha_i) absorbs all time-invariant regional factors, including unobserved ones.
This is useful in the canonical DGP because the latent demand factor is time-invariant. It does not solve time-varying unmeasured confounding.
Time fixed effects¶
Time fixed effects add a common intercept for each period:
[ Y_{it} = gamma_t + D_{it} au + X_{it}'eta + arepsilon_{it}. ]
They absorb shocks shared by all regions in the same period, including the common trend, seasonality when common across units, and period-specific shocks.
Two-way fixed effects¶
Two-way FE combines both:
[ Y_{it} = alpha_i + gamma_t + D_{it} au + arepsilon_{it}. ]
For the constant-effect version of the canonical DGP, this specification removes the time-invariant regional confounding and common time shocks by construction.
That controlled example is deliberately simpler than modern staggered-adoption DiD settings with heterogeneous effects. Later modules will treat those cases explicitly rather than presenting TWFE as universally valid.
Random effects¶
Random effects model unit heterogeneity as a random component rather than a set of unrestricted unit intercepts.
Its efficiency advantage depends on an additional orthogonality assumption: the unit-specific effect must be uncorrelated with the included regressors. When treatment selection is related to persistent latent regional factors, that assumption can fail.
Covariance estimators¶
All wrappers support:
unadjusted: model-based homoskedastic covariance;robust: heteroskedasticity-robust covariance;clustered: clustering by entity, time, or both.
Panel analyses should not default mechanically to independent-observation standard errors. Repeated observations from the same region naturally create within-region dependence.
The repository defaults entity fixed-effects models to entity-clustered uncertainty.
Hausman comparison¶
The classical Hausman comparison evaluates the difference between FE and RE coefficient vectors:
[ H = (hateta_{FE}-hateta_{RE})' left[ operatorname{Var}(hateta_{FE}) - operatorname{Var}(hateta_{RE})
ight]^{-1} (hateta_{FE}-hateta_{RE}). ]
Under the classical null, both estimators are consistent and RE is efficient. A systematic coefficient difference is evidence against the RE orthogonality assumption.
The implementation uses a pseudo-inverse because finite-sample covariance differences can be singular. The diagnostic should be interpreted together with the substantive assignment mechanism, not as an automatic model-selection button.
Omitted-variable-bias experiment¶
omitted_variable_bias_demo fits three models to the canonical DGP:
- naive pooled OLS using treatment plus time/seasonality controls;
- observed-adjusted pooled OLS adding
market_pressure; - two-way fixed effects using region and period effects.
For a simulation with constant treatment effect and time-invariant latent confounding, the true coefficient is known.
The experiment demonstrates an important hierarchy:
- adjusting for an observed confounder can reduce some bias;
- residual bias remains when latent regional selection persists;
- entity effects remove time-invariant latent regional factors;
- time effects remove common period shocks.
This is a controlled demonstration, not a claim that fixed effects repair all forms of confounding.
Methodology contracts¶
The module attaches explicit methodology metadata to each model family.
Pooled OLS references consistency, conditional exchangeability, positivity, and no interference.
Fixed effects additionally require strict exogeneity appropriate to the panel specification and no unmeasured time-varying confounding.
Random effects require orthogonality between unit-specific effects and the regressors.
The contracts document what is required for a treatment coefficient to receive a causal interpretation; fitting the model itself does not establish those assumptions.