Hello, I encounter a problem while performing the unit root test at https://docs.aptech.com/gauss/tspdlib/docs/cips.html.
I load the dataset as in the example, but when I enter the code for analysis, I get the following error.
Currently active call:
File myols.src, line 5, in myols
m = inv (moment(x, 0));
Traceback:
File pd_cips.src line 237, in _get_cadf_lag
{b, e1, sig2, se, ssr} = myols (dep, x);
File pd_cips.src, line 69, in cips
{Nlag[i]} = _get_cadf_lag(y,[.,i], f, model, pmax, ic);
File saveload.src, line 132, in <main>
retp(__loadd(dataset, 0, ...));
1 Answer
0
There should be an error message before Currently active call:. If it is G0121 : Matrix not positive definite, then the issue is that not all the columns of your y variable are independent. Here are a few cases where this could happen:
- More than one of the
ycolumns is the same, or very similar. - The
yvariable has a constant term and you selectedmodel = 1 or model = 2and the internal code added a second constant term to the data.
You can check to see if the columns of your y variable have full column rank with the rank() function. Here is an example with simulated data. You will need to run it on your own data.
// simulate two column matrix
x = rndn(20,2);
print "columns of x = " cols(x);
print "rank of x = " rank(x);
After running the above code, you should see:
columns of x = 2.0000000 rank of x = 2.0000000
However, if we add another column that is similar:
// simulate two column matrix
x = rndn(20,2);
// add a third column that is almost equal
// to the second column
x = x ~ x[.,2] + 1e-14;
print "columns of x = " cols(x);
print "rank of x = " rank(x);
This time we will see:
columns of x = 3.0000000 rank of x = 2.0000000
Since the rank of x is less than the number of columns of x, we know that x is not linearly independent and we cannot use all these columns in the test, because 2 of them are nearly identical.
Your Answer
1 Answer
There should be an error message before Currently active call:. If it is G0121 : Matrix not positive definite, then the issue is that not all the columns of your y variable are independent. Here are a few cases where this could happen:
- More than one of the
ycolumns is the same, or very similar. - The
yvariable has a constant term and you selectedmodel = 1 or model = 2and the internal code added a second constant term to the data.
You can check to see if the columns of your y variable have full column rank with the rank() function. Here is an example with simulated data. You will need to run it on your own data.
// simulate two column matrix
x = rndn(20,2);
print "columns of x = " cols(x);
print "rank of x = " rank(x);
After running the above code, you should see:
columns of x = 2.0000000 rank of x = 2.0000000
However, if we add another column that is similar:
// simulate two column matrix
x = rndn(20,2);
// add a third column that is almost equal
// to the second column
x = x ~ x[.,2] + 1e-14;
print "columns of x = " cols(x);
print "rank of x = " rank(x);
This time we will see:
columns of x = 3.0000000 rank of x = 2.0000000
Since the rank of x is less than the number of columns of x, we know that x is not linearly independent and we cannot use all these columns in the test, because 2 of them are nearly identical.
