*! Help file for flexmake.ado version 2.40, 12Sep2017

*! Help file version 1.4 dated 12Sep2017

Title

flexmake -- Utility to construct the transformed variables
and the factor variable lists necessary to estimate a flexible
(e.g. translog or Generalized Leontief) cost function

Syntax

flexmake
[depvar] [if] [in],
[options]

Options

Transformation options
trans Option to specify which of three possible transformations
to apply to the transformed variables. Only one transformation can be specified.
If none of these transformations is specified, the variables are not transformed.
The options are:

ln The natural logarithm transformation. Appropriate for
creating the transformed variables and the associated factor variable syntax
used to estimate a translog cost function.

log10 The common logarithm transformation. An alternative to the
natural logarithm for estimating a translog cost function, with the advantage that
the units of the transformed variables are decimal powers of the original variables.

sqrt The square root transformation. Appropriate for
creating the transformed variables and the associated factor variable syntax
used to estimate a Generalized Leontief cost function.

boxcox(lambda) Applies the boxcox transformation with parameter lambda
to the total cost variable and to the output variables.
Requires that either the ln or the log10
option also be specified and used to transform the factor price variables.
Appropriate for creating the transformed variables
and the associated factor variable syntax
used to estimate a Generalized Translog cost function.

Variables to be transformed
depvar For a cost function, this variable is the
total cost of production and is defined as the sum of expenditures on all factors of production.
Unless the nomake option is specified, omitting this variable requests
flexmake to construct it by adding the expenditures on all inputs.
(Factor and time-series variables not allowed)

outputs(varlist) Output variables (Maximum of 5).
If omitted (as in the examples below),
the depvar is assumed to be average
cost of a single output - or of a set of outputs produced in fixed proportions -
and the assumption of constant returns to scale is imposed.
(Factor and time-series variables not allowed)

prices(varlist) Factor price variables (Maximum of 10).
If the user does not specify these variables by using the prices(varlist) option,
flexmake will attempt to construct them from the other supplied variables.
(Factor and time-series variables not allowed)

Variables not transformed
inputs(varlist) Input quantities (Maximum of 10). Used as
dependent variables in generalized Leontief input demand functions or
to construct cost shares for use as dependent variables in translog
cost share equations.
If the user does not specify these variables by using the inputs(varlist) option,
flexmake will attempt to construct them from the other supplied variables.
(Factor and time-series variables not allowed)

incosts(varlist) Input costs or expenditures (Maximum of 10). Used to construct
cost shares for use as dependent variables in translog share equations.
If the user does not specify these variables by using the incosts(varlist) option,
flexmake will attempt to construct them from the other supplied variables.
(Factor and time-series variables not allowed)

shares(varlist) Input cost shares (Maximum of 10).
Used as dependent variables in translog share equations.
If the user does not specify these variables by using the shares(varlist) option,
flexmake will attempt to construct them from the other supplied variables.
(Factor and time-series variables not allowed)

othervars(varlist) List of other variables to be included
as exogenous variables on the right-hand-side of either the cost
or the factor demand equations. Flexmake only checks to see if these exist
and returns the variable list in the return space and, if
the globals option is specified, as a global macro. (Maximum of 10)
(	Factor and time-series variables are allowed)

Other options
tcname(newvarname) If flexmake is asked to create
the dependent variable, its default behavior is to name that variable tc.
This tcname(newvarname) option allows the user to specify an alternative
name for the created dependent variable.

innames(namelist) User-specified names of the inputs
to be used as suffixes in the creation of new variable names. By default,
flexmake constructs new variables by adding the approriate prefix
to these names. This option is required if the user provided variable lists
for prices, quantities, expenditures or costs do not use an underscore
character to separate the prefix from the input name.
See Example 1.

impvars(varlist) For two of the five argument combinations,
flexmake constructs the average factor price faced by
each firm in the sample by dividing that firm's total expenditure
on a factor input by the quantity it uses of that input.
(These are input options 2 and 5 as explained in the
Description section below.)
Since there is no input expenditure or input quantity for an unused input,
this quotient is undefined for a firm which does not use an input.
In this situation, flexmake's default behavior is to set the factor
price to a missing value. However, if the user specifies a set of
instrumental variables using the option impvars(varlist), flexmake uses
these variables to impute the price the firm would have faced, if it had
used that input. This option accepts the factor variable
syntax for specifying categorical variables and interactions. If you have
tsset your data, you may also include time-series operators
in this varlist. N.B.: flexmake does not impute the missing values
of any variables other than the input prices.

half Create a variable named "__half" defined as the constant
0.50 and include it in the factor variable expressions for subsequent use in
specifying the right-hand-side variables used to estimate the cost and
factor demand equations. This option
is only approriate for the translog options, ln, log10 and
boxcox.

one For any variable to be transformed which has non-positive values
in the sample, add the constant 1.0 before applying the transformation.
This option prevents the natural and common logarithm transformations,
specified by ln or log10, from creating missing
values for observations containing zeros. An alternative strategy for preventing
the exclusion of these observations during estimation would be to specify the
square root or the Box-Cox transformation
(i.e. the option sqrt or boxcox(lambda)).

globals Specifies that flexmake return its results not only
as volatile local macros in the stored results space, but also as
global macros.

replace The created transformed variables with prefixs ln_,
sqrt_, log10_ or bc_
will replace any variables of the same name that are currently in the data. Also
allows the replacement of other created variables such as total cost or factor prices

double Generated variables will be of type double.
Default is type float.

nomake Suppress flexmake's first step, which by default
is to construct an internally consistent set of cost variables from the minimal set
of variables provided by the user. With option nomake selected,
flexmake still performs its other functions,
viz. to generate transformormations of the provided input price and output variables
and also to construct Stata macros which facilitate specification
of the estimating equation(s).

Description

flexmake is a utility to assist in preparing for and estimating
flexible cost functions that are linear in the parameters, but potentially
non-linear in the variables. Examples are the translog and the
Generalized Leontief function.

Suppose that data are available on the total amount of output(s) produced in a year
by each of a sample of productive "decision-making units" (or "DMUs")
and also on each DMU's expenditure on each of the inputs or input categories
that constitute its factors of production.
A cost function is a function relating the total cost of producing a set of outputs
to the quantities produced and to the prices paid for the inputs.
A flexible cost function is one that can be characterized as a second-order
approximation to an arbitrary cost function.
Preparing to estimate a flexible cost function typically requires,
first, constructing an internally consistent data set
on a sample of productive "decision-making units"
(or "DMUs")and then transforming this data by applying one of several
non-linear transformations.
flexmake is intended to help with both of these
preparatory steps and then facilitate the specification of the estimating
equations.

Assuring internal consistency.
Internally consistent cost data consists of a set of variables for each DMU
which capture, for a specified time interval such as a year,
the quantity used of each of several factors of production,
the DMU's expenditure on each factor, the total cost of production to the DMU,
the share of each input's cost in total cost and the average price of each factor.
Each observation (or row) of the data matrix contains these variables
for a single DMU in a single time period.
Except in the special case of constant returns to scale
(illustrated in the examples below), estimating
a cost function also requires data on the the quantity of the output(s)
produced by each DMU in the same period.
Accounting relationships link the input and cost variables so that, for example,
knowing the quantities used of each factor and its average price allows
the construction of all the other expenditure on each input, total expenditure
and the expenditure shares. By default, flexmake's first function is to exploit
these accounting identities in order to construct an internally consistent
minimal set of cost and input variables. (The user can skip this first step
by specifying the nomake option.)

Since a user cannot always choose how cost data is supplied,
flexmake allows the user to choose one of five combinations
of arguments from which it will construct the rest of the input and cost
data. These options are:

1.	Only factor prices and input quantities (Options:prices(varlist) and
inputs(varlist))

2.	Only input costs and input quantities (Options:incosts(varlist) and
inputs(varlist))

3.	Only input costs and input prices (Options:incosts(varlist) and
prices(varlist))

