### 5.8 Random-eﬀects dynamic stochastic frontier

Mathematical representation

$\begin{array}{lllll}\hfill & {y}_{it}={\alpha }_{i}+{\mathbf{x}}_{it}^{\prime }\beta +{v}_{it}±{u}_{it},\phantom{\rule{2em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{2em}{0ex}}& \hfill & {v}_{it}\sim \mathrm{N}\left(0,\frac{1}{\tau }\right),\phantom{\rule{1em}{0ex}}{\alpha }_{i}\sim \mathrm{N}\left(0,\frac{1}{\omega }\right)\phantom{\rule{2em}{0ex}}& \hfill \text{(5.11)}\\ \hfill & {s}_{it}=f\left({u}_{it}\right)\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}& \hfill \text{(5.12)}\\ \hfill & {s}_{it}={\mathbf{z}}_{it}^{\prime }\delta +\rho {s}_{i,t-1}+{\xi }_{it},\phantom{\rule{2em}{0ex}}& \hfill & {\xi }_{it}\sim \mathrm{N}\left(0,\frac{1}{\varphi }\right)\phantom{\rule{2em}{0ex}}& \hfill \text{(5.13)}\\ \hfill & {s}_{i1}=\frac{{\mathbf{z}}_{i1}^{\prime }\delta }{1-\rho }+{\xi }_{i1},\phantom{\rule{2em}{0ex}}& \hfill & {\xi }_{i1}\sim \mathrm{N}\left(0,\frac{1}{\varphi {\left(1-\rho \right)}^{2}}\right)\phantom{\rule{2em}{0ex}}& \hfill \text{(5.14)}\end{array}$
• the model is estimated using observations from $N$ groups, each group observed for ${T}_{i}$ periods (balanced or unbalanced panels); the total number of observations is ${\sum }_{i=1}^{N}{T}_{i}$
• ${y}_{it}$ is the value of the dependent variable for group $i$, observed in period $t$
• ${\mathbf{x}}_{it}$ 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 group $i$, observed in period $t$
• $\beta$ is a $K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector of parameters associated with the variables in the observed equation
• $\tau$ is the precision of the noise component of the error term in the observed equation: ${\sigma }_{v}^{2}=\frac{1}{\tau }$
• ${\alpha }_{i}$ is the group-speciﬁc error term for group $i$
• $\omega$ is precision of the group-speciﬁc error term: ${\sigma }_{\alpha }^{2}=\frac{1}{\omega }$
• ${u}_{i}$ is the ineﬃciency component of the error term
• ${s}_{it}$ is the value of the hidden-state variable for group $i$, period $t$; this hidden state is a monotonic transformation of the ineﬃciency component of the error term: ${s}_{it}=f\left({u}_{it}\right)$ and controls the autoregressive process of eﬃciency; BayES supports the following transformations:
• ${s}_{it}=log\left(\frac{{e}^{-{u}_{it}}}{1-{e}^{-{u}_{it}}}\right)$ as presented in Emvalomatis (2011); in this formulation the eﬃciency score, ${e}^{-{u}_{it}}$, follows, conditional on ${s}_{i,t-1}$, a logit-normal distribution
• ${s}_{it}=log\left({u}_{it}\right)$ as presented in Tsionas (2006); in this formulation ${u}_{it}$ follows, conditional on ${s}_{i,t-1}$, a log-normal distribution
• ${\mathbf{z}}_{it}$ is an $L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector that stores the values of the $L$ determinants of ineﬃciency, as they enter equation (5.13), for group $i$, observed in period $t$
• $\delta$ is an $L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector of parameters associated with the variables in the hidden-state equation
• $\rho$ is a parameter that measures the persistence of ineﬃciency
• $\varphi$ is the precision of the error term in the hidden-state equation: ${\sigma }_{\xi }^{2}=\frac{1}{\varphi }$

 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.

 The mean of the distribution of the ${\alpha }_{i}$s is restricted to zero and, therefore, these are simply group-speciﬁc errors terms. However, including a constant term in the set of independent variables is valid and leads to a speciﬁcation equivalent to one where the group eﬀects are draws from a normal distribution with mean equal to the parameter associated with the constant term and precision $\omega$.

 Due to Metropolis-Hastings updates used by BayES in the estimation of dynamic stochastic frontier models, the draws from the posterior are likely to have very large autocorrelation times. Therefore, long burn-ins are recommended (above 30,000 draws) and large thinning parameters if machine memory is an issue.

Priors

 Parameter Probability density function Default hyperparameters $\beta$ $p\left(\beta \right)=\frac{|{\mathbf{P}}_{\beta }{|}^{1∕2}}{{\left(2\pi \right)}^{K∕2}}exp\left\{-\frac{1}{2}{\left(\beta -{\mathbf{m}}_{\beta }\right)}^{\prime }{\mathbf{P}}_{\beta }\left(\beta -{\mathbf{m}}_{\beta }\right)\right\}$ ${\mathbf{m}}_{\beta }={\mathbf{0}}_{K}$, ${\mathbf{P}}_{\beta }=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$ $\omega$ $p\left(\omega \right)=\frac{{b}_{\omega }^{{a}_{\omega }}}{\Gamma \left({a}_{\omega }\right)}{\omega }^{{a}_{\omega }-1}{e}^{-\omega {b}_{\omega }}$ ${a}_{\omega }=0.01$, ${b}_{\omega }=0.001$ $\delta$ $p\left(\delta \right)=\frac{|{\mathbf{P}}_{\delta }{|}^{1∕2}}{{\left(2\pi \right)}^{L∕2}}exp\left\{-\frac{1}{2}{\left(\delta -{\mathbf{m}}_{\delta }\right)}^{\prime }{\mathbf{P}}_{\delta }\left(\delta -{\mathbf{m}}_{\delta }\right)\right\}$ ${\mathbf{m}}_{\delta }={\mathbf{0}}_{L}$, ${\mathbf{P}}_{\delta }=0.001\cdot {\mathbf{I}}_{L}$ $\rho$ $p\left(\rho \right)=\frac{{\rho }^{{a}_{\rho }-1}\left(1-\rho \right){\rho }^{{b}_{\rho }-1}}{B\left({a}_{\rho },{b}_{\rho }\right)}$ ${a}_{\rho }=4.0$, ${b}_{\rho }=2.0$ $\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 }=0.1$, ${b}_{\varphi }=0.01$

Syntax

$\left[$<model name> = $\right]$ sf_dyn_re( y ~ x1 x2 $\dots$ xK $|$ z1 z2 $\dots$ zL $\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
• z1 z2 $\dots$zL is a list of the $L$ variable names that enter the hidden-state equation, 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; it is possible to run a model with an empty z list, however, it is recommended that at least a constant term is included

 BayES automatically drops from the sample used for estimation groups which are observed only once. This is because for these groups the group eﬀect (${\alpha }_{i}$) cannot be distinguished from the noise component of the error term (${v}_{it}$).

 Groups that contain observations which are not consecutive according to the panel time variable (for example, a group is observed for two consecutive periods, not observed for the following period and observed again for another string of consecutive time periods) are split into multiple groups, with each string of consecutive observations treated as a diﬀerent group. A warning is produced when the dataset used for estimation contains groups with gaps in the time dimension.

The optional arguments for the random-eﬀects dynamic stochastic frontier model are:10

 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: "explogitn" "logn" the default value is "explogitn" "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 "m_beta" 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_beta" 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$ "a_omega" shape parameter of the prior for $\omega$ (positive number); the default value is $0.01$ "b_omega" rate parameter of the prior for $\omega$ (positive number); the default value is $0.001$ "m_delta" mean vector of the prior for $\delta$ ($L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector); the default value is ${\mathbf{0}}_{L}$ "P_delta" precision matrix of the prior for $\delta$ ($L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}L$ 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}}_{L}$ "a_rho" alpha parameter of the prior for $\rho$ (positive number); the default value is $4$ "b_rho" beta parameter of the prior for $\rho$ (positive number); the default value is $2$ "a_phi" shape parameter of the prior for $\varphi$ (positive number); the default value is $0.1$ "b_phi" rate parameter of the prior for $\varphi$ (positive number); the default value is $0.01$ 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

 $\beta$ variable_name vector of parameters associated with the independent variables in the x list $\tau$ tau precision parameter of the noise component of the error term, ${v}_{i}$ $\omega$ omega precision parameter of the group-speciﬁc error term, ${\alpha }_{i}$ $\delta$ variable_name vector of parameters associated with the independent variables in the z list $\varphi$ phi precision parameter of the error term in the hidden-state equation of the error term, ${u}_{i}$ ${\sigma }_{v}$ sigma_v standard deviation of the noise component of the error term, ${\sigma }_{v}=1∕{\tau }^{1∕2}$ ${\sigma }_{\alpha }$ sigma_alpha standard deviation of the group-speciﬁc error term: ${\sigma }_{\alpha }=1∕{\omega }^{1∕2}$ ${\sigma }_{s}$ sigma_s standard deviation of the error term in the hidden-state equation: ${\sigma }_{\alpha }=1∕{\varphi }^{1∕2}$

Stored values and post-estimation analysis
If a left-hand-side id value is provided when a random-eﬀects dynamic 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$, $\tau$, $\omega$, $\delta$, $\rho$ and $\varphi$ y$x1,$\dots$,y$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, prepended by y$, where y is the name of the dependent variable; this is done so that the samples on the parameters associated with a variable that appears in both x and z lists can be distinguished) tau vector containing the draws from the posterior of $\tau$ omega vector containing the draws from the posterior of $\omega$ s$z1,$\dots$,s$zL vectors containing the draws from the posterior of the parameters associated with variables z1,$\dots$,zL (the names of these vectors are the names of the variables that were included in the z list, in the right-hand side of the model, prepended by s$; this is done so that the samples on the parameters associated with a variable that appears in both x and z lists can be distinguished) rho vector containing the draws from the posterior of $\rho$ phi vector containing the draws from the posterior of $\varphi$ (available after the estimation of the truncated-normal 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 alpha_i $N\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector that stores the group-speciﬁc errors; the values in this vector are not guaranteed to be in the same order as the order in which the groups appear in the dataset used for estimation; use the store() function to associate the values in alpha_i with the observations in the dataset 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()
• mfx()

The random-eﬀects dynamic stochastic frontier model uses the store() function to associate the group eﬀects (alpha_i) or 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 random-eﬀects dynamic stochastic frontier model and for each of these two quantities is:

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

and:

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); set_pd( year, id, "dataset" = myData); explogitnSF = sf_dyn_re( y ~ constant x1 x2 x3 | constant z2 ); Example 2 myData = import("$BayESHOME/Datasets/dataset1.csv", ",");
myData.constant = ones(rows(myData), 1);
set_pd( year, id, "dataset" = myData);

explogitnSF = sf_dyn_re( y ~ constant x1 x2 x3 | constant z2,
"udist" = "explogitn" );

lognSF = sf_dyn_re( y ~ constant x1 x2 x3 | constant z2,
"udist" = "logn" );

store( alpha_i, re_explogitn, "model" = explogitnSF );
store( alpha_i, re_logn, "model" = lognSF );

store( eff_i, eff_explogitn, "model" = explogitnSF );
store( eff_i, eff_logn, "model" = lognSF );

pmp( { explogitnSF, lognSF } );

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