1
$\begingroup$

I'm trying to estimate a nonlinear GMM model with a large parameter space and a large data set. The numerical computation takes a extremely long time and I have been using small subsamples (which also take a long time) to calibrate the model. I'm getting to a point of including a large number of dummies, many of which are removed to reduce multicollinearity, yet I'm starting to get numerically singular matrix error

Error in solve.default(w, gbar) : 
  system is computationally singular: reciprocal condition number = 1.20741e-27

The solve.default(w, gbar) inputs suggest that the error is occurring during the computation of the covariance matrix. With a small subsample, the model could be overfitted, but the error persists even if I raise the number of observations a few hundreds above the number of parameters. The gmm function is set up as below:

res<-gmm(g,x,init,type="twoStep", wmatrix="optimal", optfct="nlminb", prewhite = 0, 
         lower = lb, upper = ub,
         control = list(eval.max = 1000, iter.max = 1000, abs.tol = tols, 
         rel.tol = tols),
         tol=tols)

where various tolerances are set to tols=1e-15, and I don't think any smaller number would help in this situation.

I understand that most of the CPU time is spent on numerically approximating the gradient matrix and the computing time can be drastically reduced, with accuracy increased, if $\nabla G/\nabla \Theta_0$ is provided. Unfortunately, the partials of the moment conditions are not analytically tractable. As a result, running the full dataset every time really is not a feasible strategy given the computational complexity of the model.

I'm wondering if there's a way to configure gmm such that it returns the some estimation results even if it cannot calculate the covariance matrix. Perhaps using nlminb can give me at least the parameters, but more would be better.

Thanks in advance.

$\endgroup$
  • 1
    $\begingroup$ Some of the optimizers (selected through optfct) have the option hessian=FALSE so try adding hessian=FALSE and see what happens. $\endgroup$ – JimB Aug 10 '17 at 4:36
1
$\begingroup$

2 approaches worked for me:

1st: just run the nlminb to obtain the parameters (with identity weighting matrix):

nlmg <- function(beta){

  gv <- as.matrix(colMeans(g1(beta,x)))

  norm(t(gv)%*%gv,"F")
}

nlmr <- nlminb(init,nlmg,lower = lb, upper = ub)

2nd: turn trace on. In the control list:

gmm(g1,x,...,control = list(trace = 1,...))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.