*! version 2.0.3 29apr2022

*! version 2.0.2 03mar2022

*! version 2.0.1 10jun2021

*! version 2.0.0 08dec2020

*! version 1.1.0 12jun2019

*! version 1.0.1 09jan2018

*! version 1.0.0 01jan2018

Title

xtsfkk -- Endogenous panel stochastic frontier models in the style of Karakaplan and Kutlu (2017)

Contents

Syntax

Description

Options

Examples

Stored Results

Program Author

Recommended Citation

Acknowledgments

Disclaimer

Syntax

Estimation Syntax

xtsfkk depvar [indepvars] [if] [in] [weight] [, options]

Version Syntax

xtsfkk, version

Replay Syntax

xtsfkk [, level(#)]

Frontier
noconstant suppress constant term

production fit production frontier model; can be omitted

cost fit cost frontier model; default is production frontier model

Equations
endogenous(endovarlist) specify endogenous variables

instruments(ivarlist) specify instrumental variables

exogenous(exovarlist) specify included exogenous variables;
seldom used and can be omitted.

leaveout(lovarlist) specify included exogenous variables
to be left out; seldom used and can be omitted.

uhet(uvarlist[, noconstant]) explanatory
variables for inefficiency variance function; use noconstant
to suppress constant term

whet(wvarlist) explanatory
variables for idiosyncratic error variance function

Regression
initial(matname) specify initial values matrix

delve delve into maximization problem to find better initial values

difficult use a different stepping algorithm in nonconcave regions

technique(algorithm_spec) specify maximization technique

iterate(#) perform maximum of # iterations; default is iterate(16000)

save(filename) save the current status of the estimation while running

load(filename) load the estimation from a previously saved file to continue
from where the estimation was

Reporting
version display xtsfkk version and program author information; can be used in Version Syntax only

level(#) sets confidence level; default is level(95); can be used in Replay Syntax
or in mldisplay(display_options)

header display constraints header

timer display elapsed time to command completion

beep[(#)] beep when command completes

compare display exogenous model regression results after displaying
endogenous model regression results

efficiency(effvar[, replace]) create efficiency variables
and summarize them in detail; use replace to replace contents of existing variables

test test endogeneity and report results

nicely display regression results nicely in single table

mldisplay(display_options) control ml display options; seldom used

All the variable lists above except depvar are allowed to contain factor variables.

Description

xtsfkk fits endogenous panel stochastic production or cost frontier models following
the methodology provided by Karakaplan and Kutlu (2017) . xtsfkk provides
estimators for the parameters of a linear model with a disturbance that is assumed to be
a mixture of two components: a measure of inefficiency which is strictly nonnegative and
a two-sided error term from a symmetric distribution. xtsfkk can handle endogenous
variables in the frontier and/or the inefficiency, and the xtsfkk
estimates outperform the standard xtfrontier estimates that ignore endogeneity.
See Karakaplan and Kutlu (2017) for a detailed
explanation of their methodology and empirical analyses.

Options

Frontier

noconstant suppresses the constant term (intercept) in the frontier.

production specifies that the model to be fitted is a production frontier model. Since
the xtsfkk default is production, this option can be omitted.

cost specifies that the model to be fitted is a cost frontier model. The
xtsfkk default is production.

Equations

endogenous(endovarlist)
specifies that the variables in endovarlist are to be treated as endogenous.
If this option is not specified, xtsfkk assumes that the model is exogenous.

instruments(ivarlist)
specifies that the variables in ivarlist are to be used as instrumental variables to handle
endogeneity. If this option is not specified, xtsfkk assumes that the model is exogenous.

exogenous(exovarlist)
specifies that exovarlist is the complete list of included exogenous variables. The
xtsfkk default for the complete list of included exogenous variables is indepvars +
uvarist + wvarlist. Notice that depending on the model, exovarlist can be
different than indepvars + uvarist + wvarlist. For an illustration, please see the
examples below.
exogenous(exovarlist) cannot
be used with leaveout(lovarlist). exogenous(exovarlist)
option is seldom used and can safely be omitted.

leaveout(lovarlist)
specifies that the variables in lovarlist are to be taken out of the xtsfkk default list of
included exogenous variables which is indepvars + uvarist + wvarlist. Notice that
depending on the model, some variables such as functions of some included exogenous variables
can be left out of the
complete list of included exogenous variables. For an illustration, please see the
examples below. leaveout(lovarlist) cannot be used with
exogenous(exovarlist). leaveout(lovarlist)
option is seldom used and can safely be omitted.

uhet(uvarlist[, noconstant])
specifies that the inefficiency component is heteroskedastic,
with the variance function depending on a linear combination of
uvarlist. Specifying noconstant suppresses the
constant term from the variance function.

whet(wvarlist)
specifies that the idiosyncratic error component is heteroskedastic,
with the variance function depending on a linear combination of
wvarlist.

Regression

initial(matname)
specifies that matname is the initial value matrix.

delve provides a regression-based methodology to search for better initial values. The xtsfkk
default is to use ml search. delve is often successful in finding better
initial values. Using delve is recommended.

difficult specifies that the likelihood function is likely to be
difficult to maximize because of nonconcave regions. When the message "not
concave" appears repeatedly, ml's standard stepping algorithm may not be
working well. difficult specifies that a different stepping algorithm be
used in nonconcave regions. There is no guarantee that difficult will
work better than the default; sometimes it is better and sometimes it is
worse. difficult option should only be used when the default stepper
declares convergence and the last iteration is "not concave" or when the
default stepper is repeatedly issuing "not concave" messages and producing only
tiny improvements in the log likelihood.

technique(algorithm_spec) specifies how the likelihood function is to be
maximized. The following algorithms are allowed. For details, see
Gould, Pitblado, and Poi (2010).

technique(nr) specifies Stata's modified Newton-Raphson (NR)
algorithm.

technique(dfp) specifies the Davidon-Fletcher-Powell (DFP)
algorithm.

technique(bfgs) specifies the Broyden-Fletcher-Goldfarb-Shanno
(BFGS) algorithm.

The default is technique(bfgs).

Switching between algorithms is possible by specifying more than one algorithm in the
technique(.) option. By default, an algorithm is used for
five iterations before switching to the next algorithm. To specify a
different number of iterations, include the number after the technique in
the option. For example, specifying technique(bfgs 10 nr 1000)
requests that xtsfkk perform 10 iterations with the BFGS algorithm
followed by 1000 iterations with the NR algorithm, and then switch back
to BFGS for 10 iterations, and so on. The process continues until the
convergence or the maximum number of iterations is reached.

iterate(#) specifies the maximum number of iterations. When the number
of iterations equals #, the optimizer stops and
presents the current results. If convergence gets declared before this
threshold is reached, the optimizer would stop and present the optimized results. The default
value of # for xtsfkk is the current value of
maxiter, which is 16000.

save(filename) saves the current status of the estimation to the hard drive
in every iteration while the estimation is running. Saving is especially useful if the user thinks
that intentional breaks may be needed or unintentional interruptions may happen while the estimation is running.
save option allows stopping the estimation temporarily to release memory for other tasks, and then continue
from where the estimation was left by using the load option. Even if the computer completely shuts down for
some external reason, as long as the save option is specified, the estimation can continue from where it was
with the load option.

load(filename) loads the estimation from a previously saved file to continue from
where the estimation was. The model specification with the load option needs to be the same as the specification
in the saved file.

Reporting

version displays the version of xtsfkk installed on Stata, and the program author information.
This option can only be used in Version Syntax.

level(#) specifies the confidence level, as a percentage, for confidence
intervals. The default is level(95) or as set by set level. This option can be
used in Replay Syntax or in mldisplay(display_options)

header displays a summary of the model constraints in the beginning of the regression. header
provides a way to check the model specifications quickly while the estimation is running, or a guide to
distinguish different regression results that are kept in a single log file.

timer displays the total elapsed time xtsfkk took to complete.
The total elapsed time is measured
from the moment the command is entered to the moment the reporting of all findings is completed.

beep[(#)] produces a beep when xtsfkk reports all of the findings. beep is
useful for multitasking. If # is specified, then the option produces # number of beeps.
If # is negative, then the option acts like an alarm and produces continuous beeps until the user
interrupts them actively.

compare estimates the specified model with exogeneity assumption and displays the regression
results after displaying the endogenous model regression results.

efficiency(effvar[, replace]) generates the production or cost efficiency variable
effvar_EN once the estimation is completed, and displays its summary statistics in detail. Notice that the option
automatically extends any specified variable name effvar with _EN. If compare
option is specified, efficiency option also generates effvar_EX, the production or cost efficiency
variable of the exogenous model, and displays its summary statistics. Specifying replace
replaces the contents of the existing effvar_EN and effvar_EX with the new efficiency values
from the current model.

test provides a method to test the endogeneity in the model. test tests the joint
significance of the components of the eta term, and reports the findings after displaying the regression
results. For more information about test see Karakaplan and Kutlu (2017) .

nicely displays the regression results nicely in a single table. nicely requires
estout, a user-written command by Ben Jann, to format some parts of the table,
and xtsfkk table style
resembles that of Karakaplan and Kutlu (2017) . nicely option checks
if estout package
is installed on Stata or not, and if not, then nicely option installs the package. If
compare option is specified,
nicely displays the exogenous and endogenous models with their corresponding equations and
statistics side by side in a single table for easy comparison. nicely estimates the production
or cost efficiency and tests endogeneity, and reports them in the table
even if efficiency(effvar) or test options are not specified.

mldisplay(display_options) can be used to control the ml display
options; seldom used

Examples

Endogenous Panel Stochastic Cost Frontier Example

Setup

. use https://www.mukarakaplan.com/files/xtsfkkcost.dta, clear

. xtsfkk, version

. xtset id t

Panel stochastic cost model with endogenous frontier and uhet variables

. xtsfkk y x1 z1, cost u(z2) en(z1 z2) i(iv1 iv2) delve header timer beep

Examples of using iterate(#), initial(matname),
efficiency(effvar), beep(#) and test options

. xtsfkk y x1 z1, cost u(z2) en(z1 z2) i(iv1 iv2) iter(6) timer beep(3)

. matrix EST = e(b)

. xtsfkk y x1 z1, cost u(z2) en(z1 z2) i(iv1 iv2) init(EST) eff(costef) test beep(-1)

Note that in the examples above, beep(3) option results in 3 beeps once the output is displayed
and beep(-1) option results in continuous beeps that would not stop unless the user actively stops them.
Beep option is useful for multitasking so that the user would not need to view the Stata results
window until it starts beeping.

Examples of using compare and nicely options

. xtsfkk y x1 z1, cost u(z2) en(z1 z2) i(iv1 iv2) delve iter(15) compare beep

. xtsfkk y x1 z1, cost u(z2) en(z1 z2) i(iv1 iv2) compare nicely beep

Example of using noconstant option in the frontier

. xtsfkk y x1 z1, cost u(z2) en(z1 z2) i(iv1 iv2) nicely nocons

Endogenous Panel Stochastic Production Frontier Example

Setup

. use https://www.mukarakaplan.com/files/xtsfkkprod.dta, clear

. summ

. xtset firm year

Exogenous panel stochastic production model

. xtsfkk y x1 x2 x3 z1, prod u(z2)

Panel stochastic production model with endogenous frontier and uhet variables

. xtsfkk y x1 x2 x3 z1, prod u(z2) en(z1 z2) i(iv1 iv2) nicely header beep

Panel stochastic production model with an endogenous frontier variable and no uhet specification

. xtsfkk y x1 x2 x3 z1, en(z1) i(iv1) nicely header timer

Notice that when uhet is not specified in the example above, the results table shows that uhet
included a constant by default. Uhet can also be specified with a variable but no
constant such as uhet(z2, nocons) . Uhet specification would require at least one variable or the constant in uhet, and
specifying uhet( , nocons) to exclude uhet altogether from the model would give an error as the
inefficiency component is a necessary part of the model.

Examples of using the exogenous() and leaveout() options

. xtsfkk y x1 x2 x3 z1, u(z2) en(z1 z2) i(iv1 iv2) exogenous(x1 x3) header

. xtsfkk y x1 x2 x3 z1, u(z2) en(z1 z2) i(iv1 iv2) leave(x2) header

Note that the two examples above generate the same results.
exogenous() and leaveout() provide two different ways to specify
the list of included exogenous variables to be used. In these two models,
even though x2 is used as an independent variable in the frontier
equation, it is not used as an independent variable in the endogenous variable
equations (z1 and z2).

Examples of using difficult, and technique(algorithm_spec)

. xtsfkk y x1 x2 x3 z1, u(z2) en(z1 z2) i(iv1 iv2) diff compare nicely timer

. xtsfkk y x1 x2 x3 z1, u(z2) en(z1 z2) i(iv1 iv2) tech(nr 5 bfgs 10) compare nicely timer

Examples of using weight and factor variables

. gen count = 1

. replace count = 2 if y > 0.8

. tab count

. xtsfkk y x1 x2 x3 z1 [fweight = count], u(z2) en(z1 z2) i(iv1 iv2) nicely

. xtsfkk y x1 x2 x3 z1 i.year, u(z2) en(z1 z2) i(iv1 iv2) nicely compare diff

Example from the U.S. Banking Sector

Setup

. use https://www.mukarakaplan.com/files/xtsfkkbank.dta, clear

. xtset id year

. xtsfkk loans cdep hotm gta roe big, u(hhi) en(hhi) i(rep) iter(5) save(banks.est)

Note that in the example above, the estimation is intentially limited to 5 iterations. save option
saves the status of estimation in each iteration, and when the estimation stops, it records the status from
the last iteration. In the example below, the estimation loads the saved file and continues from where it was left. Note
that the model specifications are exactly the same. These two examples demostrate the usage of save and load
options.

. xtsfkk loans cdep hotm gta roe big, u(hhi) en(hhi) i(rep) header compare nicely timer beep(3) load(banks.est)

For details about the datasets and results, see Karakaplan (2020).

Stored Results

xtsfkk stores the following in e():

Scalars

e(effmed) median efficiency

e(effmean) mean efficiency

e(etatestX2) eta test chi-squared

e(etatestp) eta test p value

e(sigma_v) standard deviation of V_i

e(p) significance

e(chi2) chi-squared

e(df_m) model degrees of freedom

e(k_eq_model) number of equations in overall model test

e(ll) log likelihood

e(rc) return code

e(converged) 1 if converged, 0 otherwise

e(k_dv) number of dependent variables

e(k_eq) number of equations in e(b)

e(k) number of parameters

e(ic) number of iterations

e(N) number of observations

e(rank) rank of e(V)

Macros

e(_estimates_name) name of stored results

e(estimates_title) title of stored results

e(cmdbase) base command

e(cmd) name of user command

e(cmdline) command as typed

e(het) heteroskedastic components

e(function) production or cost

e(dist) distribution assumption for U_i

e(chi2type) type of model chi-squared test

e(opt) type of optimization

e(predict) program used to implement predict

e(u_hetvar) varlist in uhet()

e(vcetype) title used to label Std. Err.

e(vce) vcetype specified in vce()

e(title) title in estimation output

e(user) name of likelihood-evaluator program

e(ml_method) type of ml method

e(technique) maximization technique

e(which) max or min; whether optimizer is to perform
maximization or minimization

e(depvar) name of dependent variable(s)

e(properties) b V

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimators

e(ilog) iteration log (up to 20 iterations)

e(gradient) gradient vector

Functions

e(sample) marks estimation sample

xtsfkk stores the following in estimates memory:

Estimates

ModelEN stored estimates of endogenous model

ModelEX stored estimates of exogenous model if compare option is specified

Note that if compare option is specified, ereturn list
would list the results from the last specification, which is the exogenous model. In order to retrieve
the stored results from the endogenous model, estimates restore ModelEN can be used.

Program Author

Dr. Mustafa Ugur Karakaplan
E-mail: mukarakaplan@yahoo.com
Webpage: www.mukarakaplan.com

For comments, suggestions, or questions about xtsfkk, please send
an email to me.

Recommended Citations

The following citations are recommended for referring to the xtsfkk program package,
underlying econometric methodology, and examples:

+ Karakaplan, Mustafa U. (2022) "Panel Stochastic Frontier Models with Endogeneity."
Forthcoming. The Stata Journal.

+ Karakaplan, Mustafa U. (2018) "xtsfkk: Stata Module for Endogenous Panel Stochastic Frontier Models." Available at Boston College, Department of Economics, Statistical Software Components (SSC)
S458445

+ Karakaplan, Mustafa U. and Kutlu, Levent (2017) "Endogeneity in Panel Stochastic Frontier Models."
Applied Economics

More Recommended Citations

Karakaplan, Mustafa U. (2017) "Fitting Endogenous Stochastic Frontier Models in Stata."
The Stata Journal

Karakaplan, Mustafa U. and Kutlu, Levent (2017) "Handling Endogeneity in Stochastic Frontier Analysis."
Economics Bulletin

Karakaplan, Mustafa U. and Kutlu, Levent (2018) "School District Consolidation Policies: Endogenous Cost Inefficiency and Saving Reversals."
Empirical Economics

Kutlu, Levent (2010) "Battese–Coelli Estimator with Endogenous Regressors."
Economics Letters

Acknowledgments

I would like to thank Levent Kutlu, Hung-Jen Wang, Isabel Canette, Joerg Luedicke, Ben Jann, Jan Ditzen, Myk Milligan, Kit Baum, and an anonymous referee for their great support. I would also like to acknowledge that the Research Computing program under the Division of Information Technology at the University of South Carolina contributed to the results in this research by providing high performance computing resources and expertise.

Disclaimer

xtsfkk is not an official Stata command. It is a third-party command
programmed by Mustafa U. Karakaplan as a free contribution
to the research society. By choosing to download, install and use the xtsfkk package,
users assume all the liability for any xtsfkk package related risk. If you encounter
any problems with the xtsfkk package, or if you have comments, suggestions, or questions,
please send an email to Mustafa U. Karakaplan at
mukarakaplan@yahoo.com