## generating interdependent series goes wrong

For notifying us of what you believe are bugs or errors in EViews.

Moderators: EViews Gareth, EViews Moderator

grabodan
Posts: 7
Joined: Thu Jun 11, 2015 6:36 am

### generating interdependent series goes wrong

Hi all,

I want to create three series that are dependent on each others past, as for simulating VAR-model or cointegrated data.
I have the following code:

Code: Select all

`workfile u 1000smpl @allseries common_root=0series var1=0 'Just three variables var1, 2 and 3series var2=0series var3=0smpl 2 @lastcommon_root=common_root(-1)+@nrndvar1=var1(-1)-0.5*(var1(-1)-var2(-1)-var3(-1)) + common_rootvar2=var2(-1) +0.25*(var1(-1)-var2(-1)-var3(-1))var3=var3(-1) +0.25*(var1(-1)-var2(-1)-var3(-1))`

Series 2 and 3 should be exactly the same. They should be computed at the same time, depending on each others past but not the contemporaneous values.
The Problem is, they (a) are quite different from each other (var2 sticks close to var1 while var3 sticks around the zero line) and (b) if I change the order of the code (switching the ordering of var2 and 3):

Code: Select all

`var1=var1(-1)-0.5*(var1(-1)-var2(-1)-var3(-1)) + common_rootvar3=var3(-1) +0.25*(var1(-1)-var2(-1)-var3(-1))var3=var3(-1) +0.25*(var1(-1)-var2(-1)-var3(-1))`

...the result changes (i.e. var3 now sticks around var1 and var2 sticks to the zero). Both things should not happen.
If I instead use a for loop such as below, it works as it should:

Code: Select all

`smpl @allseries v1=0series v2=0series v3=0for !t=2 to 1000v1(!t)= v1(!t-1) - 0.5*( v1(!t-1) - v2(!t-1) - v3(!t-1) ) + common_root(!t)v2(!t)= v2(!t-1) +0.25*( v1(!t-1) - v2(!t-1) - v3(!t-1) )v3(!t)= v3(!t-1) +0.25*( v1(!t-1) - v2(!t-1) - v3(!t-1) )next`

I don't quite understand why that is but there has to be a problem with the way EViews computes the vectors / series (Does the program overlook the interdependency and computes the series one after the other?)

I have Version 8.1 Build Nov 11 2014.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12543
Joined: Tue Sep 16, 2008 5:38 pm

### Re: generating interdependent series goes wrong

I'm not quite sure what you expect to happen.

EViews programs are computed line by line.

startz
Non-normality and collinearity are NOT problems!
Posts: 3573
Joined: Wed Sep 17, 2008 2:25 pm

### Re: generating interdependent series goes wrong

EViews computes all of var2 and then all of var3. That's why you're getting the difference.

EViews Glenn
EViews Developer
Posts: 2642
Joined: Wed Oct 15, 2008 9:17 am

### Re: generating interdependent series goes wrong

The model object may be used to evaluate the system of equations observation by observation.

grabodan
Posts: 7
Joined: Thu Jun 11, 2015 6:36 am

### Re: generating interdependent series goes wrong

EViews Gareth wrote:I'm not quite sure what you expect to happen.

EViews programs are computed line by line.

Hi,
thanks for the reply. Well I thought that EViews would automatically handle this. I mean, treating a vector as a series so that you dont need a for loop but only need to write y=alpha*y(-1) is a neat feature of EViews.
Because of that I expected that EViews always computes one point in time after the other, kind of an implicit for loop. And I expected to never need a loop for the creation of series
Apparently that was naive.
Ok then. sorry for crying wolf

Btw I used to create vector series that way and never noticed my results are ****

EViews Glenn
EViews Developer
Posts: 2642
Joined: Wed Oct 15, 2008 9:17 am

### Re: generating interdependent series goes wrong

A bit of context...

The problem with always computing one point in time after the other is that EViews doesn't know when to start the evaluation. Suppose that you enter one series generation command and type return, should EViews generate all of the observations for that series, or wait for you to enter another command? And if it is going to wait, how long should it wait? Until the second, fifth, twentieth command? There is an implicit loop, but over the single series generation command; as Gareth says, line-by-line.

It is true that it is very useful to compute one point in time after another for a set of commands. EViews offers a specific object, the model object, for doing so. In this case you define an object with the set of commands you want to generate as a set, and tell EViews to solve the model an observation at a time. This creates your implicit loop over a set of commands. For your purposes, I think you'll find it useful.