import expdpy as ex
res = ex.learn_hausman_test()
res.figlearn_hausman_test
learn_hausman_test(
n_units=60,
n_periods=8,
beta=1.0,
unit_effect_corr=0.8,
seed=0,
)Show why the Hausman test prefers fixed effects when unit effects are correlated.
Simulates a panel where the regressor x is correlated with each unit’s effect. Random effects assumes no such correlation (so it is biased here) while fixed effects is consistent; the Hausman test compares the two and rejects their equality.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| n_units | int | Panel dimensions. | 60 |
| n_periods | int | Panel dimensions. | 60 |
| beta | float | True within-unit slope. | 1.0 |
| unit_effect_corr | float | Correlation between x and the unit effect (drives the random-effects bias). |
0.8 |
| seed | int | Random seed. | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| SandboxResult | df (FE vs RE vs true slope), fig, summary and topic. |
Examples
This sandbox simulates its own panel, so the call needs no DataFrame: