SCM

Forum: developers

Monitor Forum | Start New Thread Start New Thread
RE: Error in qr.solve(H[!fixed, !fixed, drop = FALSE], G0[!fixed], tol = slot(contro [ Reply ]
By: Arne Henningsen on 2015-11-09 08:51
[forum:42725]
Thanks a lot for your quick help!

I ran 'R CMD check' on the sampleSelection package using the latest revision of the maxLik package on R-Forge and everything looks good :-)

RE: Error in qr.solve(H[!fixed, !fixed, drop = FALSE], G0[!fixed], tol = slot(contro [ Reply ]
By: Ott Toomet on 2015-11-09 03:41
[forum:42724]
Uploaded.

I also changed the algorithm a little bit. Marquardt now converges, but Hessian is near-singular and you have to check the results with summary(x, eigentol=1e-13) if you wish. Fixed an issue with summary in the process.

I hope you can CMD check sampleSelection now. The vignette seems to work but it gives a load of other errors for me as I have not cleaned out the treatReg stuff in my folder.

RE: Error in qr.solve(H[!fixed, !fixed, drop = FALSE], G0[!fixed], tol = slot(contro [ Reply ]
By: Arne Henningsen on 2015-11-08 20:13
[forum:42723]
Thanks a lot for fixing the issue :-)

Can you please upload the fixed version of maxLik to CRAN so that sampleSelection passes the tests on CRAN?

In the first example ("greeneStart" with 'bad' starting value), the Marquardt method indeed achieves convergence and returns virtually the same results as with automatic starting values, while the original quadratic approximation correction does not converge and returns completely 'wrong' parameters. In the second example ("tobitML", with the 'true' rho being one), neither the original quadratic approximation correction nor the Marquardt approach achieves convergence but the estimated parameters of both approaches are rather close to the 'true' parameters.

The problem with the error in the sampleSelection vignette due to the singular Hessian matrix seems to be solely related to the changes within the maxLik package between version 1.2 and version 1.3; I can 'switch on and off' the error in the sampleSelection vignette by installing maxLik version 1.3 and 1.2, respectively.


Error in qr.solve(H[!fixed, !fixed, drop = FALSE], G0[!fixed], tol = slot(contro [ Reply ]
By: Ott Toomet on 2015-11-08 02:00
[forum:42722]
Fixed the issue. This was a numeric problem, should be more robust now. SampleSelection vignette works.

* The issue was following: if Hessian is not negative definite, the algorithm subtracts from it lambda%*%I, where lambda is 'barely' enough to make the matrix negative definite. lambda is calculated based on eigenvalues. However, it may get it wrong due to numeric noise. Now it subtracts, and rechecks, and subtracts again if necessary. It should be robust, ie. no try() needed around solve, but it involves one more step of eigenvalue computation.

* The example converges with Marquardt method (although I did not check if the solution is the same).

* I don't know why it does behave differently now. The example in the vignette has numeric issues, perhaps a library was changed meanwhile? I may check it on the current computer and old version of maxLik if you think it is worth of doing. I tried to make the algorithm a bit more robust, and the results changed substantially (all standard errors missing). So I kept the lambda computation as it was earlier.

Thanks to:
Vienna University of Economics and Business Powered By FusionForge