import expdpy as ex
res = ex.learn_pooled_vs_fixed_effects()
res.figlearn_pooled_vs_fixed_effects
learn_pooled_vs_fixed_effects(
n_units=50,
n_periods=10,
beta=1.0,
unit_effect_corr=0.8,
seed=0,
)Show how pooled OLS is biased by unit effects, and fixed effects fix it.
Simulates a panel where the regressor x is correlated with each unit’s fixed effect. Pooled OLS confounds within- and between-unit variation (biased); the within (fixed- effects) estimator recovers the true slope.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| n_units | int | Panel dimensions. | 50 |
| n_periods | int | Panel dimensions. | 50 |
| beta | float | True within-unit slope. | 1.0 |
| unit_effect_corr | float | Correlation between x and the unit effect (drives the pooled bias). |
0.8 |
| seed | int | Random seed. | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| SandboxResult | df (pooled vs FE vs true slope), fig, summary and topic. |
Examples
This sandbox simulates its own panel, so the call needs no DataFrame: