Calculate the endogenous variable of a ‘Constant Elasticity of Substitution’ (CES) function.
The original CES function with two explanatory variables is
y = gamma * exp( lambda * t ) * ( delta * x1^(rho) + ( 1  delta ) * x2^(rho) )^(nu/rho)
and the nonnested CES function with N explanatory variables is
y = gamma * exp( lambda * t ) * ( sum(i=1 to N) delta_i * x_i^(rho) )^(nu/rho)
where in the latter case sum(i=1 to N) delta_i = 1.
In both cases, the elesticity of substitution is s = 1 / ( 1 + rho ).
The nested CES function with 3 explanatory variables proposed by Sato (1967) is
y = gamma * exp( lambda * t ) * [ delta * ( delta_1 * x_1^(rho_1) + ( 1  delta_1 ) * x_2^(rho_1) )^(rho / rho_1) + ( 1  delta ) * x_3^(rho) ]^(nu / rho)
and the nested CES function with 4 explanatory variables (a generalisation of the version proposed by Sato, 1967) is
y = gamma * exp( lambda * t ) * [ delta ( delta_1 * x_1^(rho_1) + ( 1  delta_1 ) * x_2^(rho_1) )^(rho / rho_1) + ( 1  delta ) ( delta_2 * x_3^(ρ_2) + ( 1  delta_2 ) * x_4^(rho_2) )^(rho / rho_2) ]^(nu / rho)
1 
xNames 
a vector of strings containing the names of the explanatory variables. 
data 
data frame containing the explanatory variables. 
coef 
numeric vector containing the coefficients of the CES:
if the vector is unnamed,
the order of the coefficients must be
gamma, eventuelly lambda,
delta, rho,
and eventually nu
in case of two expanatory variables,
gamma, eventuelly lambda,
delta_1, ...,
delta_N, rho, and eventually nu
in case of the nonnested CES with N>2 explanatory variables,
gamma, eventuelly lambda,
delta_1, delta,
rho_1, rho, and eventually nu
in case of the nested CES with 3 explanatory variables,
and gamma, eventuelly lambda,
delta_1, delta_2,
delta, rho_1, rho_2,
rho, and eventually nu
in case of the nested CES with 4 explanatory variables,
where in all cases the nu is only required if the model
has variable returns to scale.
If the vector is named, the names must be 
tName 
optional character string specifying the name of the time variable (t). 
nested 
logical. ;
if 
rhoApprox 
if the absolute value of the coefficient rho is smaller than or equal to this argument, the endogenous variable of the nonnested CES is calculated using the Kmenta approximation, which is more precise than the nonlinear CES formula for very small values of rho (and the CES formula cannot even be used for rho = 0). This feature is not (yet) available for the nested CES. 
A numeric vector with length equal to the number of rows of the data set
specified in argument data
.
Arne Henningsen and Geraldine Henningsen
Kmenta, J. (1967): On Estimation of the CES Production Function. International Economic Review 8, p. 180189.
Sato, K. (1967): A TwoLevel ConstantElasticityofSubstitution Production Function. Review of Economic Studies 43, p. 201218.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  data( germanFarms, package = "micEcon" )
# output quantity:
germanFarms$qOutput < germanFarms$vOutput / germanFarms$pOutput
# quantity of intermediate inputs
germanFarms$qVarInput < germanFarms$vVarInput / germanFarms$pVarInput
## Estimate CES: Land & Labor with fixed returns to scale
cesLandLabor < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms )
## Calculate fitted values
cesCalc( c( "land", "qLabor" ), germanFarms, coef( cesLandLabor ) )
# variable returns to scale
cesLandLaborVrs < cesEst( "qOutput", c( "land", "qLabor" ), germanFarms,
vrs = TRUE )
## Calculate fitted values
cesCalc( c( "land", "qLabor" ), germanFarms, coef( cesLandLaborVrs ) )

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.