DOFOR LOOP

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
wljames
Posts: 3
Joined: Fri Dec 02, 2011 8:50 pm

DOFOR LOOP

Unread post by wljames »

I am trying to create a dofor loop for series. The following is my attempt:

I have read the data in correctly. The data is panel data from the Applied Econometric Times Series Text - exchange rates

dofor i = australia canada france germany japan netherlands uk us
set lx = log(i)

At this point I check the Series Windows in RATS 8.1 and lx has no observations. What am I doing wrong? :?

Thanks!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: DOFOR LOOP

Unread post by TomDoan »

wljames wrote:I am trying to create a dofor loop for series. The following is my attempt:

I have read the data in correctly. The data is panel data from the Applied Econometric Times Series Text - exchange rates

dofor i = australia canada france germany japan netherlands uk us
set lx = log(i)

At this point I check the Series Windows in RATS 8.1 and lx has no observations. What am I doing wrong? :?

Thanks!
i at that point is a number, representing a series but not parsed as one. You need to use

set lx = log(i{0})

to get the proper results.
wljames
Posts: 3
Joined: Fri Dec 02, 2011 8:50 pm

Re: DOFOR LOOP

Unread post by wljames »

dofor i = australia canada france germany japan netherlands uk us

set lx = log(i{0})

When I execute the above lx still have zero observations. I checked another source and it suggested the following, but I do not know what is meant by [series]

log [series]i / lx

I am a beginner and I respectfully request anyone's help. Thank you! :shock:
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: DOFOR LOOP

Unread post by moderator »

You don't need or want the type modifier (the [series] tag) on the LOG instruction. You would just do:

log i / lx

For an instruction like this, RATS knows that the first parameter has to be a series, so if you supply an integer, it automatically treats it as a series number.

RATS can't make that assumption when an integer appears on the right side of a SET instruction (it has no way of knowing that you mean for an integer to refer to a series number). That's why you would need to add lag notation or a type modifier:

set lx = log(i{0})

or

set lx = log([series] i)

Any of the three above commands is correct. If you are still getting missing values in all entries for LX using any of these, then the source of the problem lies elsewhere. The first step would be to check the original series. For example, do:

print / australia canada france germany japan netherlands uk us

Do the data look correct? If not, work back from there to see where you've made a mistake.

Regards,
Tom Maycock
Estima
Post Reply