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.
Categorical Dummy Variable Help
Moderators: EViews Gareth, EViews Moderator
Re: Categorical Dummy Variable Help
hi
So, what's your problem?You can't get the estimating output?
So, what's your problem?You can't get the estimating output?
Re: Categorical Dummy Variable Help
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?
IF is not defined in "GENR DUM1=1 IF REGION=1 ELSE DUM1=0"
How can I fix this error?
Re: Categorical Dummy Variable Help
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.
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 Developer
- Posts: 2672
- Joined: Wed Oct 15, 2008 9:17 am
Re: Categorical Dummy Variable Help
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
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
Re: Categorical Dummy Variable Help
QMS Glenn,
Thank you very much for your suggestion. It helped me save a lot of time.
Thank you very much for your suggestion. It helped me save a lot of time.
Who is online
Users browsing this forum: No registered users and 44 guests