Categorical Dummy Variable Help

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

Economist
Posts: 7
Joined: Wed Nov 04, 2009 4:38 pm

Categorical Dummy Variable Help

Postby Economist » Wed Nov 04, 2009 7:05 pm

Hi,

I am trying to create categorical dummy variables for a variable called "region" in order to see the probability of being poor in these specific regions(such as dum1, dum2, dum3...etc) by using the probit model. Nevertheless, although I tried several different ways, I couldn't find out where I was doing wrong. I would highly appreciate if anyone tells me what my mistake is and how I can fix it. Here is the code;

open poverty.wf1
output(t) poverty.txt
pon
include subs.prg
smpl 1 1937

genr dum1=1 if region=1 else dum1=0
genr dum2=1 if region=2 else dum2=0
genr dum3=1 if region=3 else dum3=0
genr dum4=1 if region=4 else dum4=0
genr dum5=1 if region=5 else dum5=0
genr dum6=1 if region=6 else dum6=0
genr dum7=1 if region=7 else dum7=0

probit poor3e c dum1 dum2 dum3 dum4 dum6 dum7

output off
close poverty.wf1
open poverty.txt

PS:I intentionally left dum5 out in order not to have near singular matrix.

ermutuxia
Posts: 2
Joined: Sun Nov 01, 2009 11:41 pm

Re: Categorical Dummy Variable Help

Postby ermutuxia » Wed Nov 04, 2009 7:27 pm

hi
So, what's your problem?You can't get the estimating output?

Economist
Posts: 7
Joined: Wed Nov 04, 2009 4:38 pm

Re: Categorical Dummy Variable Help

Postby Economist » Wed Nov 04, 2009 7:32 pm

When I run the program, it gives the error message

IF is not defined in "GENR DUM1=1 IF REGION=1 ELSE DUM1=0"

How can I fix this error?

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Categorical Dummy Variable Help

Postby startz » Wed Nov 04, 2009 9:25 pm

Try

Code: Select all

genr dum1 = @recode(region=1,1,0)

Economist
Posts: 7
Joined: Wed Nov 04, 2009 4:38 pm

Re: Categorical Dummy Variable Help

Postby Economist » Tue Nov 10, 2009 8:12 am

thank you startz for the suggestion. it worked out!

All right, so do you or does anyone have a suggestion about how to create a dummy variable which would combine two characteristics in itself? To detail, I used

genr edu1=@recode(edlevel=1,1,0)
genr edu2=@recode(edlevel=2,1,0)
genr edu3=@recode(edlevel=3,1,0)
genr edu4=@recode(edlevel=4,1,0)

EDLEVEL 1=primary education only 2=didn't complete high school 3= high school only 4=higher education

to see the educational effect on poverty. I would appreciate if anybody advises on coding about how to combine edlevel=1 and edlevel=2 (primary education only and didn’t complete high school) in one dummy variable. I will keep edu3 and edu4 but I need to see the combined effect of edu1 and edu2.
Thanks in advance.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Categorical Dummy Variable Help

Postby EViews Glenn » Tue Nov 10, 2009 10:41 am

A slight variant on Startz's original suggestion is to generate the (0,1) directly using

series edu1= edlevel=1

which is perhaps less transparent, but equivalent.

Thus, a simple way of doing what you want is

series edu12 = edu1=1 or edu2=1

or from the originals

series ed12 = edlevel=1 or edlevel=2

Economist
Posts: 7
Joined: Wed Nov 04, 2009 4:38 pm

Re: Categorical Dummy Variable Help

Postby Economist » Wed Nov 18, 2009 4:34 pm

QMS Glenn,

Thank you very much for your suggestion. It helped me save a lot of time.


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 44 guests