### 5.1 Simple stochastic frontier

Mathematical representation

 ${y}_{i}={\mathbf{x}}_{i}^{\prime }\beta +{v}_{i}±{u}_{i},\phantom{\rule{2em}{0ex}}\phantom{\rule{1em}{0ex}}{v}_{i}\sim \mathrm{N}\left(0,\frac{1}{\tau }\right),\phantom{\rule{1em}{0ex}}{u}_{i}\sim \mathrm{D}\left(𝜃\right)$ (5.1)
• the model is estimated using $N$ observations
• ${y}_{i}$ is the value of the dependent variable for observation $i$
• ${\mathbf{x}}_{i}$ is a $K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector that stores the values of the $K$ independent variables for observation $i$
• $\beta$ is a $K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector of parameters
• $\tau$ is the precision of the noise component of the error term: ${\sigma }_{v}^{2}=\frac{1}{\tau }$
• ${u}_{i}$ is the ineﬃciency component of the error term and it can have any non-negative distribution, represented in the equation above by $\mathrm{D}\left(𝜃\right)$; BayES supports the following distributions for ${u}_{i}$:
• exponential: $p\left({u}_{i}\right)=\lambda {e}^{-\lambda {u}_{i}}$
• half normal: $p\left({u}_{i}\right)=\frac{2{\varphi }^{1∕2}}{{\left(2\pi \right)}^{1∕2}}exp\left\{-\frac{\varphi }{2}{u}_{i}^{2}\right\}$
• truncated normal: $p\left({u}_{i}\right)=\frac{{\varphi }^{1∕2}exp\left\{-\frac{\varphi }{2}{\left({u}_{i}-\mu \right)}^{2}\right\}}{{\left(2\pi \right)}^{1∕2}{\Phi }^{1∕2}\left({\varphi }^{1∕2}\mu \right)}$
• gamma: $p\left({u}_{i}\right)=\frac{{\lambda }^{\kappa }}{\Gamma \left(\kappa \right)}{u}_{i}^{\kappa -1}{e}^{-\lambda {u}_{i}}$
• log-Normal: $p\left({u}_{i}\right)=\frac{{\varphi }^{1∕2}}{{\left(2\pi \right)}^{1∕2}{u}_{i}}exp\left\{-\frac{\varphi }{2}{\left(log{u}_{i}-\mu \right)}^{2}\right\}$

 When ${u}_{i}$ enters the speciﬁcation with a plus sign then the model represents a cost frontier, while when ${u}_{i}$ enters with a minus sign the model represents a production frontier. For the eﬃciency scores generated by a stochastic frontier model to be meaningful, the dependent variable in both cases must be in logarithms.

Priors

 Parameter Probability density function Default hyperparameters Common to all models $\beta$ $p\left(\beta \right)=\frac{|\mathbf{P}{|}^{1∕2}}{{\left(2\pi \right)}^{K∕2}}exp\left\{-\frac{1}{2}{\left(\beta -\mathbf{m}\right)}^{\prime }\mathbf{P}\left(\beta -\mathbf{m}\right)\right\}$ $\mathbf{m}={\mathbf{0}}_{K}$, $\mathbf{P}=0.001\cdot {\mathbf{I}}_{K}$ $\tau$ $p\left(\tau \right)=\frac{{b}_{\tau }^{{a}_{\tau }}}{\Gamma \left({a}_{\tau }\right)}{\tau }^{{a}_{\tau }-1}{e}^{-\tau {b}_{\tau }}$ ${a}_{\tau }=0.001$, ${b}_{\tau }=0.001$ Exponential model $\lambda$ $p\left(\lambda \right)=\frac{{b}_{\lambda }^{{a}_{\lambda }}}{\Gamma \left({a}_{\lambda }\right)}{\lambda }^{{a}_{\lambda }-1}{e}^{-\lambda {b}_{\lambda }}$ ${a}_{\lambda }=1$, ${b}_{\lambda }=0.15$ Half normal model $\varphi$ $p\left(\varphi \right)=\frac{{b}_{\varphi }^{{a}_{\varphi }}}{\Gamma \left({a}_{\varphi }\right)}{\varphi }^{{a}_{\varphi }-1}{e}^{-\varphi {b}_{\varphi }}$ ${a}_{\varphi }=7$, ${b}_{\varphi }=0.5$ Truncated normal model $\mu$ $p\left(\mu \right)=\frac{{t}_{\mu }^{1∕2}}{{\left(2\pi \right)}^{1∕2}}exp\left\{-\frac{{t}_{\mu }}{2}{\left(\mu -{m}_{\mu }\right)}^{2}\right\}$ ${m}_{\mu }=0$, ${t}_{\mu }=1$ $\varphi$ $p\left(\varphi \right)=\frac{{b}_{\varphi }^{{a}_{\varphi }}}{\Gamma \left({a}_{\varphi }\right)}{\varphi }^{{a}_{\varphi }-1}{e}^{-\varphi {b}_{\varphi }}$ ${a}_{\varphi }=5$, ${b}_{\varphi }=0.5$ Gamma model $\kappa$ $p\left(\kappa \right)=\frac{{b}_{\kappa }^{{a}_{\kappa }}}{\Gamma \left({a}_{\kappa }\right)}{\kappa }^{{a}_{\kappa }-1}{e}^{-\kappa {b}_{\kappa }}$ ${a}_{\kappa }=3$, ${b}_{\kappa }=2$ $\lambda$ $p\left(\lambda \right)=\frac{{b}_{\lambda }^{{a}_{\lambda }}}{\Gamma \left({a}_{\lambda }\right)}{\lambda }^{{a}_{\lambda }-1}{e}^{-\lambda {b}_{\lambda }}$ ${a}_{\lambda }=\kappa$, ${b}_{\lambda }=0.2$ Log-normal model $\mu$ $p\left(\mu \right)=\frac{{t}_{\mu }^{1∕2}}{{\left(2\pi \right)}^{1∕2}}exp\left\{-\frac{{t}_{\mu }}{2}{\left(\mu -{m}_{\mu }\right)}^{2}\right\}$ ${m}_{\mu }=-1.5$, ${t}_{\mu }=1$ $\varphi$ $p\left(\varphi \right)=\frac{{b}_{\varphi }^{{a}_{\varphi }}}{\Gamma \left({a}_{\varphi }\right)}{\varphi }^{{a}_{\varphi }-1}{e}^{-\varphi {b}_{\varphi }}$ ${a}_{\varphi }=2$, ${b}_{\varphi }=1$

Syntax

$\left[$<model name> = $\right]$ sf( y ~ x1 x2 $\dots$ xK $\left[$, <options> $\right]$ );

where:

• y is the dependent variable name, as it appears in the dataset used for estimation
• x1 x2 $\dots$xK is a list of the $K$ independent variable names, as they appear in the dataset used for estimation; when a constant term is to be included in the model, this must be requested explicitly

The optional arguments for the simple stochastic frontier model are:1

 Gibbs parameters "chains" number of chains to run in parallel (positive integer); the default value is 1 "burnin" number of burn-in draws per chain (positive integer); the default value is 10000 "draws" number of retained draws per chain (positive integer); the default value is 20000 "thin" value of the thinning parameter (positive integer); the default value is 1 "seed" value of the seed for the random-number generator (positive integer); the default value is 42 Model specification "udist" speciﬁcation of the distribution of the ineﬃciency component of the error term; the following options are available, corresponding to the distributions presented at the beginning of this section: "exp" "hnorm" "tnorm" "gamma" "lognorm" the default value is "exp" "production" boolean specifying the type of frontier (production/cost); it could be set to either true (production) or false (cost); the default value is true Hyperparameters Common to all models "m" mean vector of the prior for $\beta$ ($K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector); the default value is ${\mathbf{0}}_{K}$ "P" precision matrix of the prior for $\beta$ ($K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}K$ symmetric and positive-deﬁnite matrix); the default value is $0.001\phantom{\rule{0.3em}{0ex}}\cdot \phantom{\rule{0.3em}{0ex}}{\mathbf{I}}_{K}$ "a_tau" shape parameter of the prior for $\tau$ (positive number); the default value is $0.001$ "b_tau" rate parameter of the prior for $\tau$ (positive number); the default value is $0.001$ Exponential model "a_lambda" shape parameter of the prior for $\lambda$ (positive number); the default value is $1$ "b_lambda" rate parameter of the prior for $\lambda$ (positive number); the default value is $0.15$ Half normal model "a_phi" shape parameter of the prior for $\varphi$ (positive number); the default value is $7$ "b_phi" rate parameter of the prior for $\varphi$ (positive number); the default value is $0.5$ Truncated normal model "m_mu" location parameter of the prior for $\mu$ (real number); the default value is $0$ "t_mu" precision parameter of the prior for $\mu$ (positive number); the default value is $1$ "a_phi" shape parameter of the prior for $\varphi$ (positive number); the default value is $5$ "b_phi" rate parameter of the prior for $\varphi$ (positive number); the default value is $0.5$ Gamma model "a_kappa" shape parameter of the prior for $\kappa$ (positive number); the default value is $3$ "b_kappa" rate parameter of the prior for $\kappa$ (positive number); the default value is $2$ "b_lambda" rate parameter of the prior for $\lambda$ (positive number); the default value is $0.2$ Log-normal model "m_mu" location parameter of the prior for $\mu$ (real number); the default value is $-1.5$ "t_mu" precision parameter of the prior for $\mu$ (positive number); the default value is $1$ "a_phi" shape parameter of the prior for $\varphi$ (positive number); the default value is $2$ "b_phi" rate parameter of the prior for $\varphi$ (positive number); the default value is $1$ Dataset and log-marginal likelihood "dataset" the id value of the dataset that will be used for estimation; the default value is the ﬁrst dataset in memory (in alphabetical order) "logML_CJ" boolean indicating whether the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood should be calculated (true$|$false); the default value is false

Reported Parameters

 Common to all models $\beta$ variable_name vector of parameters associated with the independent variables $\tau$ tau precision parameter of the noise component of the error term, ${v}_{i}$ ${\sigma }_{v}$ sigma_v standard deviation of the noise component of the error term, ${\sigma }_{v}=1∕{\tau }^{1∕2}$ Exponential model $\lambda$ lambda rate parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ ${\sigma }_{u}$ sigma_u scale parameter of the ineﬃciency component of the error term: ${\sigma }_{u}=1∕\lambda$. For the exponential model the standard deviation of ${u}_{i}$ is equal to the scale parameter. Half normal model $\varphi$ phi precision parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ ${\sigma }_{u}$ sigma_u scale parameter of the ineﬃciency component of the error term: ${\sigma }_{u}=1∕{\varphi }^{1∕2}$. The standard deviation of ${u}_{i}$ for the half-normal model can be obtained as ${\sigma }_{u}\sqrt{1-\frac{2}{\pi }}$. Truncated normal model $\mu$ mu location parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ $\varphi$ phi precision parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ ${\sigma }_{u}$ sigma_u scale parameter of the ineﬃciency component of the error term: ${\sigma }_{u}=1∕{\varphi }^{1∕2}$. The standard deviation of ${u}_{i}$ for the truncated-normal model can be obtained as ${\sigma }_{u}\sqrt{1-2\frac{\mu }{{\sigma }_{u}}\varphi \left(-\frac{\mu }{{\sigma }_{u}}\right)-4{\varphi }^{2}\left(-\frac{\mu }{{\sigma }_{u}}\right)}$. Gamma model $\kappa$ kappa shape parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ $\lambda$ lambda rate parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ $𝜃$ theta scale parameter of the ineﬃciency component of the error term: $𝜃=1∕\lambda$. The standard deviation of ${u}_{i}$ for the Gamma model can be obtained as $𝜃\sqrt{\kappa }$. Log-normal model $\mu$ mu location parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ $\varphi$ phi precision parameter of the distribution of the ineﬃciency component of the error term, ${u}_{i}$ ${\sigma }_{u}$ sigma_u scale parameter of the ineﬃciency component of the error term: ${\sigma }_{u}=1∕{\varphi }^{1∕2}$. The standard deviation of ${u}_{i}$ for the log-normal model can be obtained as $\sqrt{\left({e}^{{\sigma }_{u}^{2}}-1\right){e}^{2\mu +{\sigma }_{u}^{2}}}$.

Stored values and post-estimation analysis
If a left-hand-side id value is provided when a simple stochastic frontier model is created, then the following results are saved in the model item and are accessible via the ‘.’ operator:

 Samples a matrix containing the draws from the posterior of $\beta$ and $\tau$, and, depending on the estimated model, $\lambda$, $\mu$, $\varphi$, $\kappa$ x1,$\dots$,xK vectors containing the draws from the posterior of the parameters associated with variables x1,$\dots$,xK (the names of these vectors are the names of the variables that were included in the right-hand side of the model) tau vector containing the draws from the posterior of $\tau$ lambda vector containing the draws from the posterior of $\lambda$ (available after the estimation of the exponential and Gamma models) mu vector containing the draws from the posterior of $\mu$ (available after the estimation of the truncated-normal and log-normal models) phi vector containing the draws from the posterior of $\varphi$ (available after the estimation of the half-normal, truncated-normal and log-normal models) kappa vector containing the draws from the posterior of $\kappa$ (available after the estimation of the Gamma model) logML the Lewis & Raftery (1997) approximation of the log-marginal likelihood logML_CJ the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood; this is available only if the model was estimated with the "logML_CJ"=true option eff_i $N\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector that stores the expected values of the observation-speciﬁc eﬃciency scores, $E\left({e}^{-{u}_{i}}\right)$; the values in this vector are not guaranteed to be in the same order as the order in which the observations appear in the dataset used for estimation; use the store() function to associate the values in eff_i with the observations in the dataset nchains the number of chains that were used to estimate the model nburnin the number of burn-in draws per chain that were used when estimating the model ndraws the total number of retained draws from the posterior ($=$chains $\cdot$ draws) nthin value of the thinning parameter that was used when estimating the model nseed value of the seed for the random-number generator that was used when estimating the model

Additionally, the following functions are available for post-estimation analysis (see section B.14):

• diagnostics()
• test()
• pmp()
• store()

The simple stochastic frontier model uses the store() function to associate the estimates of the eﬃciency scores (eff_i) with speciﬁc observations and store their values in the dataset used for estimation. The generic syntax for a statement involving the store() function after estimation of a simple stochastic frontier model is:

store( eff_i, <new variable name> $\left[$, "model"=<model name>$\right]$ );

Examples

Example 1

myData = import("$BayESHOME/Datasets/dataset1.csv"); myData.constant = ones(rows(myData), 1); sf( y ~ constant x1 x2 x3, "logML_CJ" = true ); Example 2 myData = import("$BayESHOME/Datasets/dataset1.csv");
myData.constant = ones(rows(myData), 1);

expSF = sf( y ~ constant x1 x2 x3,
"a_lambda"=-log(0.8), "b_lambda"=1.0,
"logML_CJ"=true );

hnSF = sf( y ~ constant x1 x2 x3,
"udist" = "hnorm",
"a_phi"=7.0, "b_phi"=0.5,
"logML_CJ"=true );

pmp( { expSF, hnSF } );
pmp( { expSF, hnSF }, "logML_CJ"=true);

store( eff_i, eff_exp, "model"=expSF );
store( eff_i, eff_hn, "model"=hnSF );

hist(myData.eff_exp,
"title"="Efficiency scores from the exponential model",
"grid"="on");
hist(myData.eff_hn,
"title"="Efficiency scores from the half$-$normal model",
"grid"="on");

1Optional arguments are always given in option-value pairs (eg. "chains"=3).