Science Score: 57.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.6%) to scientific vocabulary
Keywords
Repository
Python package for frontier analysis
Basic Info
Statistics
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 9
Topics
Metadata Files
README.md
FronPy
Version 1.0.2
Python package for stochastic frontier analysis
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 $$y_i=\boldsymbol{x'_i\beta}+E_i, \qquad E_i=V_i-sU_i, \qquad V_i\sim N\left(0,\sigma_V^2\right),$$ where $U_i$ may be either $N^+\left(0,\sigma_U^2\right)$ (half normal), $N^+\left(\mu,\sigma_U^2\right)$ (truncated normal), $\mathrm{Rayleigh}\left(\sigma_U/2\right)$, $\mathrm{Nakagami}\left(\mu,\sigma_U\right)$ (truncated normal), $\mathrm{Gamma}\left(\mu,\sigma_U\right)$, and $\mathrm{Exponential}\left(\sigma_U\right)$; N.B. in the latter three cases $\sigma_U$ is a scale parameter.
All distributional parameters are assumed to be scalars by default, but may be modelled as a function of a vector of covariates, e.g. $\ln\sigma_{vi}=\boldsymbol{z'_{vi}\delta_v}$, or $\ln\sigma_{ui}=\boldsymbol{z'_{ui}\delta_u}$, or $\ln\mu_{i} = \boldsymbol{z'_{\mu i}\delta_\mu}$ (gamma and Nakagami models only), or $\mu_{i} = \boldsymbol{z'_{\mu i}\delta_\mu}$ (truncated normal model only), or combinations of these.
The package may be extended in future in order to accomodate additional specifications.
Installation
Provided you have the git package installed, you can install FronPy by entering:
python
pip install git+https://github.com/AlexStead/FronPy.git
Getting started
The code block below prints the help text explaining the use of the fronpy.dataset() and fronpy.estimate() functions: ```python import fronpy
help(fronpy.dataset) help(fronpy.estimate) ```
The code block below loads a built-in dataset, does some basic data transformation, estimates the normal-gamma stochastic frontier model, and demonstrates the package's basic syntax: ```python import fronpy import numpy as np electricitydf = fronpy.dataset('electricitydf.csv',dataframe=True)
electricitydf[f'lnc'] = np.log((electricitydf['cost']/electricitydf['cost'].mean())/(electricitydf['fprice']/electricitydf['fprice'].mean())) electricitydf[f'q'] = electricitydf['output'] / electricitydf['output'].mean() electricitydf[f'lnq'] = np.log(electricitydf['output'] / electricitydf['output'].mean()) electricitydf[f'lnw'] = np.log((electricitydf['lprice']/electricitydf['lprice'].mean())/(electricitydf['fprice']/electricitydf['fprice'].mean())) electricitydf[f'lnr'] = np.log((electricitydf['cprice']/electricitydf['cprice'].mean())/(electricitydf['fprice']/electricity_df['fprice'].mean()))
nexpmodel = fronpy.estimate(electricitydf,frontier='lnc~np.log(q)+I(np.log(q)**2)+lnw+lnr',cost=True,model='nexp') ngmodel = fronpy.estimate(electricitydf,frontier='lnc~np.log(q)+I(np.log(q)**2)+lnw+lnr',cost=True,model='ng', startingvalues=np.append(nexpmodel.theta,[0])) 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 $\mathbb{E}[e^{-Ui}|Ei=\varepsilon_i]$ for each observation, and so on. Note that currently, 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.
Alternatively, the following command may be used to launch a graphical user interface. Note that this is very rudimentary, and needs further development to incorporate all of the options available using the command line interface:
python
import fronpy
fronpy.launch_gui()
Owner
- Name: Dr Alex Stead
- Login: AlexStead
- Kind: user
- Company: University of Leeds
- Website: https://environment.leeds.ac.uk/transport/staff/979/dr-alexander-stead
- Twitter: AlexanderStead
- Repositories: 2
- Profile: https://github.com/AlexStead
Lecturer in Transport Economics, @ITSLeeds @universityofleeds
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: Stead
given-names: Alexander D.
orcid: "https://orcid.org/0000-0002-7836-3827"
title: "FronPy: A Python package for frontier analysis"
version: 1.0.0
doi: 10.5281/zenodo.14262815
date-released: 2024-12-03
url: "https://github.com/AlexStead/FronPy"
GitHub Events
Total
- Release event: 10
- Watch event: 1
- Delete event: 4
- Push event: 27
- Pull request event: 18
- Fork event: 1
- Create event: 14
Last Year
- Release event: 10
- Watch event: 1
- Delete event: 4
- Push event: 27
- Pull request event: 18
- Fork event: 1
- Create event: 14