Page 1 of 1

Appending to SUR specification in a for loop

Posted: Tue Feb 09, 2010 11:22 pm
by Tom Simpson
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!

Re: Appending to SUR specification in a for loop

Posted: Wed Feb 10, 2010 9:06 am
by EViews Gareth
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

Re: Appending to SUR specification in a for loop

Posted: Wed Feb 10, 2010 7:36 pm
by Tom Simpson
Thank you! I'll give that a shot right now...