EViews Training Dummy Variables Note: Data and workfiles

EViews Training Dummy Variables Note: Data and workfiles

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 * These data are from Wooldridge, Introductory Econometrics (4th Edition). 2 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).

Lets 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. 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.

5 Creating Dummy Variables Using Samples: Example 1 (contd) 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 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 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. Press Enter after each command line.

7 Creating Dummy Variables Using @recode function Creating Dummy Variables Using @recode Another way to create dummy variables in EViews is by using @recode function. Function Description @recode(s,x,y) Returns x if condition s is true; otherwise it returns y

9 Creating Dummy Variables Using @recode: Example 1 Suppose you want 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. Lets first set the sample equal to the entire range by typing in the command window smpl @all. Now, type in the command window: series [email protected](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. 10 Creating Dummy Variables Using @recode: Example 1 (contd) 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 Create a dummy variable equal to 1 if -0.2-0.2 and return<1,1,0) 2. Press Enter.

Original Series Dummy Variable 12 Creating Dummy Variables Using @recode: Example 3 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 [email protected](return<=-1.2 or return>=1,1,0) 2. Press Enter.

Original Series Dummy Variable 13 Creating Dummy Variables Using @recode: Example 4 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=0.3 Dummies with @recode: Example 4

1. Click on Dated workfile page. Type in the command window: series [email protected](return>-0.3 and return<0.3,return,0) series [email protected](return<=-0.3 or return>0.3,return,0) 2. Press Enter after each command line. 14 Creating Dummy Variables Using @recode: Example 4 (contd) The original series (return) and the two new dummy variables are shown here. Original series Series 1

Series 2 15 Creating Dummy Variables Using @recode: Example 5 Lets 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 [email protected](@trend=0,100, index(-1)*(1+return/100)) 2. Press Enter.

Original Series Index 16 Creating Dummy Variables Using @recode: Example 6 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 [email protected](return>@quantile(return,0.025) and

return<@quantile(return,0.975), return, na) 2. Press Enter. 17 Creating Dummy Variables Using @recode: Example 6 (contd) The original series (return) and the new series are shown here. Original series No Outlier 18

A Few Notes on Simple Dummy Variables For simple dummies, you dont 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 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:

Original Series Dummy Variable series d1=return<=0 2. Press Enter. 20 A few Notes on Simple Dummy Variables: Example 2 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 21 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. Main Functions 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 23 Creating Date Dummies: Example 1 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 [email protected](@date>@dateval("1995/3/15"),1,0) 2.

Press Enter. Dummy Variable Alternatively, without @recode: 1. Type in the command window: series [email protected]>@dateval("1995/3/15") 2. Press Enter. 24 Creating Date Dummies: Example 2

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 [email protected](@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 [email protected]<@dateval("1979m4") or @date>@dateval("1994m2")

2. Press Enter (please type the command in one line). 25 Creating Date Dummies: Example 2 (contd) A graph of the new dummy variable is shown here. As you can see, it assumes a value of 1 prior to April 1979 and post February 1994. Dummy Variable 26 Creating Date Dummies: Example 4

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 [email protected](@month=1 or @weekday=5,1,0) Press Enter. 2. Dummy Variable Alternatively, without @recode: 1. Type in the command window: series [email protected]=1 or @weekday=5

2. Press Enter. 27 Creating Date Dummies: Example 5 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 [email protected](@year>1994 and (@month=1 or @weekday=5),1,0) 2.

Press Enter. Alternatively, without @recode: 1. Type in the command window: series [email protected]>1994 and (@month=1 or @weekday=5) 2. Press Enter. 28 Creating Date Dummies: Example 6 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. Dummy Variable Press Enter after each command line. 29

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 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 [email protected](@obsnum>5,1,0) 2. Dummy Variable Press Enter. Alternatively, without @recode: 1. Type in the command window: series [email protected]>5 2. Press Enter.

32 Creating Dummies in Non-Dated Workfiles: Example 2 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 [email protected]((@obsnum>=7 and @obsnum<=12),1,0) 2. Press Enter. Dummy Variable

Alternatively, without @recode: 1. Type in the command window: series [email protected]>=7 and @ obsnum<=12 2. Press Enter. 33 Creating Dummy Variables Using @expand function Creating Categorical Dummies Categorical dummies can be easily created by using @expand function.

Function Description @expand Allows you to create a group of dummy variables by expanding out one or more series into individual categories 35 Creating Dummy Variables using @expand: Example 1: Categorical Dummies Lets 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

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. 36 Creating Dummy Variables using @expand:

Example 2: Categorical Dummies Now lets 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. 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. 37

Creating Dummy Variables using @expand: Example 3: Categorical Dummies Now lets 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). 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. 38 Creating Dummy Variables using @expand: Example 4: Date Dummies 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. Dummies using @expand: Example 4 1. Click on the Dated workfile page. Type in the command window: group g1 @expand(@weekday) 2.

Press Enter. 39 Creating Dummy Variables using @expand: Example 5: Date Dummies Suppose that now you would like to create a dummy variable for each year. Dummies using @expand: Example 5 1. Click on the Dated workfile page. Type in the command window: group g2 @expand(@year) 2. Press Enter.

40 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. 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.

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. *Note: see tutorial on Basic Estimation for details on regression analysis in EViews. 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: 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 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. Type in the command window: equation eq1.ls wage exper educ @expand(female, married) 2. Press Enter (type command in one line). 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: equation eq1.ls wage c exper educ @expand(female, married) 2. Press Enter (type command in one line).

You will receive an error message (shown here). In order to estimate the regression with a constant, you should exclude one of the dummies. 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).

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). 47

Recently Viewed Presentations

  • CAA Membership Meeting

    CAA Membership Meeting

    CAA BOD discussed and voted to support the APCA. Letter of support sent to ADA as well as legislators nationally and locally, e-blast with form letter sent to CAA members. Currently discussing HR 1120/S. 2087: Alice Cogswell and Anne Sullivan...
  • What is IsoPod™? - CamelForth

    What is IsoPod™? - CamelForth

    Most programmers must use a Real Time Operating System. A Multitasking Operating System adds much overhead and complexity for switching tasks/contexts. Concept of Isostructure The word, Isostructure, has two roots: Iso, meaning equal or "on the same level," and structure,...
  • Preventing CAUTI in Special Populations: Focus on Procedure-Related

    Preventing CAUTI in Special Populations: Focus on Procedure-Related

    Seven questions related to BPH: Incomplete emptying. Frequency. Intermittency. Urgency. Weak stream. Straining. Nocturia. Performance in predicting POUR following lower limb arthroplasty has been variable - Scored 1-5 - For nocturia = average # of episodes of nocturia/night) 1 Barry...
  • Resistencia bacteriana - WordPress.com

    Resistencia bacteriana - WordPress.com

    Al analizar la resistencia por antibiótico, fueron siete los responsables de 80% de la resistencia observada en los seis hospitales estudiados: gentamicina (Gm), ampicilina (Am), ciprofloxacina (Cip), amikacina (Ak), cefalotina (Cf), piperacilina (Pip) y trimetoprim-sulfametoxazol (T/S).
  • Getting to Know Your Learning Style - Columbia University

    Getting to Know Your Learning Style - Columbia University

    Verdana MS Pゴシック Arial Wingdings Calibri Monotype Sorts Tahoma Comic Sans MS Times New Roman Bold Stripes 1_Bold Stripes Microsoft Graph Chart Getting to Know Your Learning Style Learning Styles Individual Differences in Learning Style Slide 4 Slide 5 Learning...
  • TeraGrid Progress and Status - educationgrid.org

    TeraGrid Progress and Status - educationgrid.org

    Minority-Serving Institutions Cyberinfrastructure Institute Welcome to TeraGrid Scott Lathrop, TeraGrid Director of Education, Outreach and Training
  • Celebrating Black History Rosa Louise Parks - Instructional ...

    Celebrating Black History Rosa Louise Parks - Instructional ...

    Celebrating Black History Rosa Louise Parks - Instructional Materials (CA Dept of Education) Subject Celebrating Black History Rosa Louise Parks PowerPoint Presentation.
  • Yellowstone National Park - University of West Alabama

    Yellowstone National Park - University of West Alabama

    Park crosses Continental Divide 3 times and has 350 miles of paved road Yellowstone National Park Managed to protect cultural and natural resources and scenery for visitor's use For example: fishing Fishing has been one of the major activities that...