<p>I think that the wikipedia steps are not completely correct. When you perform Johansen cointegration test you first have to pretest the data to find if they have the same order of integration. That is all variables have to be either <span class="math-container">$I(1)$</span> or <span class="math-container">$I(2)$</span> etc. (see Verbeek, 2008). There are some cointegration tests and models that relax this assumption but Johansen is not one of them. But otherwise the steps 1-3 are correct. </p>

<p><span class="math-container">$\Phi D_t$</span> are indeed seasonal dummies. However, note they are actually not standard part of the model, they are added when you think series can be affected by seasonal trends and if you dont use some other seasonal adjustment technique or if you dont already have data provided with seasonal adjustment from the source.  </p>

<p><span class="math-container">$\mu$</span> is the constant or 'drift' term. It allows your regression to have different intercept than zero. </p>

<p>You are correct <span class="math-container">$\Pi$</span> are matrices of coefficients but dont forget about <span class="math-container">$\Phi$</span>. Any coefficient you add there has to be estimated - I know its just nitpicking but still.</p>

<p>The co-integration vectors come from the <span class="math-container">$\Pi$</span> in the second equation. This matrix can be decomposed as <span class="math-container">$\Pi = \gamma \beta'$</span> where <span class="math-container">$\gamma$</span> is the matrix of weights with which the cointegration vectors enter the model and <span class="math-container">$\beta$</span> is actually the matrix of cointegrated relationships. I am not really exactly sure what you mean by choosing cointegrated vector from this matrix. Its not like you just somehow extract one of the vectors somewhere into some separate vector.</p>

<p>Afterwards the Johansen test basically tests the rank or the number of columns of the cointegrated matrix (With dimensions <span class="math-container">$k$</span>x<span class="math-container">$r$</span> you test for # of <span class="math-container">$r$</span>). Intuitively this works because you need one column to represent each cointegrated relationship (note there might be multiple cointegrated relationship at the same time).</p>

<p>The rank of the matrix is tested either by trace or eigenvalue test as you correctly mentioned. The null of trace test is <span class="math-container">$H_0: r \leq r_0$</span> against <span class="math-container">$H_a: r &lt;r_0 \leq k$</span>  and the max eigenvalue test has the same null but alternative hypothesis is slightly different <span class="math-container">$H_a: r = r_0+1$</span>. However, this might be hard to read in plain English. In practice if you would have only two variables both tests would boil down to first testing 0 cointegrated (<span class="math-container">$r=0$</span>) relationship vs 1 <span class="math-container">$(r=1)$</span>, second <em>less</em> or equal to 1 cointegrated relationships <span class="math-container">$(r\leq 1$</span>) vs 2 (<span class="math-container">$r=2$</span>), third <em>less</em> or equal to 2 coint. rel. <span class="math-container">$r\leq 2$</span> vs 3 (<span class="math-container">$r=3$</span>). You dont really pick from these vectors although the number of cointegrated vectors can affect functional form of VECM, but with just two variables you are looking for <span class="math-container">$r=1$</span>, if your test finds there should be more you are missing some important variables in your model.</p>

<p>Also yes <span class="math-container">$\Delta$</span> is the first difference <span class="math-container">$\Delta y_t = y_t - y_{t-1}$</span>. Also including first differences assumes that the variables are all <span class="math-container">$I(1)$</span> if they are <span class="math-container">$I(2)$</span> you need at least second differences. The reason for that is that outside the cointegrated lagged variables the 'contemporaneous' variables must be stationary otherwise your ECM will be biased.  The whole justification of including level variables in ECM is that as long as there is a cointegrated relationship between those their combination will be stationary and their coefficient will be super consistent, but this does not extend to the variables that are added to the model outside the cointegrated relationship.</p>

<p>References:
Verbeek, M. (2008). A guide to modern econometrics. John Wiley &amp; Sons.</p>

CC BY-SA 4.0
2019-12-31T18:27:13.153Z
Thanks for the detailed response. I have some follow ups. You state that Pi comes from the 2nd equation, which is the VECM equation. However, in the steps were are estimated the VAR model first, so are we getting that Pi matrix from VAR or VECM? Also, it sounds like the ultimate matrix that we test is the Beta matrix decomposed from Pi correct?

I'll try to give you context on what I'm trying to do. I'm working with multiple stocks time series and want to form a stationary time series from them. From my understanding, one can use one of these cointegration vectors to form (continued)
Davis Owen
CC BY-SA 4.0
2019-12-31T18:42:41.187Z
A linear combination of the stock prices such that it will form a stationary time series. That is what I meant when I said "choosing cointegration vector from this matrix". I might then need some clarification on exactly what the cointegration vectors are if this is incorrect. However, even if this is the case, one would only use the cointegration vectors from VAR(p) to determine if there are the right number of cointegration relationships, then estimate a VECM model with that knowledge and ultimately "use" the cointegration vectors from the Pi in the VECM model, right?
Davis Owen
CC BY-SA 4.0
2020-01-01T05:56:43.313Z
I don't claim to have read this but at a glance it looks useful as far as theory. https://www.fsb.miamioh.edu/lij14/672_johansen.pdf
mark leeds
CC BY-SA 4.0
2020-01-01T05:59:39.280Z
Here's one more than looks helpful. http://www.jerrydwyer.com/pdf/Clemson/Cointegration.pdf
mark leeds
CC BY-SA 4.0
2019-12-31T13:04:16.163Z
2019-12-31T13:13:02.947Z
2019-12-31T13:13:02.947Z
1muflon1
<p>I am trying to understand the whole Johansen procedure via wikipedia and some other articles and I'm a noob in econometrics so there is a lot of notation and jargon that I think I am not familiar with. </p>

<p><a href="https://en.wikipedia.org/wiki/Johansen_test" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Johansen_test</a></p>

<p>First off, the test itself. I'm confused by how we test for the cointegration vectors. Where do these vectors come from? Based on this </p>

<p><a href="https://en.wikipedia.org/wiki/Error_correction_model" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Error_correction_model</a></p>

<p>It states that</p>

<p>Step 1: estimate an unrestricted VAR involving potentially non-stationary variables
Step 2: Test for cointegration using Johansen test
Step 3: Form and analyse the VECM.</p>

<p>So is it that we first estimate a VAR, then run the trace or eigenvalue test on the pi matrix, then estimate the VECM? Then when we estimate the vecm, is that where, ultimately, the cointegration vectors come from? And do those ultimate cointegration vectors reside in the pi matrix? How do we know which cointegration vectors to use?</p>

<p>Also I need some slight clarification on the models.</p>

<p>I'll start with the VAR(p) model</p>

<p><img src="https://latex.codecogs.com/gif.latex?%7B%5Cdisplaystyle&space;X_%7Bt%7D=%5Cmu&space;&plus;%5CPhi&space;D_%7Bt%7D&plus;%5CPi&space;_%7Bp%7DX_%7Bt-p%7D&plus;%5Ccdots&space;&plus;%5CPi&space;_%7B1%7DX_%7Bt-1%7D&plus;e_%7Bt%7D,%5Cquad&space;t=1,%5Cdots&space;,T%7D" title="{\displaystyle X_{t}=\mu +\Phi D_{t}+\Pi _{p}X_{t-p}+\cdots +\Pi _{1}X_{t-1}+e_{t},\quad t=1,\dots ,T}" /></p>

<p>I'm relatively confident that Xt is a vector of values at time t, et is a white noise term at time t. I'm not quite sure what mu, phi, and Dt are (although I've heard read it's some sort of "seasonal" term). I'm also assuming that the pi's are matrices that we need to estimate. I'm asking for clarification here but in general I think I understand this VAR(p) representation.</p>

<p><img src="https://latex.codecogs.com/gif.latex?%5CDelta&space;X_%7Bt%7D=%5Cmu&space;&plus;%5CPhi&space;D_%7B%7Bt%7D%7D&plus;%5CPi&space;X_%7B%7Bt-p%7D%7D&plus;%5CGamma&space;_%7B%7Bp-1%7D%7D%5CDelta&space;X_%7B%7Bt-p&plus;1%7D%7D&plus;%5Ccdots&space;&plus;%5CGamma&space;_%7B%7B1%7D%7D%5CDelta&space;X_%7B%7Bt-1%7D%7D&plus;%5Cvarepsilon&space;_%7Bt%7D,%5Cquad&space;t=1,%5Cdots&space;,T" title="\Delta X_{t}=\mu +\Phi D_{{t}}+\Pi X_{{t-p}}+\Gamma _{{p-1}}\Delta X_{{t-p+1}}+\cdots +\Gamma _{{1}}\Delta X_{{t-1}}+\varepsilon _{t},\quad t=1,\dots ,T" /></p>

<p>This is where I need some more clarification for the VECM model. What exactly are the delta's? Are they just the first difference i.e. (1-L)? </p>

<p>Sorry for the noob questions but I'm trying to learn this on my own and haven't found many good resources for johansen test and vecm in particular.</p>

<econometrics><autoregressive><co-integration>
Johansen test explanation
Davis Owen
# Johansen test explanation

(Asked by: username_0 on 2019-12-31)

I am trying to understand the whole Johansen procedure via wikipedia and some other articles and I'm a noob in econometrics so there is a lot of notation and jargon that I think I am not familiar with.

<https://en.wikipedia.org/wiki/Johansen_test>

First off, the test itself. I'm confused by how we test for the cointegration vectors. Where do these vectors come from? Based on this

<https://en.wikipedia.org/wiki/Error_correction_model>

It states that

Step 1: estimate an unrestricted VAR involving potentially non-stationary variables
Step 2: Test for cointegration using Johansen test
Step 3: Form and analyse the VECM.

So is it that we first estimate a VAR, then run the trace or eigenvalue test on the pi matrix, then estimate the VECM? Then when we estimate the vecm, is that where, ultimately, the cointegration vectors come from? And do those ultimate cointegration vectors reside in the pi matrix? How do we know which cointegration vectors to use?

Also I need some slight clarification on the models.

I'll start with the VAR(p) model

![](https://latex.codecogs.com/gif.latex?%7B%5Cdisplaystyle&space;X_%7Bt%7D=%5Cmu&space;+%5CPhi&space;D_%7Bt%7D+%5CPi&space;_%7Bp%7DX_%7Bt-p%7D+%5Ccdots&space;+%5CPi&space;_%7B1%7DX_%7Bt-1%7D+e_%7Bt%7D,%5Cquad&space;t=1,%5Cdots&space;,T%7D "{\displaystyle X_{t}=\mu +\Phi D_{t}+\Pi _{p}X_{t-p}+\cdots +\Pi _{1}X_{t-1}+e_{t},\quad t=1,\dots ,T}")

I'm relatively confident that Xt is a vector of values at time t, et is a white noise term at time t. I'm not quite sure what mu, phi, and Dt are (although I've heard read it's some sort of "seasonal" term). I'm also assuming that the pi's are matrices that we need to estimate. I'm asking for clarification here but in general I think I understand this VAR(p) representation.

![](https://latex.codecogs.com/gif.latex?%5CDelta&space;X_%7Bt%7D=%5Cmu&space;+%5CPhi&space;D_%7B%7Bt%7D%7D+%5CPi&space;X_%7B%7Bt-p%7D%7D+%5CGamma&space;_%7B%7Bp-1%7D%7D%5CDelta&space;X_%7B%7Bt-p+1%7D%7D+%5Ccdots&space;+%5CGamma&space;_%7B%7B1%7D%7D%5CDelta&space;X_%7B%7Bt-1%7D%7D+%5Cvarepsilon&space;_%7Bt%7D,%5Cquad&space;t=1,%5Cdots&space;,T "\Delta X_{t}=\mu +\Phi D_{{t}}+\Pi X_{{t-p}}+\Gamma _{{p-1}}\Delta X_{{t-p+1}}+\cdots +\Gamma _{{1}}\Delta X_{{t-1}}+\varepsilon _{t},\quad t=1,\dots ,T")

This is where I need some more clarification for the VECM model. What exactly are the delta's? Are they just the first difference i.e. (1-L)?

Sorry for the noob questions but I'm trying to learn this on my own and haven't found many good resources for johansen test and vecm in particular.

**Tags:** econometrics, autoregressive, co-integration

---

## 1 answers

### Answer by username_1 on 2019-12-31. Score: 1

I think that the wikipedia steps are not completely correct. When you perform Johansen cointegration test you first have to pretest the data to find if they have the same order of integration. That is all variables have to be either $I(1)$ or $I(2)$ etc. (see Verbeek, 2008). There are some cointegration tests and models that relax this assumption but Johansen is not one of them. But otherwise the steps 1-3 are correct.

$\Phi D\_t$ are indeed seasonal dummies. However, note they are actually not standard part of the model, they are added when you think series can be affected by seasonal trends and if you dont use some other seasonal adjustment technique or if you dont already have data provided with seasonal adjustment from the source.

$\mu$ is the constant or 'drift' term. It allows your regression to have different intercept than zero.

You are correct $\Pi$ are matrices of coefficients but dont forget about $\Phi$. Any coefficient you add there has to be estimated - I know its just nitpicking but still.

The co-integration vectors come from the $\Pi$ in the second equation. This matrix can be decomposed as $\Pi = \gamma \beta'$ where $\gamma$ is the matrix of weights with which the cointegration vectors enter the model and $\beta$ is actually the matrix of cointegrated relationships. I am not really exactly sure what you mean by choosing cointegrated vector from this matrix. Its not like you just somehow extract one of the vectors somewhere into some separate vector.

Afterwards the Johansen test basically tests the rank or the number of columns of the cointegrated matrix (With dimensions $k$x$r$ you test for # of $r$). Intuitively this works because you need one column to represent each cointegrated relationship (note there might be multiple cointegrated relationship at the same time).

The rank of the matrix is tested either by trace or eigenvalue test as you correctly mentioned. The null of trace test is $H\_0: r \leq r\_0$ against $H\_a: r  and the max eigenvalue test has the same null but alternative hypothesis is slightly different $H\_a: r = r\_0+1$. However, this might be hard to read in plain English. In practice if you would have only two variables both tests would boil down to first testing 0 cointegrated ($r=0$) relationship vs 1 $(r=1)$, second *less* or equal to 1 cointegrated relationships $(r\leq 1$) vs 2 ($r=2$), third *less* or equal to 2 coint. rel. $r\leq 2$ vs 3 ($r=3$). You dont really pick from these vectors although the number of cointegrated vectors can affect functional form of VECM, but with just two variables you are looking for $r=1$, if your test finds there should be more you are missing some important variables in your model.

Also yes $\Delta$ is the first difference $\Delta y\_t = y\_t - y\_{t-1}$. Also including first differences assumes that the variables are all $I(1)$ if they are $I(2)$ you need at least second differences. The reason for that is that outside the cointegrated lagged variables the 'contemporaneous' variables must be stationary otherwise your ECM will be biased. The whole justification of including level variables in ECM is that as long as there is a cointegrated relationship between those their combination will be stationary and their coefficient will be super consistent, but this does not extend to the variables that are added to the model outside the cointegrated relationship.

References:
Verbeek, M. (2008). A guide to modern econometrics. John Wiley & Sons.

> **Comments:**
> **username_0**: Thanks for the detailed response. I have some follow ups. You state that Pi comes from the 2nd equation, which is the VECM equation. However, in the steps were are estimated the VAR model first, so are we getting that Pi matrix from VAR or VECM? Also, it sounds like the ultimate matrix that we test is the Beta matrix decomposed from Pi correct?  I'll try to give you context on what I'm trying to do. I'm working with multiple stocks time series and want to form a stationary time series from them. From my understanding, one can use one of these cointegration vectors to form (continued)  
> **username_0**: A linear combination of the stock prices such that it will form a stationary time series. That is what I meant when I said "choosing cointegration vector from this matrix". I might then need some clarification on exactly what the cointegration vectors are if this is incorrect. However, even if this is the case, one would only use the cointegration vectors from VAR(p) to determine if there are the right number of cointegration relationships, then estimate a VECM model with that knowledge and ultimately "use" the cointegration vectors from the Pi in the VECM model, right?  
> **username_2**: I don't claim to have read this but at a glance it looks useful as far as theory. https://www.fsb.miamioh.edu/lij14/672_johansen.pdf  
> **username_2**: Here's one more than looks helpful. http://www.jerrydwyer.com/pdf/Clemson/Cointegration.pdf  

---

