Model of the US Economy: CointegratedVARModelHandbook

Questions and discussions on Vector Autoregressions
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

ac_1 wrote: Wed Nov 06, 2024 4:10 am Sorry, I think I have made an error calculating the prediction intervals for VAR and VECM.

I have them as they would be for the univariate case:

Code: Select all

forecast(model=varmodel,results=f_D,stderrs=s_D,from=iend+1,steps=nsteps)

set l95_D(1) iend+1 iend+nsteps = f_D(1)+%invnormal(.025)*s_D(1)
set u95_D(1) iend+1 iend+nsteps = f_D(1)+%invnormal(.975)*s_D(1)
set l80_D(1) iend+1 iend+nsteps = f_D(1)+%invnormal(.1)*s_D(1)
set u80_D(1) iend+1 iend+nsteps = f_D(1)+%invnormal(.9)*s_D(1)
What is the RATS code for the prediction intervals in the multivariate case, applicable to both dynamic multi-step and recursive static one-step ahead forecasts, assuming no transformations to all the series? Or are those correct, I'm thinking multivariate normal distribution?
No, that's fine. A multivariate Normal distribution has Normal marginals.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by ac_1 »

Thanks.

I am trying to understand Johmle.src.

I have 'made-up' 3 series, which 'look cointegrated'

Code: Select all

data(unit=input) 1 20 x1
2 4 6 8 10 11 24 7 4 5 10 10 12 9 10 11 15 16 17 19

data(unit=input) 1 20 x2
9 8 4 11 12 13 20 19 5 6 11 11 12 9 14 15 13 15 11 17

data(unit=input) 1 20 x3
8 7 10 13 14 19 10 9 8 7 10 12 13 4 14 17 13 16 11 14
and run Johmle.src

Code: Select all

@JohMLE(lags=1,det=NONE,eigenvalues=evalues,vectors=evectors,loadings=loadings,print) 2 20
# x1 x2 x3
There are (3-1)=2 significant ECT's, thus it is a cointegrated system. The s matrix is:

Code: Select all

     28.78947      10.63158      -1.89474      -5.00000       0.10526      16.05263
     10.63158      22.94737       6.05263       5.31579      -6.00000       5.36842
     -1.89474       6.05263      20.63158      -1.00000      -2.68421      -6.84211
     -5.00000       5.31579      -1.00000     127.52632     129.47368     121.26316
      0.10526      -6.00000      -2.68421     129.47368     148.42105     136.52632
     16.05263       5.36842      -6.84211     121.26316     136.52632     141.73684
The s-matrix is based on CMOMENT (with the CORR option, the series correlation matrix) https://en.wikipedia.org/wiki/Cross_product.

Using s, sub-matrices are extracted and

Code: Select all

compute s10_00_01=tr(%%s01)*inv(%%s00)*%%s01
eigen(general=%%s11) s10_00_01 eigval eigvec
Numerically I can see the what the matrices are, but do not understand mathematically why:
- s
- the 3 sub-matrices, and
- s10_00_01
are used in the generalized eigenvalues and eigenvectors calculation.

HARRIS, R (1995) Using Cointegration Analysis in Econometric Modelling, Pearson Education Limited, Prentice Hall, p.78, Box.5.1 The Johansen method of reduced rank regression, is similar to the RATS method, but uses residual matrices rather the levels and differenced series. And defines the eigenvalues as squared canonical correlations between the levels residuals and the difference residuals. Likewise, in RUEY S. TSAY (2010) Analysis of Financial Time Series, 3rdEdn, Wiley, CH8 pp.432-442.
Why?


To simulate properly I have re-read Simulate a VAR process viewtopic.php?t=3695, but unfortunately am none the wiser. If I want to simulate e.g. 4 cointegrated series (as in small Cointegrated VAR) with the deterministic terms DET=NONE/[CONSTANT]/TREND/RC/RTREND, so 5 simulations, and run johmle.src, how do I in RATS?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

Stochastic trends have variances which increase with T, eventually dominating the stationary parts. There have been quite a few methods proposed to try to determine (a) how many stochastic trends there are and (b) their structure (or equivalently the structure of the stationary parts). Because these use different methods to try to separate the high variance from low variance parts, they can differ in decisions regarding (a) and will basically always disagree on (b). You might want to look at Hamilton, which covers Johansen's ML inference, Stock-Watson and canonical correlations.

Your example in the other thread has 3 variables. Is it that difficult to add a 4th?
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by ac_1 »

TomDoan wrote: Fri Nov 08, 2024 1:59 pm Stochastic trends have variances which increase with T, eventually dominating the stationary parts. There have been quite a few methods proposed to try to determine (a) how many stochastic trends there are and (b) their structure (or equivalently the structure of the stationary parts). Because these use different methods to try to separate the high variance from low variance parts, they can differ in decisions regarding (a) and will basically always disagree on (b). You might want to look at Hamilton, which covers Johansen's ML inference, Stock-Watson and canonical correlations.

Your example in the other thread has 3 variables. Is it that difficult to add a 4th?
Enders AETS, Appendix 6.1, also has Calculating the Characteristic Roots in Johansen's Method, as per the aforementioned texts.

The motivation in simulating cointegrated series is from Enders(1996) HETS CH6 Figure 6.2: Three Cointegrated Series.
- I'd like to know how the plot was generated.
- Thus how to recover the coefficients from the simulation in estimating a VECM (and further seeing how deterministic terms affect results) -- as I would in simulating an AR, MA or VAR process in RATS.

My 3 variable VECM simulation example in the other thread, I do not fully understand as I guessed at the coefficients, and also the variable construction, to create significant ECT variables. From undergrad Maths in a standard e-value/e-vector problem I know that e-values are unique and e-vectors are non-unique, and for a generalized eigen-space as-well. As the e-vectors are non-unique, and as you have stated in the other thread viewtopic.php?t=3695&start=15
TomDoan wrote: Sun Apr 21, 2024 8:49 am "Trying to determine if any particular vector appears to be part of that is very complicated"
"Again, however, why does it matter? The space of cointegrating vectors is all that matters for forecasting."
TomDoan wrote: Wed Apr 24, 2024 7:13 am "@JOHMLE only identifies the subspace of cointegrating vectors"

All-in-all trying to understand cointegration, and JOHMLE.SRC better.

I will have a look at Hamilton.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

You do not need to understand how generalized eigen analysis is used to solve the reduced rank regression problem in order to make sense out of how cointegration itself works. The "stationary" linear combinations are not themselves eigenvectors---they are the linear combinations of the eigenvectors that define what is determined to be the stationary space.

To simulate a model, you need to decide what linear combination(s) of the variables you want to be stationary. Those are completely up to you. The alpha weights on those generally should have the signs to push the model back towards long-run equilibrium. That is, in the equation for x1, if you have x1-x2 as a stationary linear combination, you would typically have a negative coefficient on that. (And a positive one in the x2 equation). That's not necessary (it's possible to have the "wrong" sign in an equation if the rest of the model more strongly pushes towards equilibrium), but it's the typical behavior in practice. Cointegrating vectors often have (hypothesized) +/-1 coefficients because the natural scales of series analyzed together are similar. (A set of bond rates; a set of GDP components), but if you want x1-30x2 as a stationary process, you can do that as well.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

ac_1 wrote: Tue Nov 12, 2024 2:52 am The motivation in simulating cointegrated series is from Enders(1996) HETS CH6 Figure 6.2: Three Cointegrated Series.
- I'd like to know how the plot was generated.
- Thus how to recover the coefficients from the simulation in estimating a VECM (and further seeing how deterministic terms affect results) -- as I would in simulating an AR, MA or VAR process in RATS.
Doesn't he give the formulas used?

Note that there are several ways to generate series which are cointegrated. Figure 6.2 first generates the stochastic trends, then adds stationary behavior around those. That will not directly give you the VECM representation---in fact, the VECM can be quite a complicated function of the parameters in a model built that way. The 3 variable example earlier does a direct simulation of the VECM.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

ac_1 wrote: Tue Nov 12, 2024 2:52 am From undergrad Maths in a standard e-value/e-vector problem I know that e-values are unique and e-vectors are non-unique, and for a generalized eigen-space as-well.
That's not true. At all.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by ac_1 »

TomDoan wrote: Tue Nov 12, 2024 3:01 pm
ac_1 wrote: Tue Nov 12, 2024 2:52 am From undergrad Maths in a standard e-value/e-vector problem I know that e-values are unique and e-vectors are non-unique, and for a generalized eigen-space as-well.
That's not true. At all.

