Visualization

All plot functions return (fig, ax) or fig so that the caller can further customize the plot before calling plt.show(). Diagnostic plot methods are also available directly on fitted model objects: SW2023Model.plot_efficiency(), SW2023Model.plot_frontier(), SW2023Model.plot_diagnostics().

Cross-Sectional

sw2023.plot_efficiency_dist(efficiency, title='Efficiency Distribution', bins=30, figsize=(7, 4), color='steelblue', ax=None)[source]

Histogram of efficiency index values.

Parameters:
  • efficiency (array-like (n,) efficiency values [0,1])

  • title (str)

  • bins (int)

  • figsize (tuple)

  • color (str)

  • ax (matplotlib Axes or None)

sw2023.plot_efficiency_rank(efficiency, labels=None, ci=None, title='Efficiency Ranking', figsize=(10, 5), ax=None, top_n=None)[source]

Efficiency rank plot (Caterpillar plot).

Parameters:
  • efficiency ((n,) efficiency values)

  • labels ((n,) labels (None → index))

  • ci ((n, 2) confidence intervals [lo, hi] (optional))

  • title (str)

  • figsize (tuple)

  • ax (Axes or None)

  • top_n (int, show only top and bottom n observations (None → all))

sw2023.plot_frontier_1d(model, dim=0, n_grid=200, title='Frontier Estimate (U vs Z)', figsize=(7, 5), ax=None)[source]

Scatter plot of U vs Z[dim] with estimated frontier phi_hat(Z).

Parameters:
  • model (SW2023Model (fitted))

  • dim (int which dimension of Z to use as x-axis)

sw2023.plot_residuals(model, bins=40, figsize=(7, 4), title='Residual Distribution (eps = U r̂₁)', ax=None)[source]

Histogram of composite residuals eps = U - r_hat_1(Z).

Under the model, eps = ||d||·v - ||d||·eta where v ~ N(0, sigma_eps^2) and eta ~ N+(0, sigma_eta^2). The resulting distribution is skewed left (negative skewness) when inefficiency is present. Observations with r_hat_3 > 0 (wrong skewness) are highlighted.

Parameters:
sw2023.plot_diagnostics(model, figsize=(12, 9), title='SW(2023) Diagnostic Plots')[source]

Diagnostic plot panel for a fitted SW2023Model (2×2 layout).

Panels

(0,0) Efficiency distribution — histogram + mean/median lines (0,1) Efficiency ranking — caterpillar plot (sorted scores) (1,0) Residual distribution — eps = U − r̂₁, wrong-skew highlighted (1,1) r̂₃ sign distribution — wrong-skewness diagnostic

param model:

type model:

SW2023Model (fitted)

param figsize:

type figsize:

tuple, default (12, 9)

param title:

type title:

str

returns:

fig

rtype:

matplotlib Figure

Panel

sw2023.plot_panel_trend(model, time_id, figsize=(8, 5), title='Mean Efficiency by Period', ax=None)[source]

Yearly efficiency trend from PanelSW2023 results.

Parameters:
  • model (PanelSW2023 (fitted))

  • time_id (array-like (n,) period ID)

sw2023.plot_decomposition(model, figsize=(6, 6), title='Transient vs Persistent Efficiency', ax=None)[source]

TE vs PE scatter plot (4-component decomposition).

Parameters:

model (PanelSW2023 (fitted))