Beruflich Dokumente
Kultur Dokumente
Dummy Variables
Note: Data and workfiles for this tutorial are provided in:
Data: Data.xlsx
Results: Results.wf1
Practice Workfile: Data.wf1
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.
Dummy Variable
Original Series
Dummy Variable
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.
Description
@recode(s,x,y)
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
10
Dummy Variable
11
Press Enter.
Original Series
Dummy Variable
12
Press Enter.
Original Series
Dummy Variable
13
14
Series 1
Series 2
15
Press Enter.
Original Series
Index
16
Press Enter.
17
No Outlier
18
19
Original Series
Dummy Variable
command window:
series d1=return<=0
2.
Press Enter.
20
window:
series d2=return<=-0.5 or return>=0.1
2.
Press Enter.
Original Series
Dummy Variable
21
Description
@date
@dateval
@year
@quarter
@month
@day
@weekday
23
series dumdate1=@recode(@date>@dateval("1995/3/15"),1,0)
2.
Press Enter.
Dummy Variable
series dumdate1=@date>@dateval("1995/3/15")
2.
Press Enter.
24
series dumdate2=@recode(@date<@dateval("1979m4") or
@date>@dateval("1994m2"),1,0)
2.
series dumdate2=@date<@dateval("1979m4") or
@date>@dateval("1994m2")
2.
26
2.
Dummy Variable
Press Enter.
27
Press Enter.
Press Enter.
28
smpl @all
series dumpres=0
smpl if @mod(@year,4)=0 and @month=11
series dumpres=1
smpl @all
2.
Dummy Variable
29
in non-dated workfiles.
Simply use @obsnum (instead of @date) to create the dummy variables.
31
series dum1=@recode(@obsnum>5,1,0)
Dummy Variable
Press Enter.
2.
series dum1=@obsnum>5
2.
Press Enter.
32
Press Enter.
Dummy Variable
Press Enter.
33
Description
@expand
35
group g1 @expand(female)
2.
Press Enter.
36
Press Enter.
37
group g3 educ*@expand(female)
2.
Press Enter.
38
group g1 @expand(@weekday)
2.
Press Enter.
39
group g2 @expand(@year)
2.
Press Enter.
40
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.
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.
Alternatively:
1. Select Quick Estimate Equation from
42
Dummies in Regressions:
Example 1 (contd)
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.
43
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.
Dummies in Regressions: Example 2
1. Click on the Dated workfile page. Type in the command window:
Press Enter.
44
Dummies in Regressions:
Example 3
Now lets 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.
45
Dummies in Regressions:
Example 3 (contd)
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).
Dummies in Regressions: Example 3
1. Type in the command window:
46
Dummies in Regressions:
Example 3 (contd)
Lets exclude one of the dummies. You can use either one of the following
commands:
@dropfirst (drops the first dummy).
@droplast (drops the last dummy).
47