Real-time programming

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Savy
Posts: 4
Joined: Fri Apr 01, 2011 1:15 am

Real-time programming

Postby Savy » Fri Apr 01, 2011 1:51 am

Hi,

I'm using EViews 6 to calculate real-time estimations, i.e. I'm using loops over vintages to create series, estimate equations etc. for every vintage

Code: Select all

for !vi = @dtoo(%vfirst) to @dtoo(%vlast) ' loop over QUARTERS %v = @otod(!vi) ... next
This works totally fine with %v being my current vintage in the loop, and {%v} being used for dynamic variable names.

However, I noticed that this only works when vintages and periods share the same frequency (e.g. quarters). Using annual data but a quarterly vintage frequency, these loops do not work anymore. Does anyone have an idea how to solve this? One possible way, although a rude one, would be

Code: Select all

for !vi = @dtoo(%vfirst) to @dtoo(%vlast) ' now a loop over YEARS %v = @otod(!vi) ... ' for quarter 1 %vq1 = %v + "q1" ... ' for quarter 2 %vq2 = %v + "q2" ... 'etc ... next
Any programming efficiency hint would be appreciated too. I considered using pools (with the vintages being cross-sections), but the number of pool functions not being explicitely for panel/pooled data is somewhat limited..

Thanks in advance. Best
Savy

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

Re: Real-time programming

Postby EViews Gareth » Fri Apr 01, 2011 8:16 am

Maybe it is early in the morning, but I can't quite get a handle on what you're doing, so I can't quite figure out a way to do it better. Could you give a more concrete example of how it works for quarterly data, and how it doesn't work for annual?

Savy
Posts: 4
Joined: Fri Apr 01, 2011 1:15 am

Re: Real-time programming

Postby Savy » Mon Apr 11, 2011 6:21 am

Hi Gareth. Thanks for your response, sorry for the late answer, and I'll give it a second try.

The calculations I'm doing treat old, past data. I use series that contain values which change over time - one important case is GDP, which gets revised quite often and quite substantially. Thus, I need different 'versions' for one series, where the version is usually called "vintage" and defines, when this series was 'captured' or 'measured'.

Now imagine that starting from these GDP series, I want to calculate a filtered series for each vintage of GDP:
1. I start with different "vintages" for one series, i.e. GDP
- gdp_v1999q3
- gdp_v1999q4
where the series cover GDP values from around 1960s to 1999q3 in the first case, and to 1999q4 in the second case.
2. Now I want to calculate the output gap for each vintage by taking - in a simple case - the difference of the logs of the non-filtered and the filtered series. Hence, I create a loop for each vintage (in this example, we only have two vintages, in my case up to 80):

Code: Select all

%vintagefirst = "1999q3" %vintagelast = "1999q4" for !vint = @dtoo(%vintagefirst) to @dtoo(%vintagelast) %v = @otod(!vi) gdp_v{%v}.hpf(lambda=1600) gdp_filtered_v{%v} gdp_gap_v{%v} = log(gdp_v{%v}) - log(gdp_filtered_v{%v}) next
Hence, I get the series
- gdp_v1999q3
- gdp_v1999q4
- gdp_filtered_v1999q3
- gdp_filtered_v1999q4
- gdp_gap_v1999q3
- gdp_gap_v1999q4

When I have an annual workfile, instead of a quarterly one, the loop over the vintages also follows an annual pattern (due to the functions otod and dtoo I'm using). Hence, what I get are these series
- gdp_v1999
- gdp_filtered_v1999
- gdp_gap_v1999

Thus, these loops work well, as long as the vintages and the workfile have the same frequency. If these frequencies diverge, the loop does not work properly anymore. Thus, my (two) questions:
1. Do you see a different approach than loops, improving calculation time?
2. Do you see an easy procedure to treat annual values, but still keeping the quarterly vintage frequency?

Best

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

Re: Real-time programming

Postby EViews Gareth » Mon Apr 11, 2011 8:14 am

Ah, that makes perfect sense now.

The easiest thing to do would be to simply have a list of all the vintages that you'll be using, and then loop over that list. Could be in a svector, or a word list. Thus something like:

Code: Select all

%vintages = "1990q1 1990q2 1990q3 1990q4 1991q1 1991q2 1991q3 1991q4" for !i=1 to @wcount(%vintages) %v = @word(%vintages, !i) '.... next

If that is too cumbersome (if you have a lot of vintages, I can see it would be), then you could use some of the built in date functions. The following will do the same as the above example (i.e. quarterly from 1990q1 to 1991q4):

Code: Select all

%start = "1990q1" !num = 8 for !i=1 to !num !pers = !i-1 %v = @datestr(@dateadd(@dateval(%start), !pers, "Q"), "YYYY[q]Q") next

Savy
Posts: 4
Joined: Fri Apr 01, 2011 1:15 am

Re: Real-time programming

Postby Savy » Mon Apr 11, 2011 11:28 pm

Many thanks Gareth, this looks nice.

At a first glance, I'll first create the dates/vintages string once with your second suggestion, and then use it whenever needed with your first suggestion.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests