maxlik produces complex numbers!

Hi everybody,

 

I'm using maxlik with the following options:

_max_Options = { bfgs stepbt };

 

The problem is that after dozens of iterations the program stops, and when I check for the problem I see the optimization method has produced complex numbers with imaginary parts. In other words, the algorithm suddenly produces complex parameters which enter into my likelihood function and produce some problems. Sometimes even the Gauss windows is closed by itself. Is there any  known solution for this problem?

 

2 Answers



0



accepted

Most likely what is happening is that some negative numbers are being passed to the ln command inside of your objective procedure which will create complex numbers.

The best way to investigate this would be to use the GAUSS debugger. It has lots of powerful tools which make it easy to find the problems to solutions like these.

The alternative is to use some functions to check for complex and/or negative numbers in your procedure to find the problem. For example, if your likelihood function looks like this:

// Original likelihood
proc lpr(x,z);
    local s,m,u,tmp;
    s = x[4];

    m = z[.,2:4]*x[1:3,.];

    u = z[.,1] ./= 0;

    tmp = ln(cdfnc(m/sqrt(s))));

    retp(u.*lnpdfmvn(z[.,1]-m,s) + (1-u) .* tmp);
endp;

then you could add some diagnostic print statements like this:

// Modified likelihood
proc lpr(x,z);
    local s,m,u,tmp;
    s = x[4];

    m = z[.,2:4]*x[1:3,.];

    u = z[.,1] ./= 0;

    tmp = ln(cdfnc(m/sqrt(s))));

    // Check to see if 'tmp' is complex
    if iscpxl(tmp);
        print "tmp is complex";
        print "m = " m;
        print "cdfnc(m/sqrt(s)) = " cdfnc(m/sqrt(s));
        print "Incoming parameter vector = " x;

        // Stop program
        end;
     endif;

    retp(u.*lnpdfmvn(z[.,1]-m,s) + (1-u) .* tmp);
endp;

aptech

1,773


0



Thank you very much! It works now.

Your Answer

2 Answers

0
accepted

Most likely what is happening is that some negative numbers are being passed to the ln command inside of your objective procedure which will create complex numbers.

The best way to investigate this would be to use the GAUSS debugger. It has lots of powerful tools which make it easy to find the problems to solutions like these.

The alternative is to use some functions to check for complex and/or negative numbers in your procedure to find the problem. For example, if your likelihood function looks like this:

// Original likelihood
proc lpr(x,z);
    local s,m,u,tmp;
    s = x[4];

    m = z[.,2:4]*x[1:3,.];

    u = z[.,1] ./= 0;

    tmp = ln(cdfnc(m/sqrt(s))));

    retp(u.*lnpdfmvn(z[.,1]-m,s) + (1-u) .* tmp);
endp;

then you could add some diagnostic print statements like this:

// Modified likelihood
proc lpr(x,z);
    local s,m,u,tmp;
    s = x[4];

    m = z[.,2:4]*x[1:3,.];

    u = z[.,1] ./= 0;

    tmp = ln(cdfnc(m/sqrt(s))));

    // Check to see if 'tmp' is complex
    if iscpxl(tmp);
        print "tmp is complex";
        print "m = " m;
        print "cdfnc(m/sqrt(s)) = " cdfnc(m/sqrt(s));
        print "Incoming parameter vector = " x;

        // Stop program
        end;
     endif;

    retp(u.*lnpdfmvn(z[.,1]-m,s) + (1-u) .* tmp);
endp;

0

Thank you very much! It works now.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.