4.	Total cost, input shares and input prices (Options:depvar, shares(varlist) and
prices(varlist))

5.	Total cost, input shares and input quantities (Options:depvar, shares(varlist) and
inputs(varlist))

If the user specifies a combination of data inputs different from one of the
above five options, flexmake will stop with an error, unless the user
has specified the nomake option. If the received
data contains more of these variables than the minimum necessary to construct
an internally consistent set of cost data, the user can experiment to see
which subset of the variables is most consistent. The two options that
leave the construction of factor prices (or factor price indices) to flexmake
are options 2 and 5. When some factors of production are unused by some DMUs,
these two options will generate missing values for the average price of those factors
faced by those DMUs. Since in theory any DMU could, at a sufficiently high price,
obtain any factor, missing values of factor prices are logically unsatisfying.
flexmake offers the option impvars(varlist),
which allows the courageous user to impute the factor prices faced by DMUs that
don't use a factor of production. It's the user's responsibility to
propose variables (e.g. geographic designations) which might plausibly
provide information on the unobserved factor price. The less heroic user
might omit the impvars(varlist) option, thus allowing flexmake
to generate missing values for the prices of unused factors and then
use Stata's mi impute suite of commands to estimate the cost structure
by multiple imputation.

Applying data transformations.
While applying a non-linear transformation to data is computationally trivial,
it is convenient to automate the process immediately prior to estimation
in order to avoid the proliferation of variables and assure that changes to
the raw data are immediately and automatically reflected in the
transformed data. Furthermore, after generating and naming the transformed variables,
flexmake can then construct the approriate factor variable expressions
used in the estimation step.

The logarithmic transformation (option ln) prepares the data for estimating
a translog or Cobb-Douglas flexible form.
The square-root transformation (option sqrt) prepares the data for estimating
the Generalized Leontief flexible form. By choosing the boxcox(lambda)
transformation, the user can approximate a translog estimation while accommodating
zeros in the input data. An alternative to the natural logarithmic transformation
is the common logarithmic tranformation (option log10),
which may be convenient for some purposes.
Because data preparation and edits are best applied to the raw data, using flexmake
allows the data transformations to be easily applied immediately before
estimation, making code more readable, results more reproducible and reducing
the chance that the user estimates the cost function on obsolete data.
The names of the created transformed variables are constructed by prepending the
prefix "ln_", "log10_" or "sqrt_" for those transformations or "bc_" for the boxcox
transformation.

Specifying the estimating equation.
flexmake's ultimate purpose is to construct the factor variables
expressions for subsequent use in specifying the command line when estimating
the cost function with the specified functional form. The user can then retrieve
these expressions from flexmake's stored results and
use them for post-estimation analysis, such as computing elasticities.

Discussion

flexmake is one of a suite of programs designed to facilitate the
estimation and interpretation of multiple output cost functions.
Other programs in the collection can be found from within Stata by clicking
here
or by typing into Stata's command window the following command:

view net from http://digital.cgdev.org/doc/stata/MO/flexcost

Cost functions are relationships between the total cost of production
and a set of determinants which include the amounts of output and the prices
of factor inputs, such as the wage rate for each distinct staff category,
the rental rate of buildings and equipment, the unit price of purchased inputs such as
electricity and gasoline, etc.. A cost function, unlike a production function,
does not typically include the amounts of factor inputs among its determinants
since those are assumed to be chosen as a function of factor prices.

Cost functions are inherently non-linear. For estimation
purposes, non-linear functions can be distinguished according to whether they are
linear in the parameters. For example, specifying a cost function as a
relationship between the natural logarithm of total cost and a quadratic
function of output and prices would allow estimation of the following relationship:

ln_tc = a + b*z + c*z^2 + d*w + f*w^2 + e

