Dummy Variables

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

sabineH
Posts: 3
Joined: Sun May 11, 2014 6:05 am

Re: Dummy Variables

Postby sabineH » Sun May 11, 2014 6:55 am

Hello, thanks for the useful guide on how to make and use dummy variables!
I read the guide, the eviews manual and did some research on the internet and on this website, but unfortunately my dummy variables in my panel dataset are still not working. this is my model:

cfp_roa_wins c csp_cg_average(-1) csp_env_average(-1) csp_soc_average(-1) crisis_dummy crisis_dummy*csp_cg_average(-1) crisis_dummy*csp_env_average(-1) crisis_dummy*csp_soc_average(-1) risk_wins @log(ws_totalassets) @expand(year,@droplast) @expand(country, @drop("AUS")) @expand(industry_code,@dropfirst)

With the @drop command I thought I circumvented the dummy trap. I build up the model one variable at the time, but all three dummy variables in the end are not working, when I add one or all three of them eviews states: nearly singular matrix, but since I already excluded one dummy with the @drop command I do not know what to do to change the dummies so the equation can be run.

Can you maybe help me what I can do to make my model work?
I would very much appreciate your help!
I am working in Eviews 7, version 7.2 serial nr: 70K00168

ps. for some reason I am not able to attach my workfile, I tried it in internet explorer and mozilla firefox.

nadine1788
Posts: 1
Joined: Sun May 25, 2014 9:22 am

Re: Dummy Variables

Postby nadine1788 » Sun May 25, 2014 9:32 am

I have a question about the use of dummies in eviews 6.

I have 3 independent variables all 3 are dummies, I already gave them the number 1 or 0 in excel.
Now I have opened the excel file in eviews and all the data is in there, but if I do a multiple regression I get very high
probabilities. Do I have to add something to the formula in order to activate the dummies or something?

I dont have any experience with eviews whatsoever.

Grtz. Nadine

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

Re: Dummy Variables

Postby EViews Gareth » Sun May 25, 2014 12:49 pm

No, you do not need to do anything. EViews (or, more correctly OLS calculation) doesn't care if they are dummies or not.
Follow us on Twitter @IHSEViews

gerrard
Posts: 17
Joined: Sun Mar 02, 2014 5:38 am

Re: Dummy Variables

Postby gerrard » Thu Jun 05, 2014 8:59 am

EViews Gareth wrote:We get asked questions on dummy variable creation in EViews fairly regularly, so I thought I'd write up a quick all-inclusive guide.
Simple Dummies
The easiest way to create a dummy variable is with the @recode function. @recode lets you specify a logical test, and the values a variable should take if that test is true, or if it is false:

Code: Select all

series dummy1 = @recode(X>0.5, 1, 0)

This will create a series called dummy1 that is equal to 1 whenever the series X is greater than 0.5, and equal to 0 otherwise. You can use the AND or OR operators to make more complicated logical tests:

Code: Select all

series dummy2 = @recode(X>=0.5 and X<=1, 1, 0)

will create a dummy that is equal to 1 whenever X is between 0.5 and less than 1.


I need an or-condition within an and-condition. Specifically, I need the following (trying to generate a dummy called FAM):

FAM = if UFAMO>50 and if (FAMCEO=1 or FAMCB=1), then 1, otherwise 0.

Code: Select all

fam = @recode(ufamo>50 and (famceo=1 or famcb=1), 1, 0)
does not work.

If I want:
FAM = if UFAMO>50 or if FAMCEO=1 or if FAMCB=1, then 1, otherwise 0.

Code: Select all

fam = @recode(ufamo>50 or famceo=1 or famcb=1, 1, 0)
does not work either.

Checked in Excel with an IF formula containing AND and OR (which gives the correct result), the 1 and 0 in the generated EViews series are not correct.

Can anyone help?

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

Re: Dummy Variables

Postby EViews Gareth » Thu Jun 05, 2014 9:16 am

Seems to work for me:

Code: Select all

create u 100
rndseed 1
series ufamo=@nrnd+50
series famceo=@nrnd>0
series famcb=@nrnd>0


series fam = @recode(ufamo>50 and (famceo=1 or famcb=1), 1, 0)

show ufamo famceo famcb fam
Follow us on Twitter @IHSEViews

samiha
Posts: 3
Joined: Tue Aug 26, 2014 11:51 am

Re: Dummy Variables

Postby samiha » Tue Aug 26, 2014 2:16 pm

Dear Concerned,

Im a masters student and I am stuck with a very crucial problem while doing my dissertation...could you please help me out. Basically I have to regress abnormal returns(returns) VS P/E ratio. And one of my aims is to show that belonging to different industries can have an effect on returns. For that I have to create dummy variables for 11 different industries and also PE ratio as another variable in the regression. In the regression, returns will be the dependent variable and the 11 different industries (in dummy variables) and PE ratios will be the independent variables. Could you please thus help me out by telling me..is it possible to create and run such a regression in e-views..? I have read about the dummy variable trap and thus I understand that I cannot include a constant in this regression...so I would also like to ask..will it be a meaningful regression without a constant in it and all the above mentioned independent variables?
Finally could you please help me out, by telling me how to do it if it can be done..I read the blog and I am thinking I would place the numbers 1 to 11 for the 11 industries or 1 to 10 (if I should do K-1 Dummy variables). But could you please tell me what to actually write in the command window and for the equation estimation?

Thanks alot in advance,
Regards,
Samiha

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

Re: Dummy Variables

Postby EViews Gareth » Tue Aug 26, 2014 2:18 pm

Follow us on Twitter @IHSEViews

Jingga
Posts: 7
Joined: Thu Jan 29, 2015 5:08 am

Re: Dummy Variables

Postby Jingga » Thu Jan 29, 2015 5:20 am

Hi Gareth,

Ive been working my way through this forum and the EViews helpfile, but I am unable to find an answer about my problem.

I have a hugh panel data set of bilateral tradeflows between 179 exporters and a possible number of 192 importers, resulting in about 29365 cross-sections. Everything works just fine, but I, like others, encounter the Near Singular Matrix problem while adding country-specific dummies.

I constructed them manually ofcourse, with the following command: genr norway= @recode(reporting="Norway" or partner="Norway", 1, 0), as you see from the alpha series 'reporting' and 'partner'.

When I include them into my benchmark model (-1 to avoid the dummy trap, so 191), I get the Near Singular Matrix error. I checked some descriptive stats but I cant find the source of the problem, and none of the variables seem to be collinear or perfectly correlated. Does it have something to do with the amount of dummies?

Hope you can help!

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

Re: Dummy Variables

Postby EViews Gareth » Thu Jan 29, 2015 6:25 am

You've probably still fallen into the dummy variable trap. Look at the dummies and make sure they are definitely different.
Follow us on Twitter @IHSEViews

Jingga
Posts: 7
Joined: Thu Jan 29, 2015 5:08 am

Re: Dummy Variables

Postby Jingga » Fri Jan 30, 2015 2:40 am

If there would be duplicates, I would see a correlation of 1 in a correlation matrix right? I don't see any (selected all the dummies as group > covariance analysis > correlation).

I just accidently discovered that two sets of two of my dummies (out of 191....) show the exact same correlation with every other dummy, but do not correlate perfectly with each other! This is crazy right?

Here you can see, France & Finland and Denmark & Cyprus. Gambia & Gabon also look alike, but also show some differences...

Image

edit: There are more pairs like these. Checked the dummy values but they're correct. Does EViews fail to pick up the differences correctly?

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

Re: Dummy Variables

Postby EViews Gareth » Fri Jan 30, 2015 6:24 am

We'd need to see the workfile.
Follow us on Twitter @IHSEViews

newtoeviews
Posts: 7
Joined: Fri Jan 23, 2015 8:51 am

Re: Dummy Variables

Postby newtoeviews » Fri Jan 30, 2015 8:02 am

hi all,

follow your direction, I wanted to test my model from year 2006 to 2011, so that I created them directly in equation (ls log(y) log(x2) log(x3) log(x4) x7 x8 x9 @year<=2011 @year>=2006) I wonder however if it is correct command or wrong in this case, even though I have the result. If it is the case, how should I interpret the result?

Best regards, HM

Dependent Variable: LOG(Y)
Method: Panel Least Squares
Date: 01/30/15 Time: 15:39
Sample: 2000 2013
Periods included: 14
Cross-sections included: 84
Total panel (balanced) observations: 1176

Variable Coefficient Std. Error t-Statistic Prob.

LOG(X2) 1.415035 0.079953 17.69825 0.0000
LOG(X3) -0.677577 0.127020 -5.334424 0.0000
LOG(X4) -0.797558 0.207332 -3.846768 0.0001
X7 -9.00E-06 8.62E-06 -1.043420 0.2970
X8 -9.62E-05 0.000818 -0.117545 0.9064
X9 -1.026969 0.459499 -2.234976 0.0256
@YEAR>2005 1.414356 0.554575 2.550344 0.0109
@YEAR<=2011 -0.119135 0.708580 -0.168132 0.8665

R-squared 0.291427 Mean dependent var 12.20850
Adjusted R-squared 0.287180 S.D. dependent var 5.834316
S.E. of regression 4.925835 Akaike info criterion 6.033644
Sum squared resid 28340.18 Schwarz criterion 6.068133
Log likelihood -3539.783 Hannan-Quinn criter. 6.046649
Durbin-Watson stat 0.764613

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

Re: Dummy Variables

Postby startz » Fri Jan 30, 2015 8:06 am

You added dummy variables rather than limiting the sample. Is that what you intended?

newtoeviews
Posts: 7
Joined: Fri Jan 23, 2015 8:51 am

Re: Dummy Variables

Postby newtoeviews » Fri Jan 30, 2015 8:39 am

Exactly, I wanted to limit the sample size that only for 5 years in total 14 years. So if it is correct?

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

Re: Dummy Variables

Postby startz » Fri Jan 30, 2015 9:13 am

Nope. Look at the smpl command in the system.


Return to “Estimation”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests