Page 1 of 1

Dummy variables: Creating by mapping to an Alpha series.

Posted: Wed Jan 27, 2010 10:41 pm
by Vladimir_Yorrick
Hi,

I am using EViews 7.

In an undated workfile with range = 15 I have an alpha series named Country:
Country = {AUT, AUT, AUT, BLX, BLX, BLX, BLX, BGR, BGR, CYP, CYP, CYP, CYP, CYP, CZE}.

Is there an easy way for me to create the following five dummies?
d_AUT = {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
d_ BLX = {0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0}
d_BGR = {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}
d_CYP = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}
d_CZE = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}

The commands below don't work but I hope it shows what I'm trying to do:

for %ctr AUT BLX BGR CYP CZE
series d_{%ctr} = stick a one in the same element when @elem(Country) = {%ctr}
next

or

for %ctr AUT BLX BGR CYP CZE
series d_{%ctr} = @recode(Country = {%ctr},"1","0")
next

Thanks in advance for any suggestions.

Vlad.

Re: Dummy variables: Creating by mapping to an Alpha series.

Posted: Thu Jan 28, 2010 8:33 am
by EViews Gareth
The best way is probably just to make an automatic group from them:

group g @expand(country)

Re: Dummy variables: Creating by mapping to an Alpha series.

Posted: Fri Jan 29, 2010 12:55 am
by Vladimir_Yorrick
Thanks Gareth.

I'm still having some problems with this.

FYI, my alpha series Country is a lot larger than 15 observations and contains country codes that are not listed in alphabetical order.

After creating the group g, the group members will be:
CODE="AUT"
CODE="BLX"
CODE="BGR"
CODE="CYP"
CODE="CZE"

How would I then:
- create 5 series objects
- where each series is equal to the appropriate 'column' of the group
- and have each series automatically named d_AUT, d_BLX, d_BGR, d_CYP and d_CZE?

If these commands
for !i = 1 to 5
series d_{g.@seriesname({!i})} = g({!i})
next
were to work (which they don't) I would end up getting series with names like:
d_CODE="AUT"
d_CODE="BLX",
etc.

Vlad.

Re: Dummy variables: Creating by mapping to an Alpha series.

Posted: Fri Jan 29, 2010 9:03 am
by EViews Gareth
Your original code, with a tweak, might be the way to go then:

for %ctr AUT BLX BGR CYP CZE
series d_{%ctr} = @recode(Country = %ctr,1,0)
next

Re: Dummy variables: Creating by mapping to an Alpha series.

Posted: Mon Feb 01, 2010 11:03 pm
by Vladimir_Yorrick
Thanks Gareth, that worked.

Vlad.