Description Usage Arguments Details Value Author(s) References See Also Examples
Estimate a ConstantElasticityofSubstitution (CES) function
with two exogenous variables
or a nested ConstantElasticityofSubstitution (CES) function
proposed by Sato (1967) with three or four exogenous variables
by Least Squares.
The functional forms are shown in the documentation of
function cesCalc
.
Warning: The econometric estimation of a CES function is (almost) always very problematic, because very different parameter vectors could result in very similar values of the objective function (sum of squared residuals). Hence, even if the optimizer reports that the nonlinear minimization has converged, there might be another rather different parameter vector that results in a lower sum of squared residuals.
1 2 3 4 5 6 7 8 9 10  cesEst( yName, xNames, data, tName = NULL, vrs = FALSE, method = "LM",
start = NULL, lower = NULL, upper = NULL, multErr = FALSE,
rho1 = NULL, rho2, rho = NULL, returnGridAll = FALSE, random.seed = 123,
rhoApprox = c( y = 5e6, gamma = 5e6, delta = 5e6,
rho = 1e3, nu = 5e6 ),
... )
## S3 method for class 'cesEst'
print( x, digits = max(3, getOption("digits")  3),
... )

yName 
a string containing the name of the dependent variable. 
xNames 
a vector of two, three or four character strings containing the names of the independent variables. 
data 
data frame containing the data. 
tName 
optional character string specifying the name of the time variable (t). 
vrs 
logical. Allow for variable returns to scale? 
method 
character string indicationg the estimation method:
either 
start 
optional numeric vector giving the starting values of the parameters in the nonlinear estimations (see section ‘Details’). 
lower 
lower bounds of the parameters (see section ‘Details’). 
upper 
upper bounds of the parameters (see section ‘Details’). 
multErr 
logical. If 
rho1,rho2,rho 
numeric scalar or vector at which the coefficients
rho_1, rho_2, and/or rho
should be fixed;
if argument 
returnGridAll 
logical value that indicates
whether the estimates for all values of rho
obtained during the grid search
(not just the estimations with the ‘best’ rho)
should be returned
(ignored if argument 
random.seed 
an integer used to seed R's random number generator.
This is to ensure replicability when the 
rhoApprox 
numeric vector with exactly 5 elements;
the endogenous variable of the CES
and the derivatives with respect to its coefficients
are calculated using a firstorder Taylor series approximation
at rho = 0 (nonnested CES)
or by interpolation between rho, rho_1,
or rho_2 equal to zero
and rho, rho_1, or rho_2
equal to +/ 
x 
an object of class 
digits 
number of digits. 
... 
further arguments to 
Estimation method
Argument method
determines the estimation method.
If it is "Kmenta"
,
the CES is estimated by ordinary least squares using the Kmenta
approximation;
otherwise, it is estimated by nonlinear leastsquares.
Several different optimizers can be used for the nonlinear estimation.
The optimization method
LM
(LevenbergMarquardt, see Moré 1978)
uses nls.lm
for the optimization.
The optimization methods
NM
or NelderMead
(Nelder and Mead 1965),
BFGS
(Broyden 1970, Fletcher 1970, Goldfarb 1970, Shanno 1970),
CG
(Conjugate Gradients based on Fletcher and Reeves 1964),
LBFGSB
(with boxconstraints, Byrd, Lu, Nocedal, and Zhu 1995), and
SANN
(Simulated Annealing, Bélisle 1992)
use optim
for the optimization.
The optimization method
Newton
(Newtontype, see Dennis and Schnabel 1983
and Schnabel, Koontz, and Weiss 1985)
uses nlm
for the optimization.
The optimization method
PORT
(PORT routines, see Gay 1990)
uses nlminb
for the optimization.
The optimization method
DE
(Differential Evolution, see Storn and Price 1997)
uses DEoptim
for the optimization.
Analytical gradients are used in the LM
, BFGS
, CG
,
LBFGSB
, Newton
, and PORT
method.
Starting values
Argument start
should be a numeric vector.
The order must be as described in the documentation of argument coef
of function cesCalc
.
However, names of the elements are ignored.
If argument start
is NULL
,
predefined starting values are used.
The starting value of lambda (if present) is set to 0.015;
the starting values of delta_1, delta_2,
and delta (if present) are set to 0.5,
the starting values of rho_1, rho_2, and
rho (if present and required) are set to 0.25
(i.e.\ elasticity of substitution = 0.8 in the twoinput case),
the starting value of nu (if present) is set to 1,
and the starting value of gamma
is set to a value
so that the mean of the error term is zero.
Hence, in case of an additive error term
(i.e. argument multErr
is set to FALSE
, the default)
gamma is set to
mean( y ) / mean( CES( X, start1 ) )
and in case of a multiplicative error term
(i.e. argument multErr
is set to TRUE
)
gamma is set to
mean( log( y ) )  mean( log( CES( X, start1 ) ) )
,
where y
is the dependent variable (defined by argument yName
),
X
is the set of covariates
(defined by arguments xNames
and tName
),
CES()
defines the (nested) CES function,
and start1
is a coefficient vector
with gamma = 1 and all other coefficients
having the starting values described above.
Lower and upper bounds
Arguments lower
and upper
can be used
to set lower and upper bounds for the estimated parameters.
If these arguments are Inf
and Inf
, respectively,
the parameters are estimated without unconstraints.
By default, arguments lower
and upper
are both NULL
,
which means that the bounds are set automatically
depending on the estimation method:
In case of the LBFGSB
, PORT
, and DE
method,
the lower bound is 0
for gamma,
delta_1, delta_2,
and delta (if present),
1
for rho_1, rho_2, and rho
(if present),
and eventually 0
for nu.
In case of the LBFGSB
and PORT
method,
the upper bound is infinity for gamma,
1
for delta_1, delta_2, and
delta (if present),
infinity for rho_1, rho_2, and rho
(if present),
and eventually infinity for nu.
Since the ‘Differential Evulation’ algorithm requires finit bounds,
the upper bounds for the DE
method are set
to 1e10
for gamma,
1
for delta_1, delta_2, and
delta (if present),
10
for rho_1, rho_2, and rho
(if present),
and eventually 10
for nu.
In case of all other estimation methods,
the lower and upper bounds are set to Inf
and Inf
, respectively,
because these methods do not support parameter constraints.
Of course, the user can specify own lower and upper bounds
by setting arguments lower
and upper
to numeric vectors
that should have the same format as argument start
(see above).
Grid search for rho
If arguments rho1
, rho2
, and/or rho
have more than one element,
a onedimensional, twodimensional, or threedimensionsl grid search
for rho_1, rho_2, and/or rho is performed.
The remaining (free) parameters of the CES are estimated by leastsquares,
where rho_1, rho_2, and/or rho are fixed
consecutively at each value defined in arguments rho1
, rho2
,
and rho
, respectively.
Finally the estimation with the rho_1, rho_2,
and/or rho
that results in the smallest sum of squared residuals is chosen
(and returned).
Random numbers
The ‘state’ (or ‘seed’) of R's random number generator
is saved at the beginning of the cesEst
function
and restored at the end of this function
so that this function does not affect the generation of random numbers
although the random seed is set to argument random.seed
and the ‘SANN’ and ‘DE’ algorithms use random numbers.
cesEst
returns a list of class cesEst
that has following components:
coefficients 
estimated coefficients/parameters of the CES (including a possible fixed rho). 
ela 
constant elasticity/elasticities of substitution. 
iter 
number of iterations (only for nonlinear leastsquares estimations). 
convergence 
logical value indicating if the nonlinear estimation has converged (only for nonlinear leastsquares estimations with solvers that have a convergence criterion). 
message 
additional information from the optimizer
(only if a message was returned by 
vcov 
approximate covariance matrix of the estimated parameters
calculated from the parameters of the linearized model by the Delta method
(only if argument 
cov.unscaled 
unscaled covariance matrix of the estimated parameters (including a possible fixed rho), i.e. the inverse of the crossproduct of the gradient matrix evaluated at the estimated parameters. 
fitted.values 
the fitted values (yHat). 
residuals 
the residuals
(i.e. y  yHat
if argument 
rss 
the sum of the squared residuals (i.e. the value of the objective function of the nonlinear leastsquares estimation evaluated at the estimated parameters). 
call 
the matched call. 
method 
argument 
multErr 
argument 
start 
starting values for the nonlinear estimation
(not for the 
lower 
lower bounds of the parameters. 
upper 
upper bounds of the parameters. 
rho 
argument 
nls.lm 
object returned by 
optim 
object returned by 
nlm 
object returned by 
nlminb 
object returned by 
DEoptim 
object returned by 
translog 
estimation results of the (unrestricted) translog model
returned by 
kmenta 
estimation results of the Kmenta approximation
(a restricted translog model)
returned by 
testKmenta 
test of the restrictions implied
by the Kmenta approximation
(including constant returns to scale
if argument 
allRhoSum 
data frame with summary results of the estimations
with all values of rho used in the grid search
(only if a grid search was performed);
this data frame has follwing columns:

allRhoFull 
list of estimation results returned by 
rho1Values,rho2Values,rhoValues 
numeric vectors giving the values that are used in the grid search for the coefficients rho_1 and rho, respectively (only if a grid search was performed). 
rssArray 
matrix or array of the RSS values obtained by a twodimensional or threedimensional grid search for the coefficients rho_1 (first dimension, e.g. rows of a matrix), rho_2, and rho (last dimension, e.g. columns of a matrix) (only if a twodimensional or threedimensional grid search was performed). 
Arne Henningsen and Geraldine Henningsen
Bélisle, C.J.P. (1992): Convergence theorems for a class of simulated annealing algorithms on Rd, Journal of Applied Probability 29, p. 885895.
Broyden, C.G. (1970): The Convergence of a Class of Doublerank Minimization Algorithms, Journal of the Institute of Mathematics and Its Applications 6, p. 7690.
Byrd, R.H., Lu, P., Nocedal, J. and Zhu, C. (1995): A limited memory algorithm for bound constrained optimization, SIAM J. Scientific Computing 16, p. 11901208.
Dennis, J.E. and Schnabel, R.B. (1983): Numerical Methods for Unconstrained Optimization and Nonlinear Equations, PrenticeHall, Englewood Cliffs, NJ.
Fletcher, R. (1970): A New Approach to Variable Metric Algorithms, Computer Journal 13, p. 317322.
Fletcher, R. and Reeves, C.M. (1964): Function minimization by conjugate gradients, Computer Journal 7, p. 148154.
Gay, D.M. (1990): Usage Summary for Selected Optimization Routines, Computing Science Technical Report No. 153, AT&T Bell Laboratories, Murray Hill NJ, http://netlib.belllabs.com/cm/cs/cstr/153.pdf.
Goldfarb, D. (1970): A Family of Variable Metric Updates Derived by Variational Means, Mathematics of Computation 24, p. 2326.
Moré, J.J. (1978): The LevenbergMarquardt algorithm: implementation and theory, in G.A. Watson (Ed.), Lecture Notes in Mathematics 630: Numerical Analysis, pp. 105116, SpringerVerlag: Berlin.
Nelder, J.A. and Mead, R. (1965): A simplex algorithm for function minimization, Computer Journal 7, p. 308313.
Schnabel, R.B., Koontz, J.E. and Weiss, B.E. (1985): A modular system of algorithms for unconstrained minimization, ACM Trans. Math. Software, 11, pp. 419440.
Shanno, D.F. (1970): Conditioning of QuasiNewton Methods for Function Minimization, Mathematics of Computation 24, p. 647656.
Storn, R. and Price, K. (1997): Differential Evolution  A Simple and Efficient Heuristic for Global Optimization over Continuous Spaces, Journal of Global Optimization, 11(4), p. 341359.
summary.cesEst
for the summary
method,
plot.cesEst
for plotting the results
of the grid search for rho,
coef.cesEst
for several further methods,
cesCalc
for calculations or simulations with the CES,
translogEst
for estimating translog functions, and
quadFuncEst
for estimating quadratic functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55  data( germanFarms, package = "micEcon" )
# output quantity:
germanFarms$qOutput < germanFarms$vOutput / germanFarms$pOutput
# quantity of intermediate inputs
germanFarms$qVarInput < germanFarms$vVarInput / germanFarms$pVarInput
## CES: Land & Labor (LevenbergMarquardt algorithm)
cesLandLabor < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms )
# variable returns to scale, increased max. number of iter. (LM algorithm)
cesLandLaborVrs < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
vrs = TRUE, control = nls.lm.control( maxiter = 1000 ) )
# using the NelderMead optimization method
cesLandLaborNm < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
method = "NM" )
# using the BFGS optimization method
cesLandLaborBfgs < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
method = "BFGS" )
# using the LBFGSB optimization method with constrained parameters
cesLandLaborBfgsCon < cesEst( "qOutput", c( "land", "qLabor" ),
germanFarms, method = "LBFGSB" )
# using the CG optimization method
cesLandLaborSann < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
method = "CG" )
# using the SANN optimization method
# (with decreased number of iteration to decrease execution time)
cesLandLaborSann < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
method = "SANN", control = list( maxit = 1000 ) )
# using the Kmenta approximation
cesLandLaborKmenta < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
method = "Kmenta" )
# using the PORT optimization routine with unconstrained parameters
cesLandLaborPortCon < cesEst( "qOutput", c( "land", "qLabor" ),
germanFarms, vrs = TRUE, method = "PORT", lower = Inf, upper = Inf )
# using the PORT optimization routine with constrained parameters and VRS
cesLandLaborPortCon < cesEst( "qOutput", c( "land", "qLabor" ),
germanFarms, vrs = TRUE, method = "PORT" )
# using the Differential Evolution optimization method
# (with decreased number of iteration to decrease execution time)
cesLandLaborDe < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
method = "DE", control = DEoptim.control( itermax = 50 ) )
## estimation with a grid search for rho (using the LM algorithm)
cesLandInt < cesEst( "qOutput", c( "land", "qLabor" ),
data = germanFarms, rho = seq( from = 0.6, to = 0.9, by = 0.3 ) )

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs in the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.