Page 1 of 1

Loop Programming and Estimation

Posted: Tue Jul 10, 2012 5:47 am
by canboardrp
I've got a number of variables with similar names that I'd like estimate in a similar manner.

For each variable the naming memnomic take the form of: CA_12_POP where:

-"CA" is the country. In this case it's Canada, but I've also go US, UK, FR
-"12" is the province/state/region
-"Pop" indicates that this var is population, but there's others incl GDP, DPC, etc.

I've used simple loop programming before of the type (example below, not actual eqn)

Code: Select all

For %1 CA US UK equation {%1}.ls GDP{%1} C POP{%1} ERATE Next
My question is, how would I write the code/program to estimate the above example equation if I wanted to test it at the regional level? Would it take the form below or would I need to use a different form of programming?:

Code: Select all

For %1 CA US UK %2 1 2 3 4 5 equation{%1}_{%2}.ls GDP{%1}_{%2} C POP{%1}_{%2} ERATE Next

Re: Loop Programming and Estimation

Posted: Tue Jul 10, 2012 6:15 am
by sean123
You'd need two loops in that case.

Code: Select all

for %1 CA US UK for %2 1 2 3 4 5 equation{%1}_{%2}.ls GDP{%1}_{%2} C POP{%1}_{%2} ERATE next next
That way it will first go from 1 to 5 for CA, then 1 to 5 for the US and then 1 to 5 for the UK as the inner loop is performed first. If you have already estimated the equations and simply want to reestimate them you could also use:

Code: Select all

%eqlist=@wlookup("*","equation") for !i=1 to @wcount(%eqlist) %eq = @word(%eqlist,!i) %estcmd = {%eq}.@command {%eq}.{%estcmd} next
which was provided by Eviews Gareth in some thread and it is a real handy code to know as it can be used in many situations.

Re: Loop Programming and Estimation

Posted: Tue Jul 10, 2012 6:17 am
by canboardrp
Thanks for the reply.

I've been reading through some of the programming threads and making notes as I'm going. Just hadn't seen case before.