G0121 : Matrix not positive definite [dolsnobreakcandt.src, line 583]

Hello,

I am running both a FMOLS and a DOLS on the same dataset o test for cointegration with structural breaks.

After the G048 error message, this is what I am getting when I try to run the dynamic OLS codes

G0121: Matrix not positive definite [dolsnobreakcandt.src, line 583]

Currently active call:

File dolsnobreakcandt.src, line 583, in dols
b = invpd(xi'xi)*xi'yi;

Traceback:

File dolsnobreakcandt.src, line 140, in estim
if est == 1; u = dols(y,x,mod,p); endif;
File dolsnobreakcandt.src, line 85, in lmbreak
lmi = lmi + lm(estim(yb,xb,mod,est));
File dolsnobreakcandt.src, line 38, in <main>
lmi = lmi + lmbreak(y0,x0,mod,bri[1,1+i],bri[2:m+1,1+i],est,mu,var);

Please I need a layman's language kind of help to determine what I need to do.

Thanks

5 Answers



0



The matrix resulting from xi'xi should be a positive definite matrix. Sometimes, however, because of problems with the data, the resulting matrix will not be positive definite. In most cases, you are probably OK. However, the GAUSS function invpd inverts a positive definite matrix.

So what you can do is replace the line

//Requires 'xi' to be positive definite
b = invpd(xi'xi)*xi'yi;

with the line

//Does not strictly require 'xi' to be positive definite
b = inv(xi'xi)*xi'yi;

If this substitution works, you are probably OK. However, if your data is in very bad shape at this point, you may end up with a matrix singular error.

aptech

1,773


0



Thank you.
After Changing the code and taking out the positive definite from the line
b = invpd(xi'xi)*xi'yi;
I get the following output:

Currently active call:

File dolsnobreakcandt.src, line 611, in fejer
        t1 = trimr(uv,i,0);

Traceback:

File dolsnobreakcandt.src, line 251, in lm
        io = fejer(u,int(t^(1/3)));
    File dolsnobreakcandt.src, line 85, in lmbreak
        lmi = lmi + lm(estim(yb,xb,mod,est));
    File dolsnobreakcandt.src, line 38, in <main>

        lmi = lmi + lmbreak(y0,x0,mod,bri[1,1+i],bri[2:m+1,1+i],est,mu,var);
 
Please what am I supposed to do with this?


0



The line t1 = trimr(uv,i,0); is telling GAUSS to remove the first i rows from uv. I do not see the error message in your post (just the stack trace, which is helpful). Usually an error from trimr is that you are trying to trim more rows from a matrix or vector than it has. For example something like this:

//Create a matrix with 3 rows and 2 columns
x = { 1 2,
      3 4,
      5 6 };

//Try to trim 4 rows from the top
//and 0 rows from the bottom
x_2 = trimr(x, 4, 0);

This will return an error, because x does not have 4 rows to trim. I would print out the number of rows of uv and the value of i and see what they are. If my guess is correct, then you can look back and see where uv went wrong in the code.

aptech

1,773


0



The Error message says

G0180 : TRIM too much [dolsnobreakcandt.src, [line 611]]

Before the trace below came:

Currently active call:

File dolsnobreakcandt.src, line 611, in fejer
t1 = trimr(uv,i,0);

Traceback:

File dolsnobreakcandt.src, line 251, in lm
io = fejer(u,int(t^(1/3)));
File dolsnobreakcandt.src, line 85, in lmbreak
lmi = lmi + lm(estim(yb,xb,mod,est));
File dolsnobreakcandt.src, line 38, in 

        lmi = lmi + lmbreak(y0,x0,mod,bri[1,1+i],bri[2:m+1,1+i],est,mu,var);


0



Yes, that is what I anticipated in my last message. Try adding a print statement like this

print "uv = " uv;
print "i = " i;

After the line on which the error is being reported. This will give you some insight into the problem. For example, you may see that on the first iteration, uv is a 1x1 missing value, or that it does not have i rows in it. With that knowledge, you can go back and look at where uv was last assigned to trace the problem.

aptech

1,773

Your Answer

5 Answers

0

The matrix resulting from xi'xi should be a positive definite matrix. Sometimes, however, because of problems with the data, the resulting matrix will not be positive definite. In most cases, you are probably OK. However, the GAUSS function invpd inverts a positive definite matrix.

So what you can do is replace the line

//Requires 'xi' to be positive definite
b = invpd(xi'xi)*xi'yi;

with the line

//Does not strictly require 'xi' to be positive definite
b = inv(xi'xi)*xi'yi;

If this substitution works, you are probably OK. However, if your data is in very bad shape at this point, you may end up with a matrix singular error.

0
Thank you.
After Changing the code and taking out the positive definite from the line
b = invpd(xi'xi)*xi'yi;
I get the following output:

Currently active call:

File dolsnobreakcandt.src, line 611, in fejer
        t1 = trimr(uv,i,0);

Traceback:

File dolsnobreakcandt.src, line 251, in lm
        io = fejer(u,int(t^(1/3)));
    File dolsnobreakcandt.src, line 85, in lmbreak
        lmi = lmi + lm(estim(yb,xb,mod,est));
    File dolsnobreakcandt.src, line 38, in <main>

        lmi = lmi + lmbreak(y0,x0,mod,bri[1,1+i],bri[2:m+1,1+i],est,mu,var);
 
Please what am I supposed to do with this?
0

The line t1 = trimr(uv,i,0); is telling GAUSS to remove the first i rows from uv. I do not see the error message in your post (just the stack trace, which is helpful). Usually an error from trimr is that you are trying to trim more rows from a matrix or vector than it has. For example something like this:

//Create a matrix with 3 rows and 2 columns
x = { 1 2,
      3 4,
      5 6 };

//Try to trim 4 rows from the top
//and 0 rows from the bottom
x_2 = trimr(x, 4, 0);

This will return an error, because x does not have 4 rows to trim. I would print out the number of rows of uv and the value of i and see what they are. If my guess is correct, then you can look back and see where uv went wrong in the code.

0

The Error message says

G0180 : TRIM too much [dolsnobreakcandt.src, [line 611]]

Before the trace below came:

Currently active call:

File dolsnobreakcandt.src, line 611, in fejer t1 = trimr(uv,i,0);

Traceback:

File dolsnobreakcandt.src, line 251, in lm io = fejer(u,int(t^(1/3))); File dolsnobreakcandt.src, line 85, in lmbreak lmi = lmi + lm(estim(yb,xb,mod,est)); File dolsnobreakcandt.src, line 38, in 

        lmi = lmi + lmbreak(y0,x0,mod,bri[1,1+i],bri[2:m+1,1+i],est,mu,var);
0

Yes, that is what I anticipated in my last message. Try adding a print statement like this

print "uv = " uv;
print "i = " i;

After the line on which the error is being reported. This will give you some insight into the problem. For example, you may see that on the first iteration, uv is a 1x1 missing value, or that it does not have i rows in it. With that knowledge, you can go back and look at where uv was last assigned to trace the problem.


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.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy