This package was built was to facilitate direct maximum likelihood estimation of the normal-gamma and normal-Nakagami stochastic frontier models using closed-form expressions for the log-likelihood functions and efficiency predictors in terms of the parabolic cylinder function, as explored in the paper:
- Stead AD. 2024. Maximum likelihood estimation of normal-gamma and normal-Nakagami stochastic frontier models. Journal of Productivity Analysis. DOI: 10.1007/s11123-024-00742-2
The package however also includes options to estimate other stochastic frontier specifications, and may be of more general use to anyone who wishes to use Python for stochastic frontier analysis. All results in the paper were obtained using this package.
The package produces parameter estimates, standard errors, log-likelihoods, efficiency predictors, and more in a convenient format.
Currently the package is limited to models of the form
Provided you have the git
package installed, you can install FronPy
by entering:
pip install git+https://github.com/AlexStead/FronPy.git
The code block below estimates the normal-gamma stochastic frontier model, and demonstrates the package's basic syntax:
import fronpy
import numpy as np
electricity = fronpy.utils.dataset('electricity.csv')
nexpmodel = fronpy.estimate(electricity,model='nexp',cost=True)
ngmodel = fronpy.estimate(electricity,model='ng',startingvalues=np.append(nexpmodel.theta,0),cost=True)
ngmodel
In the final line, ngmodel
produces rather a lot of output, but is useful to see all of the outputs produced by the fronpy.estimate
. For example, we can see that ngmodel.lnlikelihood
would give us the log-likelihood, ngmodel.beta
would give us the estimated frontier parameters, ngmodel.eff_bc
would give us fronpy.estimate
requires a numpy.ndarray
with rows representing observations and columns representing variables, where:
- all data are numeric.
- the first column contains the dependent variable.
- columns 2,...,n contain the independent variables, including a constant if desired.
- there are no missing,
NaN
,inf
,-inf
or similarly invalid values. The package then assumes that the frontier is linear in its parameters, e.g. Cobb-Douglas or translog; note that any interactions must be included as columns in thenumpy.ndarray
. The package may be generalised in future to allow for arbitrary functional forms.