SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)

How do I interpret Johansens' test results?

Requested and Answered by Vanna on 30-Jan-2011 04:51 (14750 reads)

The simplest approach for understanding implication of the results would be to simulate a set of series and use it as an input for Johansens' test. The output of the result can then be checked to help get an inuiton of how it is able to backtrack the original simulation.

Following are some example scenarios and their output in each case:

Model : Generate 5 simple stationary series. This is actually a wrong input, because the pre requirement for Johansen's test is that the input series should be I(1). Nevertheless, we do it for fun to see what happens.

Input code for simulation

The resulting saved matrix is then pasted into input tab of the spreadhseet

http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434.

In the main tab of the spreadsheet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

This is a eigen-max test with the following null hypothesis.

H0 : r=0 versus H1 : 0H0 : r=1 versus H1 : 1...

H0 : r=g-1 versus H1 : r=g

So, what do we conclude by looking at the output? We start going down one row at a time, and compare the test statistic with the critical values. 118.26 is more than the critical values 31.2379, 33.8777,39.3693 which means that we are not able to say whether there is 0 cointegration vector. It could still be that there is more than 1 cointegrating vector. So, lets move on to the 2nd row. 114.8 is above the critical values 25.1236,27.5858,32.7172 so we cannot conclude that there is 1 cointegrating vector. But it could be possible that there are 2 or more cointegrating vectors. We move on to the 3rd row now, and get rejected again.

Then 4 and 5th row are also rejected. This means that there is no conclusion.

Model : Generate 5 random walks. We should expect that Johansens' test tells us that there is no cointegrating vector

Input code for simulation

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadhseet, choose no. of lags=1.

Then Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

So, what do we conclude by looking at the output? Remember, we start going down one row at a time as we are getting rejected, and compare the test statistic with the critical values. So let's start in the above result. 27.17 is compared to critical values in the row, and it is less than all the critical values. We are not rejected, and don't need to go further down. It means that the null hypothesis of 0 cointgerating vector cannot be rejected at 90, 95 and 99% level. Which concludes that there is no cointegration!

Also, it is interesting to look at eigen values. None of them is significant.

Eigen values output:

Since all eigen values are insignifacnt, it doen't make sense to look at eigen matrix.

Neverthless, I pasted it here for the record:

Eigen vectors matrix output:

Model : Generate 5 random walks. Make a series depend on another series. We would expect that Johansens' test tells us that there is one cointegrating vector.

Input code for simulation

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadhseet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

So, what do we conclude by looking at the output. Remember, we start going down one row at a time as we are getting rejected, and compare the test statistic with the critical values. So let's start in the above result. 408.61 is compared to critical values in the row. It is more than all critical values in the row, which means that r=0 is rejected. We next move on the 2nd row. The test statistic 21.68 is less than all critial values, which means that null hypothesis of r=1 cannot be rejected i.e., there is a single cointegrating vector. We stop going down and all done for now.

Also, it is interesting to look at eigen values. Only one of them is significant.

Eigen values output:

Since only 1 eigen value is signifacnt, only the first column is important of the eigen

vectors matrix. Rest of the columns can be ignored.

Eigen vectors matrix output:

If you remember the simulation code for cointegration, it was

y(4) = 0.5*y(1) + et

which means that

y(4) - 0.5*y(1) should be stationary

Now let us look at the 1st eigenvector and see if this information can be extracted.

The eigen vector is :

Dividing by 0.892443971, we get:

This means that:

-0.505*y(1) - 0.00*y(2) + 0.002 * y(3) + 1*y(4) - 0.0072 should be stationary

Ignoring the insignificant coefficient, the result is pretty much able to extract our

simulation input of the 0.5 coefficient.

Model : Generate 5 random walks. Make 4th series depend 1st series. Make 5th series depend on 1st, 2nd and 3rd series. We would expect that Johansens' test tells us that there are 2 cointegrating vectors.

Input code for simulation

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadhseet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

So let's start navigating in the above result. 410.59 is compared to critical values in the 1st row, we get rejected because it is higher than all. We go to 2nd row, and get rejected again. But 3rd row value 14.29 is less than all critical values, which tells us that there are 2 coinegrating vectors.

Also, it is interesting to look at eigen values. Only two of them are significant.

Eigen values output:

Since only 2 eigen values are signifacnt, only the first 2 columns are important of the eigen vectors matrix. Rest of the columns can be ignored.

Eigen vectors matrix output:

If you remember the simulation code for cointegration, it was

y(4) = 0.5*y(1) + et

which means that

y(4) - 0.5*y(1) should be stationary

And there is also one more cointration we had simulated:

y(5) = 1*y(1) + 2*y(2) + 3*y(3) + et

implying

y(5) - 1*y(1) - 2*y(2) - 3*y(3) should be stationary

Now since there are 2 cointegration vectors, we are not sure which information is embedded in which vector. Let's try to make a guess

let us look at the 1st eigenvector

The eigen vector is :

I think it is the y(4)<->y(1) relation, which should indicate in the above vector that 4th value should be double the 1st value and of an opposite sign. Well, not exactly and they are way off. I wish I could extract that info. But hey wait, I can fiddle with lag remember? I chose 1 earlier. Now I will try with lag of 2 and rerun the test. eignevalues and test statistics are sligtly different but do not change the conclusion.

So, this is our eignmatrix now with the new lag of 2:

let's look at the first eigen vector:

Dividing by 0.392977483, we get:

This means that:

-1.011*y(1) - 2.0*y(2) - 3.0 * y(3) + 0.02*y(4) + y(5) should be stationary

Ignoring the insignificant coefficient of y(4), the result is pretty much able to extract

our our inputs when we created the 5 series.

let's now look at the second eigen vector:

Dividing by 0.908, we get:

This means that:

-0.423*y(1) + 0.15*y(2) + 0.23 * y(3) + 1*y(4) + -0.077*y(5) should be stationary

If we ignore the coefficients of y(2),y(3) and y(5), y(1) and y(4) coefficients pretty much match the values when we created the 4th series.

Model : Generate 5 random walks. Make 4th series depend on 1st series with a cointegrating spread having mean reversion speed of 0.5. Make 5th series depend on 2nd series with a cointegrating spread having mean reversion speed of 0.25. We would expect that Johansens' test tells us that there are 2 cointegrating vectors, and also indicate that eigen values are proportional to the speed. Also, the proper eigen value matches the correct eigen vector.

Input code for simulation

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadsheet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

As we can see, the above results indicate that there are 2 cointegrating vectors

It is now interesting to look at eigen values. Only two of them are significant.

Eigen values output:

Since only 2 eigen values are significant, only the first 2 columns are important of the eigen vectors matrix. Rest of the columns can be ignored.

Eigen vectors matrix output:

If you remember the simulation code for cointegration, y(4) was created using 2*y(1) + a series which had theta=0.5. The other series y(5) was created using 4*y(2) + a series which had theta=0.25.

Since eigen values are supposed to increase with theta, we can assume that the higher eigen value corresponds to the cointegrating vector y(4)<->y(1).

Following is the first eigen vector:

It seems that 1st series is double the 4th series, and the others are insignificant - it matches our simulation

Now let us look at the next eigen vector corresponding to the smaller eigen value 0.212614677

2nd series coeff (0.97) is around 4 times the 5th series (0.24) while the others are insignificant - it thus seems to match our original simulation of y(5)<->y(2)

Since the theta parameter or eigen helps to determine the strength of the relation and how fast or often the relationship converges, studying eigen values is an important indicator of life cycle of the pair trade

Following are some example scenarios and their output in each case:

**Scenario 1 : 5 simple stationary series**Model : Generate 5 simple stationary series. This is actually a wrong input, because the pre requirement for Johansen's test is that the input series should be I(1). Nevertheless, we do it for fun to see what happens.

Input code for simulation

n=1000;
x=randn(n,5);
save "c:\\octave_files\\xmat.txt" x;

The resulting saved matrix is then pasted into input tab of the spreadhseet

http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434.

In the main tab of the spreadsheet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

0 118.2650173 31.2379 33.8777 39.3693
1 114.8008395 25.1236 27.5858 32.7172
2 102.5224266 18.8928 21.1314 25.865
3 101.2230094 12.2971 14.2639 18.52
4 79.41884747 2.7055 3.8415 6.6349

This is a eigen-max test with the following null hypothesis.

H0 : r=0 versus H1 : 0

H0 : r=g-1 versus H1 : r=g

So, what do we conclude by looking at the output? We start going down one row at a time, and compare the test statistic with the critical values. 118.26 is more than the critical values 31.2379, 33.8777,39.3693 which means that we are not able to say whether there is 0 cointegration vector. It could still be that there is more than 1 cointegrating vector. So, lets move on to the 2nd row. 114.8 is above the critical values 25.1236,27.5858,32.7172 so we cannot conclude that there is 1 cointegrating vector. But it could be possible that there are 2 or more cointegrating vectors. We move on to the 3rd row now, and get rejected again.

Then 4 and 5th row are also rejected. This means that there is no conclusion.

**Scenario 2 : 5 random walks with no cointegration relation**Model : Generate 5 random walks. We should expect that Johansens' test tells us that there is no cointegrating vector

Input code for simulation

n=1000;
x=randn(n,5);
y=zeros(n,5);
for i=2:n,
y(i,:)=y(i-1,:)+x(i-1,:);
end
save "c:\\octave_files\\outmat.txt" y;

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadhseet, choose no. of lags=1.

Then Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

0 27.17365686 31.2379 33.8777 39.3693
1 17.30872919 25.1236 27.5858 32.7172
2 8.626250417 18.8928 21.1314 25.865
3 3.596618813 12.2971 14.2639 18.52
4 1.199571567 2.7055 3.8415 6.6349

So, what do we conclude by looking at the output? Remember, we start going down one row at a time as we are getting rejected, and compare the test statistic with the critical values. So let's start in the above result. 27.17 is compared to critical values in the row, and it is less than all the critical values. We are not rejected, and don't need to go further down. It means that the null hypothesis of 0 cointgerating vector cannot be rejected at 90, 95 and 99% level. Which concludes that there is no cointegration!

Also, it is interesting to look at eigen values. None of them is significant.

Eigen values output:

0.02686077 0 0 0 0
0 0.017193885 0 0 0
0 0 0.00860629 0 0
0 0 0 0.00359734 0
0 0 0 0 0.001201253

Since all eigen values are insignifacnt, it doen't make sense to look at eigen matrix.

Neverthless, I pasted it here for the record:

Eigen vectors matrix output:

-0.661949395 -0.40088828 0.264018582 0.1976066 0.426160722
-0.199036209 -0.066628809 0.356554053 -1.496067863 -0.780437145
-0.673273006 0.463350995 0.324806307 0.205996444 -0.281146982
-0.152620993 -0.604282965 0.820698329 0.363897613 0.081354175
0.213583421 0.533750417 0.575550683 -0.039952345 0.392567245

**Scenario 3 : 5 random walks with a single cointegration relation**Model : Generate 5 random walks. Make a series depend on another series. We would expect that Johansens' test tells us that there is one cointegrating vector.

Input code for simulation

n=1000;
x=randn(n,5);
y=zeros(n,5);
for i=2:n,
y(i,:)=y(i-1,:)+x(i-1,:);
y(i,4)=0.5*y(i,1)+x(i-1,4); %make 4th series depend on 1st series
end
save "c:\\octave_files\\outmat.txt" y;

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadhseet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

0 408.6111509 31.2379 33.8777 39.3693
1 21.68259121 25.1236 27.5858 32.7172
2 10.94487617 18.8928 21.1314 25.865
3 4.136073216 12.2971 14.2639 18.52
4 3.466208882 2.7055 3.8415 6.6349

So, what do we conclude by looking at the output. Remember, we start going down one row at a time as we are getting rejected, and compare the test statistic with the critical values. So let's start in the above result. 408.61 is compared to critical values in the row. It is more than all critical values in the row, which means that r=0 is rejected. We next move on the 2nd row. The test statistic 21.68 is less than all critial values, which means that null hypothesis of r=1 cannot be rejected i.e., there is a single cointegrating vector. We stop going down and all done for now.

Also, it is interesting to look at eigen values. Only one of them is significant.

Eigen values output:

0.335971369 0 0 0 0
0 0.021491733 0 0 0
0 0 0.010906894 0 0
0 0 0 0.004135786 0
0 0 0 0 0.003467131

Since only 1 eigen value is signifacnt, only the first column is important of the eigen

vectors matrix. Rest of the columns can be ignored.

Eigen vectors matrix output:

-0.451106535 -0.150103774 1.124659171 0.034072974 -0.393398907
-0.000117708 -0.484647805 0.181036697 -0.725581427 0.523718776
0.002076156 0.351986478 -0.181468917 0.122717955 0.816287909
0.892443971 0.082954575 -0.099065257 -0.173793873 -0.077276915
-0.006506092 0.794152923 0.169785722 -0.799508474 -0.727273969

If you remember the simulation code for cointegration, it was

y(4) = 0.5*y(1) + et

which means that

y(4) - 0.5*y(1) should be stationary

Now let us look at the 1st eigenvector and see if this information can be extracted.

The eigen vector is :

-0.451106535
-0.000117708
0.002076156
0.892443971
-0.006506092

Dividing by 0.892443971, we get:

-0.505473228
-0.000131894
0.002326371
1
-0.007290196

This means that:

-0.505*y(1) - 0.00*y(2) + 0.002 * y(3) + 1*y(4) - 0.0072 should be stationary

Ignoring the insignificant coefficient, the result is pretty much able to extract our

simulation input of the 0.5 coefficient.

**Scenario 4 : 5 random walks with two cointegration relations**Model : Generate 5 random walks. Make 4th series depend 1st series. Make 5th series depend on 1st, 2nd and 3rd series. We would expect that Johansens' test tells us that there are 2 cointegrating vectors.

Input code for simulation

n=1000;
x=randn(n,5);
y=zeros(n,5);
for i=2:n,
y(i,:)=y(i-1,:)+x(i-1,:);
y(i,4)=0.5*y(i,1)+x(i-1,4); %4th series depends on 1st series
y(i,5)=1*y(i,1)+ 2*y(i,2)+ 3*y(i,3)+ x(i-1,5); %5th series depends on 1st, 2nd and 3rd
series
end
save "c:\\octave_files\\outmat.txt" y;

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadhseet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

0 410.5947149 31.2379 33.8777 39.3693
1 390.6960494 25.1236 27.5858 32.7172
2 14.29738129 18.8928 21.1314 25.865
3 5.934468592 12.2971 14.2639 18.52
4 2.922150652 2.7055 3.8415 6.6349

So let's start navigating in the above result. 410.59 is compared to critical values in the 1st row, we get rejected because it is higher than all. We go to 2nd row, and get rejected again. But 3rd row value 14.29 is less than all critical values, which tells us that there are 2 coinegrating vectors.

Also, it is interesting to look at eigen values. Only two of them are significant.

Eigen values output:

0.337289841 0 0 0 0
0 0.323943757 0 0 0
0 0 0.014223904 0 0
0 0 0 0.005928717 0
0 0 0 0 0.002923724

Since only 2 eigen values are signifacnt, only the first 2 columns are important of the eigen vectors matrix. Rest of the columns can be ignored.

Eigen vectors matrix output:

-0.135174448 -0.299033033 -0.357385696 0.847797034 -0.635417042
0.696093715 -0.508416186 1.232368579 0.796628712 -0.188623585
1.05089023 -0.761039599 0.67389229 -0.094661601 -4.110504851
0.964622081 0.092792861 0.019643125 0.003681596 0.179172871
-0.34873143 0.253575316 -0.087529755 -0.084745827 0.3234028

If you remember the simulation code for cointegration, it was

y(4) = 0.5*y(1) + et

which means that

y(4) - 0.5*y(1) should be stationary

And there is also one more cointration we had simulated:

y(5) = 1*y(1) + 2*y(2) + 3*y(3) + et

implying

y(5) - 1*y(1) - 2*y(2) - 3*y(3) should be stationary

Now since there are 2 cointegration vectors, we are not sure which information is embedded in which vector. Let's try to make a guess

let us look at the 1st eigenvector

The eigen vector is :

-0.135174448
0.696093715
1.05089023
0.964622081
-0.34873143

I think it is the y(4)<->y(1) relation, which should indicate in the above vector that 4th value should be double the 1st value and of an opposite sign. Well, not exactly and they are way off. I wish I could extract that info. But hey wait, I can fiddle with lag remember? I chose 1 earlier. Now I will try with lag of 2 and rerun the test. eignevalues and test statistics are sligtly different but do not change the conclusion.

So, this is our eignmatrix now with the new lag of 2:

0.397310101 -0.384611124 -0.227844088 0.987359288 -0.133113526
0.787365305 0.139167334 0.845313196 1.095297321 -0.565713424
1.180091737 0.215003677 0.466075171 0.260461008 3.278046394
-0.011778218 0.908489472 -0.111137074 -0.034521057 -0.081752651
-0.392977483 -0.070376161 -0.062890049 -0.179129761 0.035345292

let's look at the first eigen vector:

0.397310101
0.787365305
1.180091737
-0.011778218
-0.392977483

Dividing by 0.392977483, we get:

-1.011025104
-2.003588853
-3.002950009
0.029971736
1

This means that:

-1.011*y(1) - 2.0*y(2) - 3.0 * y(3) + 0.02*y(4) + y(5) should be stationary

Ignoring the insignificant coefficient of y(4), the result is pretty much able to extract

our our inputs when we created the 5 series.

let's now look at the second eigen vector:

-0.384611124
0.139167334
0.215003677
0.908489472
-0.070376161

Dividing by 0.908, we get:

-0.423352319
0.153185412
0.236660615
1
-0.077465026

This means that:

-0.423*y(1) + 0.15*y(2) + 0.23 * y(3) + 1*y(4) + -0.077*y(5) should be stationary

If we ignore the coefficients of y(2),y(3) and y(5), y(1) and y(4) coefficients pretty much match the values when we created the 4th series.

**Scenario 5 : 5 random walks with two cointegration relations. The spread of the 2 coinetgrated series have different life cycles or mean reversion speeds**Model : Generate 5 random walks. Make 4th series depend on 1st series with a cointegrating spread having mean reversion speed of 0.5. Make 5th series depend on 2nd series with a cointegrating spread having mean reversion speed of 0.25. We would expect that Johansens' test tells us that there are 2 cointegrating vectors, and also indicate that eigen values are proportional to the speed. Also, the proper eigen value matches the correct eigen vector.

Input code for simulation

n=1000;
%simulate a mean reverting spread from an OU process
dB1=randn(n,1); %white noise
dB2=randn(n,1); %white noise
S1=zeros(n,1); %initialize spread process
S2=zeros(n,1); %initialize spread process
%OU model considered is :
%S_(t+1) = S_t + theta*(b-S_t)*dt + sigma*rootDt*Z_(t+1)
theta1=0.5; %speed of mean reversion
theta2=0.25; %speed of mean reversion
b=10.4; %long term or expected mean
dt=2;
sigma=0.82; %volatility
rootdt=dt^0.5;
for i=2:n,
S1(i)=S1(i-1) + theta1*(b-S1(i-1))*dt + sigma*rootdt*dB1(i);
S2(i)=S2(i-1) + theta2*(b-S2(i-1))*dt + sigma*rootdt*dB2(i);
end
x=randn(n,5);
y=zeros(n,5);
for i=2:n,
y(i,:)=y(i-1,:)+x(i-1,:);
y(i,4)=S1(i,1) - 2*y(i,1); %4th series depends on 1st series
y(i,5)=S2(i,1) - 4*y(i,2); %5th series depends on 2nd series
%y(i,4)=0.5*y(i,1)+x(i-1,4); %4th series depends on 1st series
%y(i,5)=1*y(i,1)+ 2*y(i,2)+ 3*y(i,3)+ x(i-1,5); %5th series depends on 1st, 2nd and 3rd series
end
save "c:\\octave_files\\xmat.txt" y;

The resulting saved matrix is then pasted into input tab of the spreadhseet http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=9&lid=434

In the main tab of the spreadsheet, choose no. of lags=1.

Click on button Start cointegration test.

Note result in tab johansen_results_eigen. Following is an example output:

0 445.3723341 31.2379 33.8777 39.3693
1 238.5594651 25.1236 27.5858 32.7172
2 7.984522393 18.8928 21.1314 25.865
3 2.70650406 12.2971 14.2639 18.52
4 1.105494906 2.7055 3.8415 6.6349

As we can see, the above results indicate that there are 2 cointegrating vectors

It is now interesting to look at eigen values. Only two of them are significant.

Eigen values output:

0.359985767 0 0 0 0
0 0.212614677 0 0 0
0 0 0.007968604 0 0
0 0 0 0.002708254 0
0 0 0 0 0.001107097

Since only 2 eigen values are significant, only the first 2 columns are important of the eigen vectors matrix. Rest of the columns can be ignored.

Eigen vectors matrix output:

-0.894595844 -0.004031033 -0.835084519 3.484424479 1.299565317
0.014204241 0.970165955 1.113412627 -3.848437864 -1.540476169
-0.000231447 -2.5606E-05 0.938055672 -3.085780087 0.754254917
-0.44663461 -0.00329971 0.172457761 0.271347685 -0.022913521
0.003740024 0.243190732 0.33869239 -0.182391431 -0.116972739

If you remember the simulation code for cointegration, y(4) was created using 2*y(1) + a series which had theta=0.5. The other series y(5) was created using 4*y(2) + a series which had theta=0.25.

Since eigen values are supposed to increase with theta, we can assume that the higher eigen value corresponds to the cointegrating vector y(4)<->y(1).

Following is the first eigen vector:

-0.894595844
0.014204241
-0.000231447
-0.44663461
0.003740024

It seems that 1st series is double the 4th series, and the others are insignificant - it matches our simulation

Now let us look at the next eigen vector corresponding to the smaller eigen value 0.212614677

-0.004031033
0.970165955
-2.5606E-05
-0.00329971
0.243190732

2nd series coeff (0.97) is around 4 times the 5th series (0.24) while the others are insignificant - it thus seems to match our original simulation of y(5)<->y(2)

Since the theta parameter or eigen helps to determine the strength of the relation and how fast or often the relationship converges, studying eigen values is an important indicator of life cycle of the pair trade

Discuss or give feedback? Just enter your message and click on submit. No registration is required.

Discuss or give feedback? Just enter your message and click on submit. No registration is required.