Skip to main content

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]$.

Metadata

Release files for panelsfa 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for panelsfa 0.1.2
File Size Uploaded Provenance Actions
panelsfa-0.1.2.tar.gz 18.1 kB Without provenance Details for panelsfa-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for panelsfa 0.1.2
File Interpreter ABI Platform Actions
panelsfa-0.1.2-py3-none-any.whl Python 3 none any Details for panelsfa-0.1.2-py3-none-any.whl

Total release size: 40.8 kB

Release files / panelsfa-0.1.2.tar.gz

Download URL panelsfa-0.1.2.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5c546da9ac26c0ef5076519c07f0e766003304236f2b2db017586a9c4c40edb7
BLAKE2b-256 checksum
How to use checksums
d45f1076596b0db3a19110759c73450d0570f4a2cad6b7bbe41e1caeea31605f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / panelsfa-0.1.2-py3-none-any.whl

Download URL panelsfa-0.1.2-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2e8714d384ef786e143ead8f3425f678fa9ec8ab754e31c5da00ff4cb2295cb
BLAKE2b-256 checksum
How to use checksums
7ee81d803990f0ce2ae64445b83183d34482648fe65f747ccfa3653d7b2c7016
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for panelsfa 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page