Dynamic Sample Setting Using Strings

For questions regarding programming in the EViews programming language.

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

autocorrelation
Posts: 3
Joined: Tue May 17, 2011 11:51 am

Dynamic Sample Setting Using Strings

Postby autocorrelation » Tue May 17, 2011 12:10 pm

I am running into a very unusual problem. I am working with real-time data, and the series have been named according to their vintage ie. gdp_jan2009 corresponds to the GDP release from January 2009.

I am trying to update some old RATS code to run in eViews. The idea is that we loop through all of the series, tracking what the last date was, and store the corresponding estimates from each date. The problem that I run into is in setting the dates:

Code: Select all

%fin = @otod(@ilast(gdp_apr2009)) smpl 1970Q1 %fin equation eq_bench_test.ls gdp_apr2009 c gdp_apr2009(-1) 'stop 'Initialization - need a series of scalars for each quarter that tracks how many times that has been the last quarter (may be between 2 and 4 revisions for each quarter) for !yr = 1999 to 2011 for %i jan feb mar apr may jun jul aug sep oct dec %fin = @otod(@ilast(gdp_{%i}{!yr})) scalar numlast_{%fin} = 1 next next for !yr = 1999 to 2011 for %i jan feb mar apr may jun jul aug sep oct dec %fin = @otod(@ilast(gdp_{%i}{!yr})) smpl 1970Q1 %fin equation eq_bench_{%i}{!yr}.ls gdp_{%i}{!yr} c gdp_{%i}{!yr}(-1) next next
The equation_bench_test uses the correct sample for the April 2009 GDP release, estimating over 1970Q1 to 2008Q4. Indeed, in the first loop, where I create my tracking scalars, everything works well also, with all of the scalars created with the appropriate names. It is the second loop that doesn't work - the sample is continually set to 1970Q1 1998Q3 (which incidentally corresponds to the last observation of the first series - the january 1999 vintage). I can't for the life of me figure out a way to get the sample to change correctly.

I'd like to be able to use the smpl command to store all of the estimated betas in the corresponding end of sample date to create several time series (the first loop helps me to create multiple series for vintages in a given quarter). Does anyone have any experience writing this type of loop?

Many, mank thanks.

EDIT: Forgot to mention that I am using EViews 6.

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

Re: Dynamic Sample Setting Using Strings

Postby EViews Gareth » Tue May 17, 2011 1:16 pm

First, quick, guess is that you should probably have:

Code: Select all

smpl 1970Q1 {%fin}

autocorrelation
Posts: 3
Joined: Tue May 17, 2011 11:51 am

Re: Dynamic Sample Setting Using Strings

Postby autocorrelation » Tue May 17, 2011 1:21 pm

I've tried it both ways, but I still get the same problem (note that it works without the curly braces in the test case earlier in the code)..

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

Re: Dynamic Sample Setting Using Strings

Postby EViews Gareth » Tue May 17, 2011 1:28 pm

@ilast is sample based. Currently you're not resetting the sample back to the entire workfile sample prior to using the function, thus it is returning a value based upon the sample from the previous iteration of the loop.

Try this:

Code: Select all

smpl @all %fin = @otod(@ilast(gdp_{%i}{!yr})) smpl 1970Q1 {%fin}

autocorrelation
Posts: 3
Joined: Tue May 17, 2011 11:51 am

Re: Dynamic Sample Setting Using Strings

Postby autocorrelation » Tue May 17, 2011 1:41 pm

Brilliant! Worked like a charm.

Many thanks for your (extremely fast) help.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest