I have trouble finding the right packages and methods to estimate a system of three nonlinear equations with cross-equation restrictions using R.
I want to estimate the parameters of a CES production functions using the methodology developed by Miguel A. León-Ledesma, Peter McAdam, and Alpo Willman (2010):
The estimator used for the system is a nonlinear feasible generalized least squares (FGLS) method which accounts for possible cross equation error correlation (much like an SUR model in linear contexts). The estimator performs NLLS on each individual equation and uses the estimated errors to build a variance-covariance (VCV) matrix and then estimates the system by GLS, completing one iteration. The estimated VCV matrix will be updated with each iteration until the system converges to a predetermined criterion.
I have completed the first step of a nonlinear estimation of the individual equations using the nlsLM function and build the vcv matrix of the estimated residuals but I'm struggling as to how I should implement the iterated FGLS procedure.
An example of my code is below:
psi = 1
sigma = 0.6
alpha.e = 0.01
alpha.l = 0.01
These are my starting values
es.f = les ~ (sigma-1)/sigma * (log(psi) + alpha.e*t)+
(1- sigma)/sigma * ly + (1+sigma)*log(ebar) + log(1-normals[6])
nl.e.lm = nlsLM(es.f,start = list(psi = psi, sigma = sigma, alpha.e = alpha.e))
les
, ly
, ebar
, tbar
are from the data, the elements of normals
are known constants. I only have a limited number of observations (23) which is why I am opting for the systems approach, which offers better identification especially with small sample sizes compared to other approaches such as the Kmenta approximation, which is implemented in the package micEconCES.
I get reasonable results in all three equations for at least 1 or 2 of the parameters, which is encouraging, but of course so far the cross-equation restrictions are not implemented because the equations are just estimated individually.
I would be glad for any help, just pointing me in the right direction would be helpful. I was thinking of trying the BB
package but I am confused as to how I should implement what I want to do there.
P.S.: Side-question I just remembered: How come the dat$
year reference to my data isn't working inside the call to nlsLM? I had to remove all references with $ and predefine those variables separately before my estimations.
edit: I have tried implementing the system using nlsystemfit
but it did not work.
nlsLM
works with artificial data whereasnls
does not) or provide the other two equations, but they have the same structure, or at least a comparable one and I don't think they are all that pertinent to the question. $\endgroup$