where ln_tc = log(total cost), z is output, w is the wage rate and e is an error.
While the above function specifies a nonlinear relationship
between total cost (tc) and the two right-hand-side variables,
output (z) and wage (w),
the function is linear in the parameters a, b, c, d and f.
Therefore, the parameters can be estimated by ordinary least squares
(using regress) and other linear estimators, including instrumental variable
estimators (e.g. ivreg, stochastic frontier estimators (e.g. sf,
panel estimators (e.g. xtreg and xtivreg)
and seemingly unrelated regression estimaors (e.g. sureg).

When a large number of observations are available
and the output, price and other right-hand-side variables
are only weakly correlated with one another, the analyst can select a functional form
to represent the cost function without concern for whether it is linear in
the parameters. Functions nonlinear in the paramters can be estimated with
nonlinear estimation routines such as Stata's nl, nlsur and
gmm commands.

However, the data sets available for estimating cost-functions are frequently small
and suffer from substantial multi-collinearity among right-hand-side variables.
In these circumstances, ordinary least squares and other linear estimation
algorithms will typically produce more robust estimates. In view of this
computational advantage of functional forms linear in the parameters,
researchers have developed a portfolio of so-called "flexible" functional forms.
The concept of "flexibility" in this case means that, despite being linear
in the estimated parameters and thus more computationally tractable, these
functions can approximate any non-linear function.

Flexible functional forms are designed to enable ordinary least squares
estimation of a realistic non-linear empirical production technology.
Their claim to approximate any arbitrary production structure is based
on their derivation as a Taylor series approximation of a general function.
They achieve flexibility by including interaction terms and quadratic terms
among the right-hand-side variables.

A cost function that is linear in the parameters but includes
non-linear terms in the right-hand-side variables
can be estimated by specifying the right-hand-side variables
using Stata's factor variables syntax.
Doing so has two advantages. First, use of the factor variable
avoids the proliferation in the user's data set of variables
which are functions of other variables.
Second, using factor variables enables
Stata's margins command to compute point estimates,
standard errors and confidence limits for parameters like
elasticities that are functions of both the data and the
estimated parameters. (See Baum (2010) for a tip on using
the margins command to compute elasticities for a linear
functional form.)

Stata can estimate a flexible cost function in various ways.
For example, the approach suggested by Baum and Linz (2009)
requires the user to compute not only the log-transformation of
the dependent and all the right-hand-side variables, but also
to create a new variable for each of the interaction
and quadratic terms in the model. For a cost function
with five factor prices and one output,
their approach requires the creation of 27 variables and the
estimation of 49 parameters.

By using Stata's factor variable syntax
to specify the interaction and quadratic terms,
the user can avoid cluttering the work space with unnecessary variables
and the computation of many post-estimation results is greatly simplified.
This discussion presents this factor variable strategy for specifying
and estimating a flexible cost function and demonstrates the role
of this program, flexmake, in facilitating the implementation
of this strategy. As an example, for the problem presented in Baum and Linz (2009),
the user would provide the untransformed data from which
flexmake would create only five variables and would return
to the user macros which give the factor variable
syntax to estimate all 49 parameters.

The most commonly used flexible functional form
is the translog function. The translog flexible cost function
includes as right-hand-side variables a quadratic function of
the logarithms of the factor prices and outputs.
Omitting the output terms for ease of exposition,
the part of a translog cost function
with two factor prices, w1 and w2, can be written:

ln_TC = A + B1*ln_w1 + B2*ln_w2 + B12*ln_w1_ln_w2 + C1*ln_w1_2 + C2*lnw2_2

where the variables ln_TC, ln_w1, ln_w2, ln_w1_ln_w2, ln_w1_2
and ln_w2_2 are defined and must be individually generated by:

gen ln_TC = ln(TC)

gen ln_w1 = ln(w1)

gen ln_w2 = ln(w2)

gen ln_w1_ln_w2 = ln_w1*ln_w2

gen ln_w1_2 = ln_w1*ln_w1

gen ln_w2_2 = ln_w2*ln_w2

As an example of the post-estimation analysis useful to interpret a translog cost function,
the elasticity of total cost (TC) with respect to one of the two factor prices, say w1, is
defined as the derivative of the log of TC with respect to the log of w1, which is
given by:

B1 + B12*ln_w2 + 2*C1*ln_w1

and is a function of both w1 and w2. To estimate this elasticity, we first
issue the estimation command (where again the factor price variables are omitted
for ease of exposition):

reg ln_TC ln_w1 ln_w2 ln_w1_ln_w2 ln_w1_2 lnw2_2

Then one can compute the elasticity at any point in the data by issuing the following
generate command:

gen elast_TC_wrt_w1 = _b[ln_w1] + _b[ln_w1_ln_w2]*ln_w2 + 2*_b[ln_w1_2]*ln_w1

The mean of the elasticity in the sample could then be computed with the
summarize command:

summarize elast_TC_wrt_w1

Or one could first compute the means of the variables ln_w1 and ln_w2 and compute
an estimate of elasticity at this point in the sample space as follows:

summarize ln_w1, meanonly

scalar mean_ln_w1 = `r(mean)'

summarize ln_w2, meanonly

scalar mean_ln_w2 = `r(mean)'

scalar elast_TC_wrt_w1 = _b[ln_w1] + _b[ln_w1_ln_w2]*mean_ln_w2 + 2*_b[ln_w1_2]*mean_ln_w1

di elast_TC_wrt_w1

Further code would be required to estimate the standard error
and confidence interval of any of these estimates of the elasticity.

In contrast, by exploiting Stata's factor variable functionality, the computation of both the
elasticity of cost with respect to price and its standard error can be remarkably simplified.
First the estimation would use only the variables ln_w1 and ln_w2 as follows:

reg ln_TC ln_w1 ln_w2 c.ln_w1#c.ln_w2 c.ln_w1#c.ln_w1 c.lnw2#c.ln_w2

Subsequently the estimated elasticity at the mean values of the right-hand-side variables and it's
standard error can both be estimated by issuing the command:

margins, dydx(ln_w1)

By automating the process of generating all of the
logarithmic transformations,
flexmake relieves the user of the task of generating the logarithmic
or other transformations of the data prior to estimation.
In addition to constructing the transformations, flexmake also formulates the factor variable
expressions to be used to specify the command line of the estimation command.
By default it stores these factor variable lists as stored results.
(See the list of stored results below.) Optionally, by specifying the globals
option, flexmake also stores these lists of factor variable terms as
global macros which are less volatile than stored results
and thus can be used throughout a subsequent set of commands
to specify the estimating equations or functions of the parameters.

Examples

The following examples use data on firm-level costs of manufacturing production
which originally was distributed by Greene (1997, section 15.6).
Before running any of the following examples,

click here

<output omitted>

After loading the data and changing the names of the price variables to conform
to flexmake's preferred syntax, the flexmake command is executed
and produces the following output:

. flexmake cost, ln prices(p_*) shares(s_*) globals half

Generate exp_k = s_k * tc
Generate exp_l = s_l * tc
Generate exp_e = s_e * tc
Generate exp_m = s_m * tc
Generate q_k = exp_k / p_k
Generate q_l = exp_l / p_l
Generate q_e = exp_e / p_e
Generate q_m = exp_m / p_m

Variables transformed by the function: ln

Transformation of the original variables

Cost- Number of Generated Number of Transformed
Function obs. <=0 Transformed Observations which are:
Variable or missing Variable < 0 = 0 >=.
======== ========== ======== ==== ==== ======
1 cost 0 ln_cost 0 0 0
2 p_k 0 ln_p_k 4 1 0
3 p_l 0 ln_p_l 0 1 0
4 p_e 0 ln_p_e 0 1 0
5 p_m 0 ln_p_m 0 1 0

flexmake's major contribution is to automatically create all the pieces of the
cost-function syntax. These syntax chunks are listed by Stata's
return list command as follows:

. return list

macros:

r(innames) : "k l e m"
r(inputs) : "q_k q_l q_e q_m"
r(incosts) : "exp_k exp_l exp_e exp_m"
r(prices) : "p_k p_l p_e p_m"
r(shares) : "s_k s_l s_e s_m"
r(argtype) : "totcost_shares_prices"
r(argmissing) : "incosts_inputs"
r(transvars) : "ln_cost ln_p_k ln_p_l ln_p_e ln_p_m"
r(transrhsvars) : "ln_p_k ln_p_l ln_p_e ln_p_m"
r(depvar) : "ln_cost"
r(tcname) : "cost"
r(crossprices) : "c.ln_p_k#c.ln_p_l c.ln_p_k#c.ln_p_e c.ln_p_k#c.ln_p_m c.ln_p_l#c.ln_p_.."
r(ownprices2) : "c.ln_p_k#c.ln_p_k#c.__half c.ln_p_l#c.ln_p_l#c.__half c.ln_p_e#c.ln_p_.."
r(ownprices) : "ln_p_k ln_p_l ln_p_e ln_p_m"
r(transprices) : "ln_p_k ln_p_l ln_p_e ln_p_m"

If the data had included output variables, and the outputs(varlist) option
had been specified in the flexmake command, additional return macros
would have specified the quadratic terms in the outputs and their interactions
with the prices.

. * Flexmake complements the provided data with the implied expenditure totals and input quantities.

. describe

<output omitted>

. summarize

<output omitted>

When the variables for total cost, factor prices and cost shares are provided to
flexmake, the program completes the cost data for each
observation in the data by computing the implied quantity of, and expenditure on,
each factor. The user is responsible for ordering the variables
in the same order in all the options that are factor specific; here this includes
the options prices(varlist) and shares(varlist).

Example 1. Estimate the system of cost share equations

Because the globals option was specified, the returned results listed above are also
stored as global macros. The following regression command uses
these macros to estimate the translog cost share equations with Stata's routine
for the estimation of seemingly unrelated regressions, sureg.

. * First, specify cross-equation constraints consistent with cost minimization.

Constraints imposing symmetry on the factor demand equations:

. constraint 1 _b[s_k:c.ln_p_l] = _b[s_l:c.ln_p_k]

. constraint 2 _b[s_k:c.ln_p_e] = _b[s_e:c.ln_p_k]

. constraint 3 _b[s_l:c.ln_p_e] = _b[s_e:c.ln_p_l]

Constraints imposing homogeneity of degree zero in prices on the factor demand equations:

. constraint 4 _b[s_k:c.ln_p_k] + _b[s_k:c.ln_p_l] + _b[s_k:c.ln_p_e] + _b[s_k:c.ln_p_m] = 0

. constraint 5 _b[s_l:c.ln_p_k] + _b[s_l:c.ln_p_l] + _b[s_l:c.ln_p_e] + _b[s_l:c.ln_p_m] = 0

. constraint 6 _b[s_e:c.ln_p_k] + _b[s_e:c.ln_p_l] + _b[s_e:c.ln_p_e] + _b[s_e:c.ln_p_m] = 0

sureg (s_k $ownprices ) (s_l $ownprices ) (s_e $ownprices ), constraints(1-6) isure

<output omitted>

To execute the above commands and estimate the cost function parameters
jointly with the three share equations,

click here.

Compare these results to those obtained for the same model and data using Stata's nlsur
command which are reported in the Stata manual entry for nlsur cited
below.

Example 2. Estimate the cost function jointly with cost share equations

More statistical power for estimating these parameters can be achieved
by including the cost function with the share equations and imposing additional
constraints. However, because the data on the Stata web site, originally from Greene (1997),
does not include an output variable, we must omit the level of output from the
right-hand-sides of the cost and the share equations. Essentially we must
assume that the cost variable is an average cost for a single unit of output
and impose the hypothesis of constant returns to scale.

Estimation now requires imposing 19 constraints as follows:

. constraint 1 _b[s_k:c.ln_p_l] = _b[s_l:c.ln_p_k]

. constraint 2 _b[s_k:c.ln_p_e] = _b[s_e:c.ln_p_k]

. constraint 3 _b[s_l:c.ln_p_e] = _b[s_e:c.ln_p_l]- _b[s_k:c.ln_p_e]

. constraint 4 _b[s_k:c.ln_p_k] + _b[s_k:c.ln_p_l] + _b[s_k:c.ln_p_e] + _b[s_k:c.ln_p_m] = 0

. constraint 5 _b[s_l:c.ln_p_k] + _b[s_l:c.ln_p_l] + _b[s_l:c.ln_p_e] + _b[s_l:c.ln_p_m] = 0

. constraint 6 _b[s_e:c.ln_p_k] + _b[s_e:c.ln_p_l] + _b[s_e:c.ln_p_e] + _b[s_e:c.ln_p_m] = 0

. constraint 7 _b[ln_cost:c.ln_p_k] = _b[s_k:_cons]

. constraint 8 _b[ln_cost:c.ln_p_l] = _b[s_l:_cons]

. constraint 9 _b[ln_cost:c.ln_p_e] = _b[s_e:_cons]

. constraint 10 _b[ln_cost:c.ln_p_k] + _b[ln_cost:c.ln_p_l] + _b[ln_cost:c.ln_p_e] + _b[ln_cost:c.ln_p_m] = 1.0

. constraint 11 _b[ln_cost:c.ln_p_k#c.ln_p_k#c.__half] = _b[s_k:c.ln_p_k]

. constraint 12 _b[ln_cost:c.ln_p_l#c.ln_p_l#c.__half] = _b[s_l:c.ln_p_l]

. constraint 13 _b[ln_cost:c.ln_p_e#c.ln_p_e#c.__half] = _b[s_e:c.ln_p_e]

. constraint 14 _b[ln_cost:c.ln_p_k#c.ln_p_l] = _b[s_k:c.ln_p_l]

. constraint 15 _b[ln_cost:c.ln_p_k#c.ln_p_e] = _b[s_k:c.ln_p_e]

. constraint 16 _b[ln_cost:c.ln_p_k#c.ln_p_m] = _b[s_k:c.ln_p_m]

. constraint 17 _b[ln_cost:c.ln_p_l#c.ln_p_e] = _b[s_l:c.ln_p_e]

. constraint 18 _b[ln_cost:c.ln_p_l#c.ln_p_m] = _b[s_l:c.ln_p_m]

. constraint 19 _b[ln_cost:c.ln_p_e#c.ln_p_m] = _b[s_e:c.ln_p_m]

. sureg (ln_cost $ownprices $ownprices2 $crossprices) (s_k $ownprices ) (s_l $ownprices ) (s_e $ownprices ), constraints(1-18) isure

<output omitted>

. est store withcost

To estimate the cost function jointly with the share equations:

click here

Example 3. Compare estimates with and without cost function

To compare the two estimates using Stata's estimates table command,

click here

after estimating
both of the above models. Note that the two sets of parameter estimates
are very different, suggesting that the assumption
of constant returns to scale is untenable.

Example 4.

Using margins, we can compute the Allan-Uzawa elasticity
of the demand for capital with respect to its own price
(i.e. the own-elasticity of demand).
If we assume that the mean share of capital
estimated from the sample mean is a known, fixed paramter
the following commands compute the estimated elasticity.

summ s_k

scalar kmean=r(mean)

margins , expression((_b[s_k:ln_p_k] + kmean * (kmean-1))/kmean) atmeans

click here to execute them.

Compare the above result to that presented in
Remarks and Examples
section of the nlsur postestimation section of Stata Reference Manual.

Example 5.

The above estimate of capital's own-price elasticity of demand
assumes that the mean of the capital share is a known constant.
This is clearly a false assumption, since the mean capital share is a sample statistic.
The margins command allows us to replace the sample mean by its predicted value
in order to allow the forecast error of the mean capital share to affect the
estimated value and standard deviation of capital's own-elasticity of demand.
The following command implements this more legitimate approach to estimating
the elasticity of demand for capital.

margins , expression((_b[s_k:ln_pk] + predict(xb equation(s_k)) * (predict(xb equation(s_k))-1))/predict(xb equation(s_k))) atmeans

To observe Stata computing this second estimate of the own-elasticity of
the demand for capital,
click here.

The companion post-estimation program flexelasticity, if installed,
offers a shortcut to computing the elasticities from a previously estimated
flexible cost function. For example, to compute the own-price elasticity
of demand for capital one can type:

To try flexelasticity for this computation,
click here.

Stored Results

flexmake first constructs the missing raw variables from those provided.
That is, if total cost and the input quantities and prices are provided,
flexmake constructs the factor shares to be used as dependent variables
in estimating a system of factor demand or factor share equations.
If, on the other hand, the shares and the input quantities are provided,
flexmake constructs the factor prices.

For each variable to be transformed, var, flexmake creates a transformed
variable with the name trans_var, where trans is one of the options
ln|log10|sqrt|bc.

In stored results flexmake stores the following macros:

r(innames) List of the "names" of the inputs, which are typically one
or two-letter abreviations or acronyms. These input "names" are not variables,
but each is part of the name of the corresponding input quantity, price, expenditure and
expenditure share variable.

If the variable measuring total cost is specifed as depvar:

r(depvar) The variable containing the total cost of production in this time period

Unless nomake is specified:

r(argtype) The types of variables supplied by the user.

r(argmissing) The types of variables to be generated by flexmake.

Lists of the user-supplied and flexmake-generated raw variables including:

r(inputs) List of the input quantities, typically formed by prefixing
one of the input names specified in innames(string) with the characters "q_".

r(incosts) List of the input costs or expendtures, typically formed by prefixing
one of the input names specified in innames(string) with the characters "exp_".

r(shares) List of the input cost (or expendture) shares, typically formed by prefixing
one of the input names specified in innames(string) with the characters "sh_".

If the prices(varlist) option is specified:

r(prices) List of the original price variables

r(transprices) List of the created transformed price variables, with prefixes indicating the transformation.

r(ownprices) List of the created transformed price variables, using factor variable syntax

r(ownprices2) List of the squares of the transformed price variables, using factor variable syntax

r(crossprices) List of the interactions between pairs of transformed prices, using factor variable syntax

If the outputs(varlist) option is specified:

r(outputs) List of the original output variables

r(transoutputs) List of the created transformed output variables, with prefixes indicating the transformation.

r(ownoutputs) List of the created transformed output variables, using factor variable syntax

r(ownoutputs2) List of the squares of the transformed output variables, using factor variable syntax

r(crossoutputs) List of the interactions between pairs of transformed outputs, using factor variable syntax

r(outputsxprices) List of the interactions between pairs of transformed outputs and prices, using factor variable syntax

r(transvars) List of all transformed variables

r(transrhsvars) List of all transformed right-hand-side variables

In addition, if the option globals is specified,
flexmake stores the above information in global macros of the same name.

References

Baum, C. and T. Linz (2009) "Evaluating concavity for production and cost functions,"
Stata Journal, 9-1, pp. 161–165.

Baum, C. (2010) "Stata tip 88: Efficiently evaluating elasticities with the margins command,"
Stata Journal, 10-2, pp. 309–312.

Greene, W. H. (1997) Econometric Analysis. 3rd ed. Upper Saddle River, NJ: Prentice Hall.

------ 2017. Econometric Analysis. 8th ed. Upper Saddle River, NJ: Prentice Hall.

Meyer-Rath, G. and M. Over (2012) "HIV Treatment as Prevention:
Modelling the Cost of Antiretroviral Treatment —
State of the Art and Future Directions". PLoS Med 9(7): e1001247.
doi:10.1371/journal.pmed.1001247

StataCorp. (2015) "Entry on -nlsur-, Example 2: Interactive version using
iterative FGNLS estimator—the translog production function",
Reference Manual,
Stata Statistical Software: Release 14. College Station, TX: StataCorp LP.

StataCorp. (2015) Data set mfgcost.dta. Accessed
by typing: - use http://www.stata-press.com/data/r14/mfgcost -.

Wiens, E.G. (Accessed 10/30/16)
"Egwald Economics: Cost Functions",
Web page.

Author

Mead Over at:
Email: MOver@CGDev.Org if you observe any
problems.