Estimate a Correlated Random Effects (Mundlak) model.
Augments a random-effects model with the entity means of each time-varying regressor. By the Mundlak equivalence the coefficient on each original regressor equals its within (fixed-effects) estimate — so analyze_cre_table(df, "y", "x", ...) recovers the same slope on x as analyze_regression_table(df, "y", "x", feffects=[entity]) — while the coefficient on x_mean measures the between-vs-within gap. A joint Wald test that all *_mean coefficients are zero is the regression-form Hausman test (reported on the fitted model as _cre_mundlak_stat / _cre_mundlak_df / _cre_mundlak_p).
The cross-section and time identifiers. Both default to the declared panel (set via :func:~expdpy.set_panel), so they can be omitted when it is declared.
The cross-section and time identifiers. Both default to the declared panel (set via :func:~expdpy.set_panel), so they can be omitted when it is declared.
models (the fitted linearmodels result), etable (the rendered table) and df (tidy coefficients for each regressor, its *_mean and the intercept).
Examples
import expdpy as exfrom expdpy.data import load_kuznets, load_kuznets_data_defdf = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)cre = ex.analyze_cre_table(df, dv="gini_regional", idvs=["log_gdp_pc"])cre.etable # the log_gdp_pc coefficient == the within / fixed-effects estimatecre.df # rows for log_gdp_pc, log_gdp_pc_mean and Interceptprint(cre.interpret())
This Correlated Random Effects (Mundlak) model relates **gini_regional** to its regressors *and* their unit (entity) means. By the Mundlak equivalence the coefficient on each original regressor equals its **within (fixed-effects)** estimate, while the coefficient on the mean is the gap between the between- and within-unit associations.
- **log_gdp_pc** (within estimate): a one-unit increase is associated with gini_regional that is 0.0292 higher (not statistically significant at conventional levels).
Joint test that the 1 mean coefficient(s) are zero — the regression-form Hausman test — χ²(1) = 2.23, p = 0.136: this are indistinguishable from zero, so **random effects is admissible** (and more efficient than fixed effects).
_These are associations, not causal effects. A causal reading needs a research design — see `explain('correlation_vs_causation')`._