Loop Programming and Estimation

For questions regarding programming in the EViews programming language.

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

canboardrp
Posts: 17
Joined: Tue Mar 06, 2012 9:11 am

Loop Programming and Estimation

Postby canboardrp » Tue Jul 10, 2012 5:47 am

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

sean123
Posts: 34
Joined: Wed Apr 25, 2012 11:53 am

Re: Loop Programming and Estimation

Postby sean123 » Tue Jul 10, 2012 6:15 am

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.

canboardrp
Posts: 17
Joined: Tue Mar 06, 2012 9:11 am

Re: Loop Programming and Estimation

Postby canboardrp » Tue Jul 10, 2012 6:17 am

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 0 guests