Ahhh sorry :oops: : Eigenvalues can be repeated i.e. non-distinct, and associated with each eigenvalue multiple non-unique linearly independent eigenvectors.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by ac_1 »

TomDoan wrote: Tue Nov 12, 2024 9:08 am
ac_1 wrote: Tue Nov 12, 2024 2:52 am The motivation in simulating cointegrated series is from Enders(1996) HETS CH6 Figure 6.2: Three Cointegrated Series.
- I'd like to know how the plot was generated.
- Thus how to recover the coefficients from the simulation in estimating a VECM (and further seeing how deterministic terms affect results) -- as I would in simulating an AR, MA or VAR process in RATS.
Doesn't he give the formulas used?

Note that there are several ways to generate series which are cointegrated. Figure 6.2 first generates the stochastic trends, then adds stationary behavior around those. That will not directly give you the VECM representation---in fact, the VECM can be quite a complicated function of the parameters in a model built that way. The 3 variable example earlier does a direct simulation of the VECM.

No. p.162 in the Handbook says the 100 observations of 3 simulated variables are on the file COINT1.PRN.

Please can you give example(s) in RATS so the affect of the 5 DET terms can be seen?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

This is from the 4th edition of the book.
enderscreenshot.png
enderscreenshot.png (111.53 KiB) Viewed 131900 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

ac_1 wrote: Wed Nov 13, 2024 1:47 am Please can you give example(s) in RATS so the affect of the 5 DET terms can be seen?
In the 3 variable example, what you had originally was DET=NONE. Put a constant into each equation, you get DET=CONSTANT. Instead, put a constant only inside the error correction term (same one in each occurrence in the model), you get DET=RC. Put a constant and trend inside the error correction term (again, the same in each occurrence in the model), you get DET=RTREND. DET=TREND should be ignored as a possibility.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by ac_1 »

TomDoan wrote: Wed Nov 13, 2024 7:40 am This is from the 4th edition of the book.

enderscreenshot.png

Thanks. Correct?

Code: Select all

*===============================
allocate 150


set eps1 = %ran(1)
set eps2 = %ran(1)

clear(zeros) yt yd y

set(first=0.0) yt = yt{1} + eps1
set(first=0.0) yd = 0.5*yd{1} + eps2
set(first=0.0) y = yt + yd


set eps3 = %ran(1)
set eps4 = %ran(1)

clear(zeros) zt zd z

set(first=0.0) zt = zt{1} + eps3
set(first=0.0) zd = 0.5*zd{1} + eps4
set(first=0.0) z = zt + zd + 0.5*yd


set eps5 = %ran(1)

clear(zeros) wt wd w

set(first=0.0) wt = yt + zt
set(first=0.0) wd = 0.5*wd{1} + eps5
set(first=0.0) w = wt + wd + 0.5*yd + 0.5*zd


prin / y z w


graph(key=upright) 3
# y 51 150
# z 51 150
# w 51 150
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

That looks correct.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by ac_1 »

TomDoan wrote: Wed Nov 13, 2024 7:42 am
ac_1 wrote: Wed Nov 13, 2024 1:47 am Please can you give example(s) in RATS so the affect of the 5 DET terms can be seen?
In the 3 variable example, what you had originally was DET=NONE. Put a constant into each equation, you get DET=CONSTANT. Instead, put a constant only inside the error correction term (same one in each occurrence in the model), you get DET=RC. Put a constant and trend inside the error correction term (again, the same in each occurrence in the model), you get DET=RTREND. DET=TREND should be ignored as a possibility.

I have included the DET terms as described
1) DET=NONE
2) DET=CONSTANT
3) DET=RC
I'm not certain what I have learnt/understood in 1) to 3)?

Attached is 4) DET=RTREND, I cannot seem to include both the CONSTANT and trd variables in EQUATION?
Attachments
4) simulate_cointegrated_system_3variable_VECM(1)_DET=RTREND.rpf
(3.72 KiB) Downloaded 611 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Model of the US Economy: CointegratedVARModelHandbook

Unread post by TomDoan »

x{1}+y{1}-z{1}

and

x{1}-y{1}

are your error correction terms. For DET=RC, you include constants in those. (Can be different for each of the two, but has to be the same in all locations for a given ECT). For DET=RTREND, you include constant and trend in those with the same requirement.
Post Reply