SlideShare a Scribd company logo
1 of 47
EViews Training
Dummy Variables
Note: Data and workfiles for this tutorial are provided in:
 Data: Data.xlsx
 Results: Results.wf1
 Practice Workfile: Data.wf1
Data and Workfile Documentation
• Data.wf1 and Data.xlsx consist of two pages (tabs) with the following data:
• Workfile Page: Dated (Data.xlsx tab Dated): daily, from Jan 1, 1950 – August 2, 2012
 Volume – S&P 500 volume (source: St. Louis Federal Reserve Bank, FRED Database)
 Volume1- percent change in S&P500 Volume
 Return – S&P 500 return (source: St. Louis Federal Reserve Bank, FRED Database)
• Workfile Page: Cross_Section (Data.xlsx tab Cross_Section) data on 526 individuals
 wage – wage per hour (in dollars)
 educ – number of years of education
 exper – experience, number of years
 female – dummy variable, equal to 1 if female, 0 otherwise
 married – dummy variable, equal to 1 if married, 0 otherwise
2
* These data are from Wooldridge, Introductory Econometrics (4th Edition).
Data Series Objects: Series and Groups
• It is fairly easy to create dummy variables in EViews by using sample
commands or a number of EViews functions:
smpl
@recode
@date
@expand
• This tutorial demonstrates how to create:
 Dummy Variables using samples
 Dummy Variables using the @recode function
 Date Dummy Variables using the @date function
 Categorical Dummy Variables using the @expand function
