Parametric Stochastic Frontier Analysis with a scikit-learn API
Project description
PanelSFA
Parametric Stochastic Frontier Analysis with a scikit-learn compatible API. This library implements foundational and state-of-the-art frontier models, enabling the estimation of technical efficiency in both cross-sectional and panel data settings.
Installation
pip install -e .
Dependencies: numpy>=1.23, scipy>=1.9, scikit-learn>=1.2
Models
| Class | Paper | Inefficiency Distribution | Key Extra Parameters |
|---|---|---|---|
CrossSectionalSFA |
ALS 1977 | Half-Normal | — |
TimeDecayPanelSFA |
BC 1992 | Truncated-Normal + time decay | groups, time |
EffectsPanelSFA |
BC 1995 | Truncated-Normal (effects) | groups, Z |
TrueFixedEffectsSFA |
Greene 2005 | Half-Normal (Intercepts profiled) | groups |
TrueRandomEffectsSFA |
Greene 2005 | MSL with Halton Draws | groups, n_simulations |
FourComponentSFA |
Kumbhakar et al. 2014 | Transient & Persistent Inefficiency | groups |
Quick-start
ALS 1977 – Cross-Sectional
The foundational stochastic frontier model using a half-normal distribution for inefficiency.
from panelsfa import CrossSectionalSFA
model = CrossSectionalSFA(model_type="production")
model.fit(X, y)
print(model.coef_) # Frontier coefficients (β)
print(model.gamma_) # Signal-to-noise ratio (γ)
te = model.score_efficiency(X, y) # Technical Efficiency ∈ (0, 1]
BC92 – Time-Varying Decay Panel
Extends ALS to panel data, allowing inefficiency to evolve deterministically over time via the $\eta$ parameter.
from panelsfa import TimeDecayPanelSFA
model = TimeDecayPanelSFA(model_type="production")
model.fit(X, y, groups=entity_ids, time=time_index)
print(model.eta_) # η > 0 implies inefficiency decreases over time
te = model.score_efficiency(X, y, groups=entity_ids, time=time_index)
BC95 – Inefficiency Effects Panel
Allows environmental covariates ($Z$) to directly explain the mean of the inefficiency distribution in a single-step estimation.
from panelsfa import EffectsPanelSFA
# Z contains covariates like farmer age or education level
model = EffectsPanelSFA(model_type="production")
model.fit(X, y, groups=entity_ids, Z=Z_covariates)
print(model.delta_) # Coefficients quantifying inefficiency drivers
te = model.score_efficiency(X, y, Z=Z_covariates)
Greene (2005) – True Fixed Effects (TFE)
Handles unobserved, time-invariant heterogeneity by profiling out firm-specific intercepts $\alpha_i$, preventing them from being captured as inefficiency.
from panelsfa import TrueFixedEffectsSFA
model = TrueFixedEffectsSFA(model_type="production")
model.fit(X, y, groups=entity_ids)
print(model.alphas_) # Recovered firm-specific intercepts
te = model.score_efficiency(X, y)
Greene (2005) – True Random Effects (TRE)
Uses Maximum Simulated Likelihood with Halton draws to integrate out a randomly distributed firm effect $w_i$.
from panelsfa import TrueRandomEffectsSFA
model = TrueRandomEffectsSFA(n_simulations=500)
model.fit(X, y, groups=entity_ids)
print(model.sigma_w_sq_) # Variance of the random effect (heterogeneity)
te = model.score_efficiency(X, y)
Kumbhakar et al. (2014) – Four-Component Model
Disentangles four distinct components: firm heterogeneity, random noise, persistent inefficiency, and transient inefficiency.
from panelsfa import FourComponentSFA
model = FourComponentSFA(model_type="production")
model.fit(X, y, groups=entity_ids)
# Multi-dimensional efficiency scoring
eff = model.score_efficiency(X, y, groups=entity_ids)
print(eff['transient']) # Short-term deviations
print(eff['persistent']) # Structural failures
print(eff['overall']) # Unified efficiency score
Numerical Engine & Parameterization
To ensure convergence on non-convex likelihood surfaces, PanelSFA utilizes an OLS Warm-Start with an intercept shift and reparameterizes constrained variables to an unconstrained space.
| Natural Parameter | Optimizer Parameter | Transform Back |
|---|---|---|
| $\sigma^2 > 0$ | $\ln(\sigma^2)$ | exp(·) |
| $\gamma \in (0, 1)$ | $\text{logit}(\gamma)$ | sigmoid(·) |
| $\beta, \mu, \eta, \delta, \alpha$ | identity | — |
Optimizer: L-BFGS-B (Limited-memory BFGS) for high-dimensional stability.
- Efficiency Scoring: Jondrow-Lovell-Materov-Schmidt (JLMS) conditional expectation $E[u|\varepsilon]$.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file panelsfa-0.1.2.tar.gz.
File metadata
- Download URL: panelsfa-0.1.2.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c546da9ac26c0ef5076519c07f0e766003304236f2b2db017586a9c4c40edb7
|
|
| MD5 |
3f60a0a62bf4f5b6686e2d3f878b4185
|
|
| BLAKE2b-256 |
d45f1076596b0db3a19110759c73450d0570f4a2cad6b7bbe41e1caeea31605f
|
File details
Details for the file panelsfa-0.1.2-py3-none-any.whl.
File metadata
- Download URL: panelsfa-0.1.2-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2e8714d384ef786e143ead8f3425f678fa9ec8ab754e31c5da00ff4cb2295cb
|
|
| MD5 |
39d37005fa448d0d9fcba36781ef96cf
|
|
| BLAKE2b-256 |
7ee81d803990f0ce2ae64445b83183d34482648fe65f747ccfa3653d7b2c7016
|