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)
result = ex.analyze_regression_table(
df, dvs="gini_regional", idvs=["log_gdp_pc", "log_gdp_pc_sq", "log_gdp_pc_cu"]
)
ex.analyze_coefficient_plot(result).figanalyze_coefficient_plot
analyze_coefficient_plot(
models,
*,
keep=None,
drop=None,
coef_labels=None,
model_labels=None,
alpha=0.05,
joint=False,
horizontal=True,
drop_intercept=True,
title=None,
)Plot coefficient estimates with confidence intervals for one or more models.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| models | Any | A fitted pyfixest model, a list of fitted models, or a :class:~expdpy.RegressionTableResult (its .models are used). This lets you do analyze_coefficient_plot(analyze_regression_table(...)) directly. |
required |
| keep | Sequence[str] | str | None | Optional regular-expression patterns selecting which coefficients to show (and in which order). keep whitelists, drop blacklists; both use pyfixest’s own coefficient-selection semantics. |
None |
| drop | Sequence[str] | str | None | Optional regular-expression patterns selecting which coefficients to show (and in which order). keep whitelists, drop blacklists; both use pyfixest’s own coefficient-selection semantics. |
None |
| coef_labels | Mapping[str, str] | None | Optional mapping from raw coefficient names to display labels. | None |
| model_labels | Sequence[str] | None | Optional legend labels, one per model (defaults to "Model 1", "Model 2"…). |
None |
| alpha | float | Significance level for the confidence intervals (default 0.05 → 95% intervals). |
0.05 |
| joint | bool | If True, draw simultaneous (joint) confidence bands via model.confint(joint= True) instead of pointwise intervals. |
False |
| horizontal | bool | If True (default), estimates run along the x-axis with coefficients listed down the y-axis (the most readable layout for many terms). |
True |
| drop_intercept | bool | If True (default), omit the intercept term. |
True |
| title | str | None | Optional figure title. | None |
Returns
| Name | Type | Description |
|---|---|---|
| CoefficientPlotResult | df (tidy long frame: model, term, estimate, se, ci_lower, ci_upper) and fig (the Plotly figure). |
Examples
Basic — plot a single fitted model’s coefficients:
Advanced — compare several models side by side with custom labels:
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)
pooled = ex.analyze_regression_table(
df, dvs="gini_regional", idvs=["log_gdp_pc"]
)
fe = ex.analyze_regression_table(
df, dvs="gini_regional", idvs=["log_gdp_pc"], feffects=["country", "year"]
)
ex.analyze_coefficient_plot(
[pooled, fe],
model_labels=["Pooled OLS", "Two-way FE"],
keep=["log_gdp_pc"],
).fig