analyze_panel_table

source

analyze_panel_table(
    df,
    dv,
    idvs,
    *,
    entity=None,
    time=None,
    models=('pooled', 'between', 'fe', 're'),
    cov_type='clustered',
    cluster_entity=True,
    format='gt',
)

Estimate pooled / between / fixed / random-effects models side by side.

A linearmodels-backed companion to :func:expdpy.analyze_regression_table, returned in the same :class:~expdpy.RegressionTableResult container so .df, .interpret() and the apps work the same way. The one-way fixed-effects estimate matches analyze_regression_table(feffects=[entity]).

Parameters

Name Type Description Default
df pd.DataFrame Long panel data frame. required
dv str Dependent variable name. required
idvs Sequence[str] | str Independent variable name(s). required
entity str | None The cross-section and time identifiers. Default to the panel declared via :func:expdpy.set_panel / :func:expdpy.set_labels (set_panel=True). None
time str | None The cross-section and time identifiers. Default to the panel declared via :func:expdpy.set_panel / :func:expdpy.set_labels (set_panel=True). None
models Sequence[Literal['pooled', 'between', 'fe', 're']] Which estimators to include, in order. ('pooled', 'between', 'fe', 're')
cov_type Literal['clustered', 'robust', 'unadjusted'] Covariance estimator: "clustered" (default), "robust" or "unadjusted". 'clustered'
cluster_entity bool Cluster by entity when cov_type="clustered". True
format Literal['gt', 'md', 'df', 'html'] Output format for the rendered comparison table. 'gt'

Returns

Name Type Description
RegressionTableResult models (fitted linearmodels results), etable (the comparison table) and df (tidy coefficients with the same columns as the pyfixest path).

Examples

Basic — pooled / between / FE / RE side by side. With the panel declared by set_panel=True, entity and time are resolved automatically.

import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def

df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
tab = ex.analyze_panel_table(df, dv="gini_regional", idvs=["log_gdp_pc"])
tab.etable          # comparison of the four estimators
tab.df              # tidy coefficients, same columns as the pyfixest path
model term Estimate Std. Error t value Pr(>|t|)
0 1 log_gdp_pc -0.005374 0.007283 -0.737831 4.608143e-01
1 1 Intercept 0.322965 0.065923 4.899090 1.146224e-06
2 2 log_gdp_pc -0.006157 0.005944 -1.035736 3.035258e-01
3 2 Intercept 0.330172 0.055416 5.958062 6.962191e-08
4 3 log_gdp_pc 0.029208 0.024353 1.199326 2.307569e-01
5 4 log_gdp_pc 0.007370 0.010576 0.696912 4.860425e-01
6 4 Intercept 0.205648 0.096506 2.130934 3.337182e-02

Advanced — pick a subset of estimators, robust SEs, and read the interpretation.

import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def

df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
tab = ex.analyze_panel_table(
    df,
    dv="gini_regional",
    idvs=["log_gdp_pc", "trade_share"],
    models=("between", "fe"),
    cov_type="robust",
)
tab.etable
print(tab.interpret())
This OLS regression relates **gini_regional** to its regressors.

- **log_gdp_pc**: each one-unit increase is associated with gini_regional that is 0.00591 lower (not statistically significant at conventional levels).
- **trade_share**: each one-unit increase is associated with gini_regional that is 0.0576 lower (not statistically significant at conventional levels).

Model fit: N = 80, R² = 0.0428.
(This reads the first of 2 models in the table.)

_These are associations, not causal effects. A causal reading needs a research design — see `explain('correlation_vs_causation')`._