3
Creating Dummy Variables
Using Samples
Creating Dummy Variables Using Samples:
Example 1
• The easiest way to create dummy variables in EViews is by using samples
(smpl command).
• Let’s illustrate a few examples using the Dated page in Workfile Data.wf1.
• Suppose you would like to create a dummy variable equal to 1, if return>0.2,
and 0 otherwise.
5
Dummies with samples: Example 1
1. Open Data.wf1 workfile. Click on the
Dated page.
2. Type in the command window:
smpl if return>0.2
series dummy1=1
smpl if return<=0.2
series dummy1=0
3. Press Enter after each command line
entry.
Creating Dummy Variables Using Samples:
Example 1 (cont’d)
• The original series (return) and the new dummy variable are both shown here.
Original series Dummy Variable
6
Creating Dummy Variables Using Samples:
Example 2
7
• Now suppose you would like to create a dummy variable equal to 1, if
return>0.3, or return<=-0.3, and 0 otherwise.
Dummies with samples: Example 2
1. Click on Dated workfile page. Type in the
command window:
smpl if return>0.3 or return<=-0.3
series dummy2=1
smpl if return>-0.3 and return<0.3
series dummy2=0
2. Press Enter after each command line.
Original Series Dummy Variable
Creating Dummy Variables
Using @recode function
Creating Dummy Variables Using @recode
• Another way to create dummy variables in EViews is by using @recode
function.
9
Function Description
@recode(s,x,y) Returns x if condition s is true; otherwise it returns y
Creating Dummy Variables Using @recode:
Example 1
10
• Suppose you wish to create a dummy equal to 1 if return<=0.2, 0 otherwise.
Dummies with @recode: Example 1
1. Click on the Dated workfile page. Let’s first set the
sample equal to the entire range by typing in the
command window smpl @all. Now, type in the
command window:
series dummy4=@recode(return<=0.2,1,0)
2. Press Enter.
Alternatively:
1. Click on the top menu bar of and select Quick
→ Generate Series.
2. The Generate Series by Equation dialog box
opens up. Specify here your dummy expression
(as shown here).
3. Click OK.
Creating Dummy Variables Using @recode:
Example 1 (cont’d)
• The original series (return) and the new dummy variable are both shown here.
Original series Dummy Variable
11
Creating Dummy Variables Using @recode:
Example 2
12
• Create a dummy variable equal to 1 if -0.2<return<1, 0 otherwise.
Dummies with @recode: Example 2
1. Click on Dated workfile page. Type in the command window:
series dummy5=@recode(return>-0.2 and return<1,1,0)
2. Press Enter.
Original Series Dummy Variable
Creating Dummy Variables Using @recode:
Example 3
13
• Create a dummy variable equal to 1 if return<=-1.2 or return>=1, 0 otherwise.
Dummies with @recode: Example 3
1. Click on Dated workfile page. Type in the command window:
series dummy6=@recode(return<=-1.2 or return>=1,1,0)
2. Press Enter.
Original Series Dummy Variable
Creating Dummy Variables Using @recode:
Example 4
14
• Suppose you would like to create two new series by separating an
existing series (return) as follows;
series1 collects values of return for which -0.3<return<0.3
series2 collects values of return for which return<=-0.3 or return>=0.3
Dummies with @recode: Example 4
1. Click on Dated workfile page. Type in the command window:
series series1=@recode(return>-0.3 and return<0.3,return,0)
series series2=@recode(return<=-0.3 or return>0.3,return,0)
2. Press Enter after each command line.
Creating Dummy Variables Using @recode:
Example 4 (cont’d)
15
• The original series (return) and the two new dummy variables are shown here.
Original series Series 1 Series 2
Creating Dummy Variables Using @recode:
Example 5
16
• Let’s create a total return index from daily S&P500 returns.
Dummies with @recode: Example 5
1. Click on Dated workfile page. Type in the command window:
series index=@recode(@trend=0,100, index(-1)*(1+return/100))
2. Press Enter.
Original Series Index
Creating Dummy Variables Using @recode:
Example 6
17
• Lastly, suppose you want to create a series that excludes outliers from the
return series in the previous example.
• Specifically, suppose that the new series excludes the highest and the lowest
2.5% values of returns.
Dummies with @recode: Example 6
1. Click on Dated workfile page. Type in the command window:
series no_outlier=@recode(return>@quantile(return,0.025) and
return<@quantile(return,0.975), return, na)
2. Press Enter.
Creating Dummy Variables Using @recode:
Example 6 (cont’d)
18
• The original series (return) and the new series are shown here.
Original series No Outlier
A Few Notes on Simple Dummy Variables
• For simple dummies, you don’t need to use smpl or @recode.
• You can create them simply by defining the logical expression directly in the
command window, as shown in the following examples.
• However, you may have to use smpl or @recode for more complex cases.
19
A few Notes on Simple Dummy Variables:
Example 1
20
• Create a dummy equal to 1 if return<=0, and 0 otherwise.
Simple Dummies: Example 1
1. Click on Dated workfile page. Type in the
command window:
series d1=(return<=0)
2. Press Enter.
Original Series Dummy Variable
A few Notes on Simple Dummy Variables:
Example 2
21
• Create a dummy equal to 1 if return<=-0.5 or return>=0.1, and 0 otherwise.
Simple Dummies: Example 2
1. Click on Dated workfile page. Type in the command
window:
series d2 = return<=-0.5 or return>=0.1
2. Press Enter. Original Series Dummy Variable
Date Dummy Variables
Creating Date Dummies
• Dated dummies can be created by using @recode and @date or @dateval.
• For more details on date functions, see tutorial on Date Functions.
23
Function Description
@date Returns the date associated with each observation
@dateval Returns the date associated with a text representation of a date
@year Returns the year in which each observation begins
@quarter Returns the quarter of the year in which each observation begins
@month Returns the month of the year in which each observation begins
@day Returns the day of the month in which each observations begins
@weekday Returns the day of the week
Main Functions
Creating Date Dummies:
Example 1
24
• Suppose you want to create a dummy variable equal to 1 for all dates after
1995/03/15 and 0 otherwise.
Date Dummies: Example 1
1. Click on the Dated workfile page. Now, type in the command window:
series dumdate1=@recode(@date>@dateval("1995/3/15"),1,0)
2. Press Enter.
Alternatively, without @recode:
1. Type in the command window:
series dumdate1=@date>@dateval("1995/3/15")
2. Press Enter.
Dummy Variable
Creating Date Dummies:
Example 2
25
• Create a dummy variable equal to 1 for all dates before April 1979 and after
February 1994.
Date Dummies: Example 2
1. Click on the Dated workfile page. Type in the command window:
series dumdate2=@recode(@date<@dateval("1979m4") or
@date>@dateval("1994m2"),1,0)
2. Press Enter (please type the command in one line).
Alternatively, without @recode:
1. Type in the command window:
series dumdate2=@date<@dateval("1979m4") or
@date>@dateval("1994m2")
2. Press Enter (please type the command in one line).
26
Creating Date Dummies:
Example 2 (cont’d)
Dummy Variable
• A graph of the dummy show it assumes a value of 1 prior to April 1979 and
post February 1994.
Creating Date Dummies:
Example 4
27
• Dated dummies can also be created using @year, @month, @day date functions.
• Create a dummy equal to 1 if the month is January or the day of the week is Friday.
Date Dummies: Example 4
1. Click on the Dated workfile page. Now, type in the command window:
series dumdate4=@recode(@month=1 or @weekday=5,1,0)
2. Press Enter.
Alternatively, without @recode:
1. Type in the command window:
series dumdate4=@month=1 or @weekday=5
2. Press Enter.
Dummy Variable
Creating Date Dummies:
Example 5
28
• Create a dummy equal to 1 for all years after 1994 if the month is January or the
day of the week is Friday.
Date Dummies: Example 5
1. Click on the Dated workfile page. Now, type in the command window:
series dumdate5=@recode(@year>1994 and (@month=1 or @weekday=5),1,0)
2. Press Enter.
Alternatively, without @recode:
1. Type in the command window:
series dumdate5=@year>1994 and (@month=1 or @weekday=5)
2. Press Enter.
Creating Date Dummies:
Example 6
29
• Create a dummy variable equal to 1 for all months when there is a presidential
election.
Date Dummies: Example 6
1. Click on the Dated workfile page. Now, type in the command window:
smpl @all
series dumpres=0
smpl if @mod(@year,4)=0 and @month=11
series dumpres=1
smpl @all
2. Press Enter after each command line.
Dummy Variable
Dummy Variables in Non-Dated
Workfiles
Dummies in Non-dated Workfiles
• You can follow the methodology used in “Dated Dummies” to create dummies
in non-dated workfiles.
• Simply use @obsnum (instead of @date) to create the dummy variables.
31
Creating Dummies in Non-Dated Workfiles:
Example 1
32
• In the Cross-Section page, create a dummy variable equal to 1 after the 5th
observation, and 0 otherwise.
Dummies in non-Dated Workfiles: Example 1
1. Click on the Cross-Section workfile page. Now, type in the command window:
series dum1=@recode(@obsnum>5,1,0)
2. Press Enter.
Dummy Variable
Alternatively, without @recode:
1. Type in the command window:
series dum1=@obsnum>5
2. Press Enter.
Creating Dummies in Non-Dated Workfiles:
Example 2
33
• In the Cross-Section page, create a dummy variable equal to 1 for all the
observations between the 7th and 12th observation
Dummies in non-Dated Workfiles: Example 2
1. Click on the Cross-Section workfile page. Now, type in the command window:
series dum2=@recode((@obsnum>=7 and @obsnum<=12),1,0)
2. Press Enter. Dummy Variable
Alternatively, without @recode:
1. Type in the command window:
series dum2=@obsnum>=7 and @ obsnum<=12
2. Press Enter.
Creating Dummy Variables
Using @expand function
Creating Categorical Dummies
• Categorical dummies can be easily created by using @expand function.
35
Function Description
@expand Allows you to create a group of dummy variables by expanding
out one or more series into individual categories
Creating Dummy Variables using @expand:
Example 1: Categorical Dummies
• Let’s create a group of series as follows:
One series with 1 if female and 0 if male
One series with 1 if male and 0 if female
36
Dummies using @expand: Example 1
1. Click on the Cross-Section workfile page. Type in the command window:
group g1 @expand(female)
2. Press Enter.
• The group is shown here with
the two series separating
males from females.
Creating Dummy Variables using @expand:
Example 2: Categorical Dummies
• Now let’s create a new group of series as follows:
 One series containing 1 if “male” and “single”.
 One series containing 1 if “male” and “married”.
 One series containing 1 if “female” and “single”.
 One series containing 1 if “female” and “married”.
37
Dummies using @expand: Example 2
1. Click on the Cross-Section workfile page. Type in the command window:
group g2 @expand(female, married)
2. Press Enter.
Creating Dummy Variables using @expand:
Example 3: Categorical Dummies
• Now let’s create a new group of series as follows:
 One series equal to educ (years of education) if male (female=0).
 One series equal to educ if female (female =1).
38
Dummies using @expand: Example 3
1. Click on the Cross-Section workfile page. Type in the command window:
group g3 educ*@expand(female)
2. Press Enter.
• The group is shown here with the two
series showing the years of
education for males separately from
years of education for females.
• Dummies can also be created by using @expand in conjunction with other
date functions (@year, @month, @day, etc.).
• For example, suppose you would like to create a dummy variable for each
day of the week.
Creating Dummy Variables using @expand:
Example 4: Date Dummies
39
Dummies using @expand: Example 4
1. Click on the Dated workfile page. Type in the command window:
group g1 @expand(@weekday)
2. Press Enter.
• Suppose that now you would like to create a dummy variable for each year.
Creating Dummy Variables using @expand:
Example 5: Date Dummies
40
Dummies using @expand: Example 5
1. Click on the Dated workfile page. Type in the command window:
group g2 @expand(@year)
2. Press Enter.
Dummy Variables in Regressions
Dummies in Regressions:
Example 1
• In EViews you can use dummy variable expressions in regressions without
having to first create and save the dummies.
• Suppose you would like to estimate a regression of return on volume1 and a
dummy variable equal to 1 for all dates after 1994/12/2.
42
Dummies in Regressions: Example 1
1. Click on the Dated workfile page. Type in the
command window:
equation eq1.ls return c volume1
@date>@dateval("1994/12/2")
2. Press Enter (type the command in one line).
Alternatively:
1. Select Quick → Estimate Equation from
the top menu bar.
2. The Equation Estimation box opens up.
Specify here your equation (as shown in
the figure)
3. Click OK.
Dummies in Regressions:
Example 1 (cont’d)
43
• The estimation output is shown here.
• As you can see EViews estimates the coefficient of the dummy variable
directly without us having to create and save the date dummy first.
*Note: see tutorial on Basic Estimation for details
on regression analysis in EViews.
Dummies in Regressions:
Example 2
• Now suppose you would like to estimate a regression of return on volume1 and
a dummy variable equal to 1 for all Januaries since 1994/12/2.
44
Dummies in Regressions: Example 2
1. Click on the Dated workfile page. Type in the command window:
equation eq2.ls return c volume1 (@date>@dateval("1994/12/2") and @month=1)
2. Press Enter.
• Note that there are no spaces in
the logical expression:
 @month=1 is correct
 @month = 1 is not correct
Dummies in Regressions:
Example 3
45
• Now let’s carry out a regression in the Cross_Section workfile page.
• Suppose we want to regress wage on exper, educ and four dummy variables
created by @expand(female,married).
Dummies in Regressions: Example 3
1. Click on the Cross_Section workfile page.
Type in the command window:
equation eq1.ls wage exper educ
@expand(female, married)
2. Press Enter (type command in one line).
Dummies in Regressions:
Example 3 (cont’d)
46
• In the previous example, notice that the constant was not included.
• If you include a constant, then EViews will be unable to estimate the
regression and return an error message because of perfect collinearity (the
dummy variable trap).
• You will receive an error message
(shown here).
• In order to estimate the regression with
a constant, you should exclude one of
the dummies.
Dummies in Regressions: Example 3
1. Type in the command window:
equation eq1.ls wage c exper educ
@expand(female, married)
2. Press Enter (type command in one line).
47
• Let’s exclude one of the dummies. You can use either one of the following
commands:
 @dropfirst (drops the first dummy).
 @droplast (drops the last dummy).
Dummies in Regressions:
Example 3 (cont’d)
Dummies in Regressions: Example 3
1. Type in the command window:
equation eq2.ls wage c exper educ
@expand(female, married,@dropfirst)
2. Press Enter (type command in one line).

More Related Content

Similar to Tutorial7_Dummy Variables.pptx

First of all, I like you to notice that I have set Starting WIP .docx
First of all, I like you to notice that I have set Starting WIP .docxFirst of all, I like you to notice that I have set Starting WIP .docx
First of all, I like you to notice that I have set Starting WIP .docxvoversbyobersby
 
Visual basic asp.net programming introduction
Visual basic asp.net programming introductionVisual basic asp.net programming introduction
Visual basic asp.net programming introductionHock Leng PUAH
 
The Ring programming language version 1.10 book - Part 26 of 212
The Ring programming language version 1.10 book - Part 26 of 212The Ring programming language version 1.10 book - Part 26 of 212
The Ring programming language version 1.10 book - Part 26 of 212Mahmoud Samir Fayed
 
Cmis 102 Effective Communication / snaptutorial.com
Cmis 102  Effective Communication / snaptutorial.comCmis 102  Effective Communication / snaptutorial.com
Cmis 102 Effective Communication / snaptutorial.comHarrisGeorg12
 
Case Study Analysis 2The Cholesterol.xls records cholesterol lev.docx
Case Study Analysis 2The Cholesterol.xls records cholesterol lev.docxCase Study Analysis 2The Cholesterol.xls records cholesterol lev.docx
Case Study Analysis 2The Cholesterol.xls records cholesterol lev.docxwendolynhalbert
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181Mahmoud Samir Fayed
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesccis224477
 
Cmis 102 Enthusiastic Study / snaptutorial.com
Cmis 102 Enthusiastic Study / snaptutorial.comCmis 102 Enthusiastic Study / snaptutorial.com
Cmis 102 Enthusiastic Study / snaptutorial.comStephenson22
 
Cmis 102 Success Begins / snaptutorial.com
Cmis 102 Success Begins / snaptutorial.comCmis 102 Success Begins / snaptutorial.com
Cmis 102 Success Begins / snaptutorial.comWilliamsTaylorza48
 
Cis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variablesCis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variablessdjdskjd9097
 
Advance Features In Procedues And Triggers
Advance Features In Procedues And TriggersAdvance Features In Procedues And Triggers
Advance Features In Procedues And TriggersKeshav Murthy
 
Unit 8 & 9 [122 Payroll Accounting] Page 1 of 3 .docx
Unit 8 & 9      [122 Payroll Accounting]  Page 1 of 3 .docxUnit 8 & 9      [122 Payroll Accounting]  Page 1 of 3 .docx
Unit 8 & 9 [122 Payroll Accounting] Page 1 of 3 .docxdickonsondorris
 
CIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.comCIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.comWindyMiller44
 
Ecs 10 programming assignment 4 loopapalooza
Ecs 10 programming assignment 4   loopapaloozaEcs 10 programming assignment 4   loopapalooza
Ecs 10 programming assignment 4 loopapaloozaJenniferBall44
 
Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0PMILebanonChapter
 
The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180 The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180 Mahmoud Samir Fayed
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablescis247
 

Similar to Tutorial7_Dummy Variables.pptx (20)

Ms vb
Ms vbMs vb
Ms vb
 
First of all, I like you to notice that I have set Starting WIP .docx
First of all, I like you to notice that I have set Starting WIP .docxFirst of all, I like you to notice that I have set Starting WIP .docx
First of all, I like you to notice that I have set Starting WIP .docx
 
Visual basic asp.net programming introduction
Visual basic asp.net programming introductionVisual basic asp.net programming introduction
Visual basic asp.net programming introduction
 
The Ring programming language version 1.10 book - Part 26 of 212
The Ring programming language version 1.10 book - Part 26 of 212The Ring programming language version 1.10 book - Part 26 of 212
The Ring programming language version 1.10 book - Part 26 of 212
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 
Cmis 102 Effective Communication / snaptutorial.com
Cmis 102  Effective Communication / snaptutorial.comCmis 102  Effective Communication / snaptutorial.com
Cmis 102 Effective Communication / snaptutorial.com
 
Case Study Analysis 2The Cholesterol.xls records cholesterol lev.docx
Case Study Analysis 2The Cholesterol.xls records cholesterol lev.docxCase Study Analysis 2The Cholesterol.xls records cholesterol lev.docx
Case Study Analysis 2The Cholesterol.xls records cholesterol lev.docx
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
 
Cmis 102 Enthusiastic Study / snaptutorial.com
Cmis 102 Enthusiastic Study / snaptutorial.comCmis 102 Enthusiastic Study / snaptutorial.com
Cmis 102 Enthusiastic Study / snaptutorial.com
 
Cmis 102 Success Begins / snaptutorial.com
Cmis 102 Success Begins / snaptutorial.comCmis 102 Success Begins / snaptutorial.com
Cmis 102 Success Begins / snaptutorial.com
 
Cis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variablesCis247 i lab 3 overloaded methods and static methods variables
Cis247 i lab 3 overloaded methods and static methods variables
 
Advance Features In Procedues And Triggers
Advance Features In Procedues And TriggersAdvance Features In Procedues And Triggers
Advance Features In Procedues And Triggers
 
Unit 8 & 9 [122 Payroll Accounting] Page 1 of 3 .docx
Unit 8 & 9      [122 Payroll Accounting]  Page 1 of 3 .docxUnit 8 & 9      [122 Payroll Accounting]  Page 1 of 3 .docx
Unit 8 & 9 [122 Payroll Accounting] Page 1 of 3 .docx
 
CIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.comCIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.com
 
Ecs 10 programming assignment 4 loopapalooza
Ecs 10 programming assignment 4   loopapaloozaEcs 10 programming assignment 4   loopapalooza
Ecs 10 programming assignment 4 loopapalooza
 
Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0Monte Carlo Simulation for project estimates v1.0
Monte Carlo Simulation for project estimates v1.0
 
The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180 The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180
 
Visual basic
Visual basicVisual basic
Visual basic
 
Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
 

More from TsalisSyaifuddin1

Inflasi_dan_Pengangguran dalam teori ekonomi mikro.pptx
Inflasi_dan_Pengangguran dalam teori ekonomi mikro.pptxInflasi_dan_Pengangguran dalam teori ekonomi mikro.pptx
Inflasi_dan_Pengangguran dalam teori ekonomi mikro.pptxTsalisSyaifuddin1
 
Konsumsi_Tabungan_Dan_Investasi.ppt
Konsumsi_Tabungan_Dan_Investasi.pptKonsumsi_Tabungan_Dan_Investasi.ppt
Konsumsi_Tabungan_Dan_Investasi.pptTsalisSyaifuddin1
 
Materi Presentasi Kipin 20 Juli 2023.pptx
Materi Presentasi Kipin 20 Juli 2023.pptxMateri Presentasi Kipin 20 Juli 2023.pptx
Materi Presentasi Kipin 20 Juli 2023.pptxTsalisSyaifuddin1
 
ekonomimakroislam-091020212409-phpapp02.pptx
ekonomimakroislam-091020212409-phpapp02.pptxekonomimakroislam-091020212409-phpapp02.pptx
ekonomimakroislam-091020212409-phpapp02.pptxTsalisSyaifuddin1
 
Beragama di Era Industri 4-1.pptx
Beragama di Era Industri 4-1.pptxBeragama di Era Industri 4-1.pptx
Beragama di Era Industri 4-1.pptxTsalisSyaifuddin1
 

More from TsalisSyaifuddin1 (6)

Inflasi_dan_Pengangguran dalam teori ekonomi mikro.pptx
Inflasi_dan_Pengangguran dalam teori ekonomi mikro.pptxInflasi_dan_Pengangguran dalam teori ekonomi mikro.pptx
Inflasi_dan_Pengangguran dalam teori ekonomi mikro.pptx
 
Konsumsi_Tabungan_Dan_Investasi.ppt
Konsumsi_Tabungan_Dan_Investasi.pptKonsumsi_Tabungan_Dan_Investasi.ppt
Konsumsi_Tabungan_Dan_Investasi.ppt
 
1117925408.pptx
1117925408.pptx1117925408.pptx
1117925408.pptx
 
Materi Presentasi Kipin 20 Juli 2023.pptx
Materi Presentasi Kipin 20 Juli 2023.pptxMateri Presentasi Kipin 20 Juli 2023.pptx
Materi Presentasi Kipin 20 Juli 2023.pptx
 
ekonomimakroislam-091020212409-phpapp02.pptx
ekonomimakroislam-091020212409-phpapp02.pptxekonomimakroislam-091020212409-phpapp02.pptx
ekonomimakroislam-091020212409-phpapp02.pptx
 
Beragama di Era Industri 4-1.pptx
Beragama di Era Industri 4-1.pptxBeragama di Era Industri 4-1.pptx
Beragama di Era Industri 4-1.pptx
 

Recently uploaded

VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spiritegoetzinger
 
Mulki Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Mulki Call Girls 7001305949 WhatsApp Number 24x7 Best ServicesMulki Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Mulki Call Girls 7001305949 WhatsApp Number 24x7 Best Servicesnajka9823
 
Unveiling the Top Chartered Accountants in India and Their Staggering Net Worth
Unveiling the Top Chartered Accountants in India and Their Staggering Net WorthUnveiling the Top Chartered Accountants in India and Their Staggering Net Worth
Unveiling the Top Chartered Accountants in India and Their Staggering Net WorthShaheen Kumar
 
20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdfAdnet Communications
 
Vp Girls near me Delhi Call Now or WhatsApp
Vp Girls near me Delhi Call Now or WhatsAppVp Girls near me Delhi Call Now or WhatsApp
Vp Girls near me Delhi Call Now or WhatsAppmiss dipika
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managmentfactical
 
Stock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdfStock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdfMichael Silva
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办fqiuho152
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
The Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarThe Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarHarsh Kumar
 
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...Suhani Kapoor
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfAdnet Communications
 
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfBPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfHenry Tapper
 
House of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHouse of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHenry Tapper
 
Financial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and DisadvantagesFinancial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and Disadvantagesjayjaymabutot13
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Roomdivyansh0kumar0
 
(办理学位证)加拿大萨省大学毕业证成绩单原版一比一
(办理学位证)加拿大萨省大学毕业证成绩单原版一比一(办理学位证)加拿大萨省大学毕业证成绩单原版一比一
(办理学位证)加拿大萨省大学毕业证成绩单原版一比一S SDS
 
Attachment Of Assets......................
Attachment Of Assets......................Attachment Of Assets......................
Attachment Of Assets......................AmanBajaj36
 

Recently uploaded (20)

VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Saharanpur Anushka 8250192130 Independent Escort Se...
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spirit
 
Mulki Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Mulki Call Girls 7001305949 WhatsApp Number 24x7 Best ServicesMulki Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Mulki Call Girls 7001305949 WhatsApp Number 24x7 Best Services
 
Unveiling the Top Chartered Accountants in India and Their Staggering Net Worth
Unveiling the Top Chartered Accountants in India and Their Staggering Net WorthUnveiling the Top Chartered Accountants in India and Their Staggering Net Worth
Unveiling the Top Chartered Accountants in India and Their Staggering Net Worth
 
20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf
 
Vp Girls near me Delhi Call Now or WhatsApp
Vp Girls near me Delhi Call Now or WhatsAppVp Girls near me Delhi Call Now or WhatsApp
Vp Girls near me Delhi Call Now or WhatsApp
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managment
 
Stock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdfStock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdf
 
Monthly Economic Monitoring of Ukraine No 231, April 2024
Monthly Economic Monitoring of Ukraine No 231, April 2024Monthly Economic Monitoring of Ukraine No 231, April 2024
Monthly Economic Monitoring of Ukraine No 231, April 2024
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
 
The Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarThe Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh Kumar
 
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdf
 
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfBPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
 
House of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHouse of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview document
 
Financial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and DisadvantagesFinancial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and Disadvantages
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
 
(办理学位证)加拿大萨省大学毕业证成绩单原版一比一
(办理学位证)加拿大萨省大学毕业证成绩单原版一比一(办理学位证)加拿大萨省大学毕业证成绩单原版一比一
(办理学位证)加拿大萨省大学毕业证成绩单原版一比一
 
Attachment Of Assets......................
Attachment Of Assets......................Attachment Of Assets......................
Attachment Of Assets......................
 

Tutorial7_Dummy Variables.pptx

  • 1. EViews Training Dummy Variables Note: Data and workfiles for this tutorial are provided in:  Data: Data.xlsx  Results: Results.wf1  Practice Workfile: Data.wf1
  • 2. Data and Workfile Documentation • Data.wf1 and Data.xlsx consist of two pages (tabs) with the following data: • Workfile Page: Dated (Data.xlsx tab Dated): daily, from Jan 1, 1950 – August 2, 2012  Volume – S&P 500 volume (source: St. Louis Federal Reserve Bank, FRED Database)  Volume1- percent change in S&P500 Volume  Return – S&P 500 return (source: St. Louis Federal Reserve Bank, FRED Database) • Workfile Page: Cross_Section (Data.xlsx tab Cross_Section) data on 526 individuals  wage – wage per hour (in dollars)  educ – number of years of education  exper – experience, number of years  female – dummy variable, equal to 1 if female, 0 otherwise  married – dummy variable, equal to 1 if married, 0 otherwise 2 * These data are from Wooldridge, Introductory Econometrics (4th Edition).
  • 3. Data Series Objects: Series and Groups • It is fairly easy to create dummy variables in EViews by using sample commands or a number of EViews functions: smpl @recode @date @expand • This tutorial demonstrates how to create:  Dummy Variables using samples  Dummy Variables using the @recode function  Date Dummy Variables using the @date function  Categorical Dummy Variables using the @expand function 3
  • 5. Creating Dummy Variables Using Samples: Example 1 • The easiest way to create dummy variables in EViews is by using samples (smpl command). • Let’s illustrate a few examples using the Dated page in Workfile Data.wf1. • Suppose you would like to create a dummy variable equal to 1, if return>0.2, and 0 otherwise. 5 Dummies with samples: Example 1 1. Open Data.wf1 workfile. Click on the Dated page. 2. Type in the command window: smpl if return>0.2 series dummy1=1 smpl if return<=0.2 series dummy1=0 3. Press Enter after each command line entry.
  • 6. Creating Dummy Variables Using Samples: Example 1 (cont’d) • The original series (return) and the new dummy variable are both shown here. Original series Dummy Variable 6
  • 7. Creating Dummy Variables Using Samples: Example 2 7 • Now suppose you would like to create a dummy variable equal to 1, if return>0.3, or return<=-0.3, and 0 otherwise. Dummies with samples: Example 2 1. Click on Dated workfile page. Type in the command window: smpl if return>0.3 or return<=-0.3 series dummy2=1 smpl if return>-0.3 and return<0.3 series dummy2=0 2. Press Enter after each command line. Original Series Dummy Variable
  • 9. Creating Dummy Variables Using @recode • Another way to create dummy variables in EViews is by using @recode function. 9 Function Description @recode(s,x,y) Returns x if condition s is true; otherwise it returns y
  • 10. Creating Dummy Variables Using @recode: Example 1 10 • Suppose you wish to create a dummy equal to 1 if return<=0.2, 0 otherwise. Dummies with @recode: Example 1 1. Click on the Dated workfile page. Let’s first set the sample equal to the entire range by typing in the command window smpl @all. Now, type in the command window: series dummy4=@recode(return<=0.2,1,0) 2. Press Enter. Alternatively: 1. Click on the top menu bar of and select Quick → Generate Series. 2. The Generate Series by Equation dialog box opens up. Specify here your dummy expression (as shown here). 3. Click OK.
  • 11. Creating Dummy Variables Using @recode: Example 1 (cont’d) • The original series (return) and the new dummy variable are both shown here. Original series Dummy Variable 11
  • 12. Creating Dummy Variables Using @recode: Example 2 12 • Create a dummy variable equal to 1 if -0.2<return<1, 0 otherwise. Dummies with @recode: Example 2 1. Click on Dated workfile page. Type in the command window: series dummy5=@recode(return>-0.2 and return<1,1,0) 2. Press Enter. Original Series Dummy Variable
  • 13. Creating Dummy Variables Using @recode: Example 3 13 • Create a dummy variable equal to 1 if return<=-1.2 or return>=1, 0 otherwise. Dummies with @recode: Example 3 1. Click on Dated workfile page. Type in the command window: series dummy6=@recode(return<=-1.2 or return>=1,1,0) 2. Press Enter. Original Series Dummy Variable
  • 14. Creating Dummy Variables Using @recode: Example 4 14 • Suppose you would like to create two new series by separating an existing series (return) as follows; series1 collects values of return for which -0.3<return<0.3 series2 collects values of return for which return<=-0.3 or return>=0.3 Dummies with @recode: Example 4 1. Click on Dated workfile page. Type in the command window: series series1=@recode(return>-0.3 and return<0.3,return,0) series series2=@recode(return<=-0.3 or return>0.3,return,0) 2. Press Enter after each command line.
  • 15. Creating Dummy Variables Using @recode: Example 4 (cont’d) 15 • The original series (return) and the two new dummy variables are shown here. Original series Series 1 Series 2
  • 16. Creating Dummy Variables Using @recode: Example 5 16 • Let’s create a total return index from daily S&P500 returns. Dummies with @recode: Example 5 1. Click on Dated workfile page. Type in the command window: series index=@recode(@trend=0,100, index(-1)*(1+return/100)) 2. Press Enter. Original Series Index
  • 17. Creating Dummy Variables Using @recode: Example 6 17 • Lastly, suppose you want to create a series that excludes outliers from the return series in the previous example. • Specifically, suppose that the new series excludes the highest and the lowest 2.5% values of returns. Dummies with @recode: Example 6 1. Click on Dated workfile page. Type in the command window: series no_outlier=@recode(return>@quantile(return,0.025) and return<@quantile(return,0.975), return, na) 2. Press Enter.
  • 18. Creating Dummy Variables Using @recode: Example 6 (cont’d) 18 • The original series (return) and the new series are shown here. Original series No Outlier
  • 19. A Few Notes on Simple Dummy Variables • For simple dummies, you don’t need to use smpl or @recode. • You can create them simply by defining the logical expression directly in the command window, as shown in the following examples. • However, you may have to use smpl or @recode for more complex cases. 19
  • 20. A few Notes on Simple Dummy Variables: Example 1 20 • Create a dummy equal to 1 if return<=0, and 0 otherwise. Simple Dummies: Example 1 1. Click on Dated workfile page. Type in the command window: series d1=(return<=0) 2. Press Enter. Original Series Dummy Variable
  • 21. A few Notes on Simple Dummy Variables: Example 2 21 • Create a dummy equal to 1 if return<=-0.5 or return>=0.1, and 0 otherwise. Simple Dummies: Example 2 1. Click on Dated workfile page. Type in the command window: series d2 = return<=-0.5 or return>=0.1 2. Press Enter. Original Series Dummy Variable
  • 23. Creating Date Dummies • Dated dummies can be created by using @recode and @date or @dateval. • For more details on date functions, see tutorial on Date Functions. 23 Function Description @date Returns the date associated with each observation @dateval Returns the date associated with a text representation of a date @year Returns the year in which each observation begins @quarter Returns the quarter of the year in which each observation begins @month Returns the month of the year in which each observation begins @day Returns the day of the month in which each observations begins @weekday Returns the day of the week Main Functions
  • 24. Creating Date Dummies: Example 1 24 • Suppose you want to create a dummy variable equal to 1 for all dates after 1995/03/15 and 0 otherwise. Date Dummies: Example 1 1. Click on the Dated workfile page. Now, type in the command window: series dumdate1=@recode(@date>@dateval("1995/3/15"),1,0) 2. Press Enter. Alternatively, without @recode: 1. Type in the command window: series dumdate1=@date>@dateval("1995/3/15") 2. Press Enter. Dummy Variable
  • 25. Creating Date Dummies: Example 2 25 • Create a dummy variable equal to 1 for all dates before April 1979 and after February 1994. Date Dummies: Example 2 1. Click on the Dated workfile page. Type in the command window: series dumdate2=@recode(@date<@dateval("1979m4") or @date>@dateval("1994m2"),1,0) 2. Press Enter (please type the command in one line). Alternatively, without @recode: 1. Type in the command window: series dumdate2=@date<@dateval("1979m4") or @date>@dateval("1994m2") 2. Press Enter (please type the command in one line).
  • 26. 26 Creating Date Dummies: Example 2 (cont’d) Dummy Variable • A graph of the dummy show it assumes a value of 1 prior to April 1979 and post February 1994.
  • 27. Creating Date Dummies: Example 4 27 • Dated dummies can also be created using @year, @month, @day date functions. • Create a dummy equal to 1 if the month is January or the day of the week is Friday. Date Dummies: Example 4 1. Click on the Dated workfile page. Now, type in the command window: series dumdate4=@recode(@month=1 or @weekday=5,1,0) 2. Press Enter. Alternatively, without @recode: 1. Type in the command window: series dumdate4=@month=1 or @weekday=5 2. Press Enter. Dummy Variable
  • 28. Creating Date Dummies: Example 5 28 • Create a dummy equal to 1 for all years after 1994 if the month is January or the day of the week is Friday. Date Dummies: Example 5 1. Click on the Dated workfile page. Now, type in the command window: series dumdate5=@recode(@year>1994 and (@month=1 or @weekday=5),1,0) 2. Press Enter. Alternatively, without @recode: 1. Type in the command window: series dumdate5=@year>1994 and (@month=1 or @weekday=5) 2. Press Enter.
  • 29. Creating Date Dummies: Example 6 29 • Create a dummy variable equal to 1 for all months when there is a presidential election. Date Dummies: Example 6 1. Click on the Dated workfile page. Now, type in the command window: smpl @all series dumpres=0 smpl if @mod(@year,4)=0 and @month=11 series dumpres=1 smpl @all 2. Press Enter after each command line. Dummy Variable
  • 30. Dummy Variables in Non-Dated Workfiles
  • 31. Dummies in Non-dated Workfiles • You can follow the methodology used in “Dated Dummies” to create dummies in non-dated workfiles. • Simply use @obsnum (instead of @date) to create the dummy variables. 31
  • 32. Creating Dummies in Non-Dated Workfiles: Example 1 32 • In the Cross-Section page, create a dummy variable equal to 1 after the 5th observation, and 0 otherwise. Dummies in non-Dated Workfiles: Example 1 1. Click on the Cross-Section workfile page. Now, type in the command window: series dum1=@recode(@obsnum>5,1,0) 2. Press Enter. Dummy Variable Alternatively, without @recode: 1. Type in the command window: series dum1=@obsnum>5 2. Press Enter.
  • 33. Creating Dummies in Non-Dated Workfiles: Example 2 33 • In the Cross-Section page, create a dummy variable equal to 1 for all the observations between the 7th and 12th observation Dummies in non-Dated Workfiles: Example 2 1. Click on the Cross-Section workfile page. Now, type in the command window: series dum2=@recode((@obsnum>=7 and @obsnum<=12),1,0) 2. Press Enter. Dummy Variable Alternatively, without @recode: 1. Type in the command window: series dum2=@obsnum>=7 and @ obsnum<=12 2. Press Enter.
  • 34. Creating Dummy Variables Using @expand function
  • 35. Creating Categorical Dummies • Categorical dummies can be easily created by using @expand function. 35 Function Description @expand Allows you to create a group of dummy variables by expanding out one or more series into individual categories
  • 36. Creating Dummy Variables using @expand: Example 1: Categorical Dummies • Let’s create a group of series as follows: One series with 1 if female and 0 if male One series with 1 if male and 0 if female 36 Dummies using @expand: Example 1 1. Click on the Cross-Section workfile page. Type in the command window: group g1 @expand(female) 2. Press Enter. • The group is shown here with the two series separating males from females.
  • 37. Creating Dummy Variables using @expand: Example 2: Categorical Dummies • Now let’s create a new group of series as follows:  One series containing 1 if “male” and “single”.  One series containing 1 if “male” and “married”.  One series containing 1 if “female” and “single”.  One series containing 1 if “female” and “married”. 37 Dummies using @expand: Example 2 1. Click on the Cross-Section workfile page. Type in the command window: group g2 @expand(female, married) 2. Press Enter.
  • 38. Creating Dummy Variables using @expand: Example 3: Categorical Dummies • Now let’s create a new group of series as follows:  One series equal to educ (years of education) if male (female=0).  One series equal to educ if female (female =1). 38 Dummies using @expand: Example 3 1. Click on the Cross-Section workfile page. Type in the command window: group g3 educ*@expand(female) 2. Press Enter. • The group is shown here with the two series showing the years of education for males separately from years of education for females.
  • 39. • Dummies can also be created by using @expand in conjunction with other date functions (@year, @month, @day, etc.). • For example, suppose you would like to create a dummy variable for each day of the week. Creating Dummy Variables using @expand: Example 4: Date Dummies 39 Dummies using @expand: Example 4 1. Click on the Dated workfile page. Type in the command window: group g1 @expand(@weekday) 2. Press Enter.
  • 40. • Suppose that now you would like to create a dummy variable for each year. Creating Dummy Variables using @expand: Example 5: Date Dummies 40 Dummies using @expand: Example 5 1. Click on the Dated workfile page. Type in the command window: group g2 @expand(@year) 2. Press Enter.
  • 41. Dummy Variables in Regressions
  • 42. Dummies in Regressions: Example 1 • In EViews you can use dummy variable expressions in regressions without having to first create and save the dummies. • Suppose you would like to estimate a regression of return on volume1 and a dummy variable equal to 1 for all dates after 1994/12/2. 42 Dummies in Regressions: Example 1 1. Click on the Dated workfile page. Type in the command window: equation eq1.ls return c volume1 @date>@dateval("1994/12/2") 2. Press Enter (type the command in one line). Alternatively: 1. Select Quick → Estimate Equation from the top menu bar. 2. The Equation Estimation box opens up. Specify here your equation (as shown in the figure) 3. Click OK.
  • 43. Dummies in Regressions: Example 1 (cont’d) 43 • The estimation output is shown here. • As you can see EViews estimates the coefficient of the dummy variable directly without us having to create and save the date dummy first. *Note: see tutorial on Basic Estimation for details on regression analysis in EViews.
  • 44. Dummies in Regressions: Example 2 • Now suppose you would like to estimate a regression of return on volume1 and a dummy variable equal to 1 for all Januaries since 1994/12/2. 44 Dummies in Regressions: Example 2 1. Click on the Dated workfile page. Type in the command window: equation eq2.ls return c volume1 (@date>@dateval("1994/12/2") and @month=1) 2. Press Enter. • Note that there are no spaces in the logical expression:  @month=1 is correct  @month = 1 is not correct
  • 45. Dummies in Regressions: Example 3 45 • Now let’s carry out a regression in the Cross_Section workfile page. • Suppose we want to regress wage on exper, educ and four dummy variables created by @expand(female,married). Dummies in Regressions: Example 3 1. Click on the Cross_Section workfile page. Type in the command window: equation eq1.ls wage exper educ @expand(female, married) 2. Press Enter (type command in one line).
  • 46. Dummies in Regressions: Example 3 (cont’d) 46 • In the previous example, notice that the constant was not included. • If you include a constant, then EViews will be unable to estimate the regression and return an error message because of perfect collinearity (the dummy variable trap). • You will receive an error message (shown here). • In order to estimate the regression with a constant, you should exclude one of the dummies. Dummies in Regressions: Example 3 1. Type in the command window: equation eq1.ls wage c exper educ @expand(female, married) 2. Press Enter (type command in one line).
  • 47. 47 • Let’s exclude one of the dummies. You can use either one of the following commands:  @dropfirst (drops the first dummy).  @droplast (drops the last dummy). Dummies in Regressions: Example 3 (cont’d) Dummies in Regressions: Example 3 1. Type in the command window: equation eq2.ls wage c exper educ @expand(female, married,@dropfirst) 2. Press Enter (type command in one line).

Editor's Notes

  1. 1
  2. 4
  3. 8
  4. 22
  5. 30
  6. 34
  7. 41