Novice question: Loop

For questions regarding programming in the EViews programming language.

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

popdycentral
Posts: 7
Joined: Tue May 20, 2014 4:55 am

Novice question: Loop

Postby popdycentral » Mon Jun 02, 2014 5:32 am

Hi,

I'm trying to create a loop OLS regression for a set of 30 countries, but it keeps alerting me with error messages. I've read some manuals, but I still haven't worked out....

Take US for example
I have the independent variables like this: US_GDP, US_UNEMPLOYMENT, etc

I have dependent variable as: US_RATE

I'd like to repeat command US_RATE c US_GDP US_UNEMPLOYMENT for rest of 29 countries

How can I do that.....?
Sorry for this novice question, this is the first programming attempt for me....

Thank you!

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

Re: Novice question: Loop

Postby EViews Gareth » Mon Jun 02, 2014 7:36 am


popdycentral
Posts: 7
Joined: Tue May 20, 2014 4:55 am

Re: Novice question: Loop

Postby popdycentral » Mon Jun 02, 2014 7:41 am

Hi Gerah,

I've viewed that page many times before I posted the question, but my problem seems simpler than that...so I've tried to simply
put a string for my 30 countries
%country="us, uk,..."
then set an equations as
{%country}_RATE c {%country}_GDP {%country}_UNEMPLOYMENT

But it doesn't work...

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

Re: Novice question: Loop

Postby EViews Gareth » Mon Jun 02, 2014 7:49 am

Try it without the commas.

popdycentral
Posts: 7
Joined: Tue May 20, 2014 4:55 am

Re: Novice question: Loop

Postby popdycentral » Mon Jun 02, 2014 8:02 am

sorry, the comma wasn't in my codes for eviews. The error says %country is not a valid string or scalar name.

I just want to repeat same regression for 30 countries.

they all have same dependent and independent variables corresponding to their own countries.

so my dataset is like:
us_rate, us_gdp, us_unemployment
uk_rate, uk_gdp, uk_unemployment
fr_rate, fr_gdp, fr_unemployment
.................

This is what I have done:
--------------------------------
%country="us uk fr"
{%country}_rate c {%country}_gdp {%country}_unemployment
--------------------------------

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

Re: Novice question: Loop

Postby EViews Gareth » Mon Jun 02, 2014 8:09 am

You need to use a FOR loop to loop through the values in %country.

popdycentral
Posts: 7
Joined: Tue May 20, 2014 4:55 am

Re: Novice question: Loop

Postby popdycentral » Tue Jun 03, 2014 6:31 am

Hi, Thank you for the help.
I've worked it out. (It's simple but it took me some time..)

I;m wondering how I can add Newey-West options through the looping?

thanks.

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

Re: Novice question: Loop

Postby EViews Gareth » Tue Jun 03, 2014 6:38 am

Estimate the equation via dialogs, then click on View->Representations to see what the command line form is.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests