G0041 : Argument must be scalar [maxlik.src, line 767]

While running a particular file, I am getting the following error. However, there is no error when using different variables (2 out of 5 have issues).

Currently active call:
File maxlik.src, line 767, in maxprt
print "Mean log-likelihood " ftos(f,"%#.lG",15,6);
Traceback:
File mgarch1.gss, line 111, in <main>
{th,f,g,covmat,retcode}=maxprt(maxlik(data,0,&varmgarchmll,theta));

the code used by me are:

new;
cls;
@===========call different library=============@
library maxlik, pgraph;
#include maxlik.ext;
maxset;
graphset;
@===============================================@
format /ld 8,6;
@==================set output file==============@
output file=varmgarchm_ukbr_lag2.out reset;
@===============================================@

@============= load data file===================@
nor0=358; @=====number of rows=================@
noc=2; @========number of columns===========@
//load data[nor0,noc]=ukbr.txt;

data1mg = loadd("A:/1_research21/1.1_obj1/1_MGARCH_part/analysis/data1mg.xlsx", "rt + mininggrowth");

z0=data1mg[.,"rt" "mininggrowth"]

NOTE: IF I USE  z0=data1mg[.,"rt" "generalgrowth"] THAT IS, A DIFFERENT VARIABLE THEN I HAVE NO ERROR.

PLEASE HELP!!

1 Answer



0



There should be an error message above Currently active call. If the error message is:

Arugment must be scalar

then it is likely that the return value from your loglikelihood function was a complex number. This could be because a negative number was passed to the ln() function, or something else. You can add a check to the end of the varmagarchmll procedure to check and see if the return value is complex and then check to see if the imaginary part is more than round-off error.

For example if the very end of varmagarchmll() looks like this:

    retp(ll);
endp;

You could add this code:


    // Check to see if the return value is complex
    if iscplx(ll);
        // Check to see if the imaginary part is more than round-off errr
        if hasimag(ll);
            print "ll is imaginary and its value is: ll;
        else;
            // if the imaginary part is only round-off, remove it
            ll = real(ll);
        endif;
    endif;
    retp(ll);
endp;

admin

47

Your Answer

1 Answer

0

There should be an error message above Currently active call. If the error message is:

Arugment must be scalar

then it is likely that the return value from your loglikelihood function was a complex number. This could be because a negative number was passed to the ln() function, or something else. You can add a check to the end of the varmagarchmll procedure to check and see if the return value is complex and then check to see if the imaginary part is more than round-off error.

For example if the very end of varmagarchmll() looks like this:

    retp(ll);
endp;

You could add this code:


    // Check to see if the return value is complex
    if iscplx(ll);
        // Check to see if the imaginary part is more than round-off errr
        if hasimag(ll);
            print "ll is imaginary and its value is: ll;
        else;
            // if the imaginary part is only round-off, remove it
            ll = real(ll);
        endif;
    endif;
    retp(ll);
endp;


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.