Appending to SUR specification in a for loop

For questions regarding programming in the EViews programming language.

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

Tom Simpson
Posts: 19
Joined: Fri Oct 09, 2009 1:14 am

Appending to SUR specification in a for loop

Postby Tom Simpson » Tue Feb 09, 2010 11:22 pm

Hi all,

I'm currently trying to write a for! loop to create a series of SUR systems involving spot exchange rate as the dependent variable in one system and inflation rate as the dep var in the second system. The SUR systems are designed to test for per-period dummy variable coefficients coupled with a few other coefficients. As there are a bunch of these systems with very similar structures it'd be nice to be able to write a for! loop to create the specifications. Unfortunately in each period there are one fewer independent variable for each of the paired equations. Is there some way to write a for loop which creates sur systems that "get shorter" by one indipendent variable each time?

it might help if i provide an illustration:

say my 1st sur system looks like this:
-s = D1 + X1 + X2 + X3 + X4
r = D1 +X1 + X2 + X3 + X4
2nd system looks like this:
-s = D1 + X1 + X2 + X3
r = D1 +X1 + X2 + X3
3rd systen looks like this:
-s = D1 + X1 + X2
r = D1 +X1 + X2
4th looks like this:
-s = D1 + X1
r = D1 +X1

and so on... only in my setup it goes on for several dozen independent variables. having an efficient way to generate this could be very helpful. it's nice with single equation systems because you can use a for loops to create a series of different sized group (say G1, G2 ... G!z) and then just run for !z = 1 to # LS depend_var G! and you'll get your results. but unfortunately systems don't recognise groups in the same way.

thanks for your help!

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

Re: Appending to SUR specification in a for loop

Postby EViews Gareth » Wed Feb 10, 2010 9:06 am

You can build up the string of the variables 1 by 1 in a for loop. Something like:

Code: Select all

%regs = "c(1)*D1" !i=1 for %j X1 X2 X3 X4 %regs = %regs + "+c(" + @str(!i) + ")*" + %j system s!i s!i.append -s = {%regs} s!i.append r = {%regs} s!i.sur !i=!i+1 next

Tom Simpson
Posts: 19
Joined: Fri Oct 09, 2009 1:14 am

Re: Appending to SUR specification in a for loop

Postby Tom Simpson » Wed Feb 10, 2010 7:36 pm

Thank you! I'll give that a shot right now...


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests