Aptech Systems, Inc. Worldwide Headquarters
Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286
Ready to Get Started?
Request Quote & Product Information
Training & Events
Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.
Have a Specific Question?
Q&A: Register and Login
Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.
Join our community to see why our users are considered some of the most active and helpful in the industry!
Where to Buy
Recent Tagsapplications character vectors CML CMLMT Constrained Optimization datasets dates dlibrary dllcall error error handling errors Excel file i/o floating network GAUSS Engine graphics GUI hotkeys installation Java API license licensing linux loading data loops matrices matrix manipulation Maxlik MaxLikMT Memory multidimensional array optimization Optmum output PQG graphics procs RAM random numbers string functions strings structures threading Time Series writing data
Time Series 2.0 MT
Find out more now
Time Series MT 2.1
Find out more now
How to resolve error G0525 : Argument contains NaNs inside likelihood procedure
I am doing an optimization problem with a likelihood function and when I start the optimization process I get the following error:
error G0525 : Argument contains NaNs
Given that for starting values there is no problem, meaning that the 0/0 or o*inf occurs when the optimization starts I am not sure how to go around it.
I would like to know if you guys have an idea of how to track down the place where this error comes up.
Thanks in advance.
You can track this down in the debugger. The trick in this case is that you do not know if it is on the second call to your likelihood function or the 200th and you don't want to have to keep stepping through your code until it errors out.
Let's work through a simple example. We will run this program file, which I named debug_proc.gss:
testProcedure(); proc (0) = testProcedure(); local a, iters, i, eig_vals; iters = 100; for i(1, iters, 1); //create random array a = areshape(rndn(24, 1), 6|2|2); //Set first element to be //missing value if it is less //than -1 if a[1,1,1] .< -1; a[1,1,1] = error(0); endif; eig_vals = eigh(a); endfor; endp;
When we run this file, we will get this error message:
G0525 : Argument contains NaNs [debug_proc.gss, line 19]
Click on the thumbnail image below to see a screenshot.
Based upon this information, we know that the error is happening in the call to the GAUSS function eigh. Since we do not know on which iteration the error is occuring, we will add an if statement that checks to see if our variable a, contains any NaNs with the GAUSS function isinfnanmiss. To accomplish this we will add this bit of code just before the call to eigh:
//check to see if 'a' contains NaNs if isinfnanmiss(a); a = a; endif;
The purpose of the line: a = a; is just to give us a line to place our breakpoint on. Click in the margin to the left of the line number on the line a = a; to set the breakpoint. Then start the debugger and run to that breakpoint. Click on the thumbnail below to see a screenshot with the breakpoint set and the debugger being started:
When you are in the debugger and have run to your breakpoint, you can examine the contents of any local variables by double-clicking them in the Local/Watch variable window (inside the yellow box in the image below), or by placing your cursor on a variable inside the code and using the hotkey CTRL+E.
so a follow up on this. It was perfectly clear the example you gave me and it works when I know where the NaNs are located.
But now the problem is that the like mentioned in the NaNs error is an empty one.
So at this point I am quite lost. The estimation runs for some time but after quite a number of iterations it gives the same NaNs error I cant locate.
Any ideas on this?
Thanks in advance.
Is this empty line in your code or in the code for Optmum? The error is most likely coming from a call to eigh. I would guess that unless your code has a call to eigh, the problem is that the return from your likelihood function contains NaNs.
What I would do is place an if check before any call to eigh that occurs in your code and I would also check the return from your likelihood function before you return it--something like:
proc (1) = myLikelihood(x); local out; . . . if isinfnanmiss(out); out = out; //put a breakpoint here endif; retp(out); endp;
This should find your problem.