Hi, I need help with my homework about Computer Modelling in Finance. This homework included a project and a report. The report is based on project and this project need to use Excel to make.

profilerdgrls
regressionwithd.pdf

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 1/11

POL242 LAB MANUAL:  EXERCISE 9B Regressions with Dummy Variables and Interaction Terms

Part 1: Dummy Variables

PURPOSE

To learn how to create dummy variables and interpret their effects in multiple regression analysis.

MAIN POINTS Along with interval and ordinal variables we can use nominal level variables that are dichotomous, such as gender, in multiple regression analysis. In previous labs we have used a dichotomous variable for age to define subsets of cases. We can also use dichotomous variables as independent variables in regression. When scored as either a 0 or 1, dichotomies are often referred to as "dummy" variables. They indicate either the absence or presence of a characteristic or trait. Hence they function as a "dummy" for the variable in question. The most obvious use is when a variable either already has or has been recoded into two categories. However, the logic of dummy variables can also be extended to enable us to include nominal level variables with more than two categories in our multiple regressions. Examples of such variables include region, province, country, Canadian party identification, occupation and marital status. 

 

An Example of Dummy Variables in Multiple Regression

Consider the hypothesis that income depends on gender, education, and region of residence.  Working once again with our example of predicting income level using the CRIC2003 data, we could develop an equation of the form Y = A + B(X1) + B(X2) + B(X3) + B(X4) +B(X5) + B(X6) + B(X7), where:

B(X1) = Female (by coding female respondents as 1 and males as 0);

B(X2) = Education (by maintaining the original coding) ;

B(X3) = BC residence (by coding BC respondents as 1 and everyone else as 0);

B(X4) = Alberta residence (by coding Alberta respondents as 1 and everyone else as

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 2/11

0);

B(X5) = Manitoba/Saskatchewan residence (by coding Man/Sask  respondents as 1 and everyone else as 0);

B(X6 ) = Quebec residence (by coding Quebec respondents as 1 and everyone else as 0);

B(X7) = Atlantic residence (by coding all Atlantic respondents as 1 and everyone else as 0).

You will notice in both the equation and the syntax that the most populous province, Ontario, has been left out of the list.

At least one category must always be omitted which leaves something with the value of zero with which to compare each of the other categories. In this case, we need something to be not BC, not Alberta, not Man/Sask, not Quebec and not Atlantic. If, along with all the other regions, we were to enter Ontario as a predictor in the equation, its values would be perfectly correlated (negatively) with the combination of the other regional dummy variables. This would create a situation of multi­ collinearity. So we intentionally leave out at least one of the categories. The omitted category becomes the reference category against which the effects of the other categories are assessed. We can interpret the results as the difference between each category and this omitted category.

You can arbitrarily choose any category to be omitted. However, carefully consider your options and exclude whichever category most sensibly should be the one best suited to be the reference value for all the other variables. Typically, this is the most common or largest category.

It is important that, with the exception of the reference category, you include each of the other categories of your variable in the regression.

Example Syntax

set width=80/length=none/header=no/messages=none. get file="/homes/josephf/webstats/cric03.sav". weight by wt. missing values q40 (11). missing values q26 (8). missing values q25 (9). recode q40 (1 thru 10 = copy) into income. recode q26 (1 thru 7 = copy) into educate. recode sex (1=0) (2=1) into female. recode region (1=1) (2 thru 6=0) into BC. recode region (2=1) (1, 3 thru 6=0) into Alberta. recode region (3=1) (1,2,4,5,6=0) into Prairie. recode region (5=1) (1,2,3,4,6=0) into Quebec. recode region (6=1) (1 thru 5=0) into Atlantic. regression variables=income educate female BC Alberta Prairie Quebec Atlantic        /statistics coeff r tol /descriptives =n         /dependent=income /method=enter educate female BC Alberta Prairie Quebec Atlantic.   

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 3/11

Syntax Legend

The usual missing values are declared

Income, gender, and education are recoded

A set of regional dummy variables are created through another set of recodes

The regression command lists the dependent and all seven independent variables.

The statistics subcommand asks for regression coefficients, explained variance (r), and tolerance.

The descriptives subcommand asks for the number of cases used in the regression.

The dependent variable is declared with the dependent subcommand.

The method subcommand indicates that education, gender, and the five regional dummies should be entered together in the regression.

Example Output

N of Cases =  1830

           * * * *   M U L T I P L E   R E G R E S S I O N   * * * *

Equation Number 1    Dependent Variable..   INCOME

  Descriptive Statistics are printed on Page    4

Block Number  1.  Method:  Enter    EDUCATE  FEMALE BC ALBERTA  PRAIRIE  QUEBEC  ATLANTIC

 

   1..    FEMALE    2..    EDUCATE    3..    PRAIRIE    4..    ATLANTIC    5..    ALBERTA    6..    BC    7..    QUEBEC

Multiple R           .39553 R Square             .15644 Adjusted R Square    .15320 Standard Error      2.52800

F =      48.26685       Signif F =  .0000

­­­­­­­­­­­­­­­­­­­­­­­­­ Variables in the Equation ­­­­­­­­­­­­­­­­­ ­­­­­­­­­

Variable              B        SE B       Beta  Tolerance        VIF         T

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 4/11

EDUCATE         .517381     .036775    .305824    .979913      1.020    14.069 FEMALE         ­.707809     .118295   ­.128854    .998401      1.002    ­5.983 BC             ­.635267     .190322   ­.077849    .851211      1.175    ­3.338 ALBERTA         .303136     .213140    .032671    .877450      1.140     1.422 PRAIRIE        ­.934037     .245900   ­.085847    .906485      1.103    ­3.798 QUEBEC         ­.914617     .152956   ­.144970    .787751      1.269    ­5.980 ATLANTIC      ­1.023321     .232552   ­.100351    .890308      1.123    ­4.400 (Constant)     4.185041     .200155                                     20.909

­­­­­­ in ­­­­­­­

Variable    Sig T

EDUCATE     .0000 FEMALE      .0000 BC          .0009 ALBERTA     .1551 PRAIRIE     .0002 QUEBEC      .0000 ATLANTIC    .0000 (Constant)  .0000

 

Interpretation of Output

The R­square and adjusted R­square figures indicate that approximately 15% of variance in incomes is explained by gender education and region of residence.  Compared to the regression model without the dummies, the R­square is higher by 3 percentage points.  NOTE: this does NOT mean that region of residence on its own explains only a small amount of the variance in incomes, because the effects of education and gender are simultaneously controlled in the regression equation.  If we wanted to examine the impact of only region of residence on the R­square, we could run a regression with only the regional dummies in an equation.

The B values for education and income indicate the direction and number of units (as coded) of change in the dependent variable due to a one unit change in each independent variable.  In this example, the indicators for education and income are ordinal measures.  The results show that earning more income depends in part on obtaining more education. Controlling for the effects of gender and region, a one category increase in education produces about a half category increase (+.52) in income. A university graduate, for example, could earn $10­20,000 more annual income than someone not yet finished university.  The multiple regression results also indicate that women have lower incomes than men.  Controlling for the effects of education and region, females earn three­quarters of an income category less (­.71) than males. 

The B values for the regional dummies indicate that residents of the Prairies, Quebec,

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 5/11

and Atlantic Canada have incomes that are about one income category lower than residents of Ontario. And British Columbians earn about .6 of an income category less than Ontarians residents, whereas Albertans earn about .3 of an income category more than Ontarians.  However, the T­test results, which tell us whether any of the five regions are significantly different from Ontario, show that the difference between Ontarians and Albertans is insignificant. 

We should also note that because Ontario is the same reference group for each of the other regional dummies, we can directly compare each of the regions to one another: British Columbians, for example, earn higher incomes on average than Atlantic Canadians (­.64 versus ­1.02), but lower incomes than Albertans (.30 versus ­.64). 

We can also determine whether or not each of these regional differences are statistically significant by examining the standard errors of the region coefficients.  If any pair of regional dummies do not overlap within +/­ 1.96 standard errors of one another, we can be 95% confident the differences are not due to sampling error.  In this example, Albertans have significantly higher incomes than from residents of the Prairies, Quebec, and Atlantic Canada, since the income differences between Alberta and these three regions do not overlap within +/­ 1.96 standard errors of one another.  This task can be made easier by asking Webstats to produce confidence intervals with your output.  You can do this by including the "ci" command in the "/statistics" line of your regression syntax.  However, it is useful to know how to calculate those confidence intervals yourself by examining the standard errors of the B values, since some of the research you read may not report confidence intervals.

The constant (or y­intercept) indicates the value of  'a' in the regression equation.

From the information in the regression output we can write the following regression equation:

income = 4.19 + .52educate ­ .71 female ­ .64 BC + .30 Alberta ­ .93 Prairies ­ .92 Quebec ­ 1.02 Atlantic.

 

Instructions

1.  Perform a multiple regression analysis including a set of dummy variables built from a multi­category nominal variable.

2.  You can begin by using the syntax from the above example working with the CRIC 2003 data set.

3.  Identify a multi­category nominal variable in the data set to "dummy up" and use it as a control in your analysis. Potential variables include: Q27 (marital status) q28 (work status) q37 (community size).

4.  Include your dummies in the multiple regression equation. 5.  Examine your output to determine the influence of your dummy variables.

QUESTIONS FOR REFLECTION

What happens if you change the reference category for your set of dummy variables?  If, for instance, we use Quebec as the reference category instead of Ontario, how do we interpret the resulting B values?  Does the model explain any more or less of the observed variance? Do our substantive conclusions about the results change in any way?

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 6/11

What happens when you convert ordinal variables such as education into a series of dummy variables? What else can we do with dummies?

DISCUSSION

When we change the reference category, we must interpret the results as indicating differences from the new reference category. Your substantive conclusions and explained variance should be essentially the same. With ordinal variables you still enter a dummy variable for all categories but one into the regression. Any you still interpret your results in terms of its difference from the reference category. Dummy variables can be useful in exploring the non­linear effects of some independent variables in regression analysis.  For example, if you have a theory that middle age individuals tend to be more knowledgeable about politics than their younger or older counterparts, then an independent variable that simply measures respondents' ages in years, from youngest to oldest, is not very helpful in a linear regression.  Such a variable will likely produce modest and insignificant age effects, even if middle aged individuals are significantly different from others.  Instead, you can create dummy variables for several different age categories and enter these in your regression model to see whether the middle aged are more knowledgeable than others.  

Part 2: Interaction Terms

PURPOSE To learn how to use regression analysis to compare the effects of an independent variable on a dependent variable when a third variable takes on different values (interaction effects). To learn how to incorporate interaction terms in a single regression equation.

MAIN POINTS Elaboration patterns of replication, explanation, and interpretation, can be incorporated into regression analysis by simply entering the appropriate independent variables into the analysis.  See here for examples. Elaboration patterns of specification can also be incorporated into regression analysis using interaction terms.  Recall that specification is a pattern of elaboration where one variable affects the relationship between two other variables. This is also often described as an interaction effect, when the effects of one independent variable (x) on the dependent variable (y) are a function of a second independent variable (z). 

For instance, the effect of gender on income is different for different age groups

In a regression, an interaction effect is present when the slope of the regression line changes depending on the value of a third variable. There are two ways to include interaction effects in regression analysis: The two methods calculate and express the interaction effect in slightly different ways. 

Method 1 is to run regressions with a subset of cases. This approach has been explored in previous labs on bivariate and multivariate regression. It follows a logic similar to that of using control tables. 

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 7/11

Method 2 is to include an interaction term in a single regression equation.  An interaction term can be created by multiplying two variables together to create a new variable (e.g. compute interact= x * z).  Great care must be taken to ensure that interaction terms are correctly computed. Generally, you want to ensure that in multiplying your dummy variables together you obtain a value of 1 only for the category or interest to you. In this case, we expect that being female and over 30 leads to lower income. So we should ensure that in our dummy variables Female =1 and over 30 =1.

The interaction term and the two independent variables from which it is computed are all entered into a single regression equation. In addition to using dummy variables, interaction terms can be computed using ordinal or interval level data. Here we will focus only on dummy variables. The example again analyzes the effects of differential effect of gender on income levels among different age groups. 

EXAMPLE

Dataset: CRIC2003

Hypotheses Arrow Diagrams: [FEMALE] X [OVER 30] ­­> [INCOME]

 

Regression Syntax weight by wt. missing values q40 (11). missing values q25 (9). recode q40 (1 thru 10 = copy) into income.  recode sex (1=0) (2=1) into female. recode scr1 (1=0) (2=1) into agedummy. value labels agedummy 0 'under30' 1 'over30'. compute fem30 = (female*agedummy).   regression variables = income age female fem30   / statistics coeff r tol/descriptive = n   /dependent = income   /method = enter age female   /method = enter age female fem30.

 

Syntax Legend Missing Values The usual recodes recoding a dichotomous variable (coded 1 or 2) into a dummy variable (coded 0 or 1). creating an interaction term (fem30) which takes the value of 1 for women over 30 years of age. See multiplication table below.

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 8/11

     <30(0)   >30 (1)

Male (0)          0       0

Female (1)          0       1

The regression command. Be sure to include "tol" in the statistics line in order to assess multicollinearity.  Two method subcommands are included, one without and one with the interaction term.

Output            * * * *   M U L T I P L E   R E G R E S S I O N   * * * *

Listwise Deletion of Missing Data

N of Cases =  1835

           * * * *   M U L T I P L E   R E G R E S S I O N   * * * *

Equation Number 1    Dependent Variable..   INCOME

  Descriptive Statistics are printed on Page    2

Block Number  1.  Method:  Enter      AGEDUMMY FEMALE

Variable(s) Entered on Step Number    1..    FEMALE    2..    AGEDUMMY

Multiple R           .18121 R Square             .03284 Adjusted R Square    .03178 Standard Error      2.70153

F =      31.10496       Signif F =  .0000

­­­­­­­­­­­­­­­­­­­­­­­­­ Variables in the Equation ­­­­­­­­­­­­­­­­­ ­­­­­­­­­

Variable              B        SE B       Beta  Tolerance        VIF         T

AGEDUMMY        .679421     .135058    .115613    .999351      1.001     5.031 FEMALE         ­.782345     .126165   ­.142512    .999351      1.001    ­6.201

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 9/11

(Constant)     5.545508     .126958                                     43.680

­­­­­­ in ­­­­­­­          ­­­­­­­­­­­ not in ­­­­­­­­­­­­

Variable    Sig T          Variable   Tolerance        VIF

AGEDUMMY    .0000          FEM30        .240225      4.163 FEMALE      .0000 (Constant)  .0000

End Block Number   1   All requested variables entered.

           * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Block Number  2.  Method:  Enter      AGEDUMMY FEMALE   FEM30

Variable(s) Entered on Step Number    3..    FEM30

Multiple R           .19095 R Square             .03646 Adjusted R Square    .03488 Standard Error      2.69720

F =      23.09946       Signif F =  .0000

­­­­­­­­­­­­­­­­­­­­­­­­­ Variables in the Equation ­­­­­­­­­­­­­­­­­ ­­­­­­­­­

Variable              B        SE B       Beta  Tolerance        VIF         T

AGEDUMMY       1.029219     .189592    .175137    .505511      1.978     5.429 FEMALE         ­.302044     .222161   ­.055020    .321268      3.113    ­1.360 FEM30          ­.707862     .269702   ­.122831    .240225      4.163    ­2.625 (Constant)     5.312372     .154780                                     34.322

­­­­­­ in ­­­­­­­

Variable    Sig T

AGEDUMMY    .0000 FEMALE      .1741 FEM30       .0087 (Constant)  .0000

 

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 10/11

Interpretation The first block of the regression analysis shows the additive effects of and age and gender on income levels.  The mathematical interpretation of the b coefficients, the Adjusted R­square, the confidence intervals, and statistical significance is the same as described in the Regression Lab.  Thus, it will not be repeated here.  Note that both and gender are statistically significant. The second block of the regression analysis shows both the additive and interaction effect of age and gender on income levels The age variable and the interaction term (Fem30) are significant but gender is not significant. The interaction term can be interpreted as showing that the interaction of being female and over 30 is a significant negative predictor of income. In this regard, an interaction term is equivalent to specification. To see how the equation can be converted to a graphic, CLICK HERE. The tolerance scores tell us that multicollinearity is a source of concern in our regression model, but the results are still statistically significant and acceptable by conventional standards (recall from the Multiple Regression Lab that any tolerance score higher than .20 is acceptable; any score lower than .10 indicates a serious problem with multicollinearity).  However, multicollinearity is frequently a serious problem in interactive regression models because the interaction term is constructed from two variables that are already included in the model. 

Instructions 1.  For this exercise you will perform a multiple regression analysis with an

interaction term 2.  Create an interaction term: As always, it is best to work with an explicit

hypothesis in mind. 3.  Multiply two independent variables together to create the interaction term. 4.  Create a new variable (with a new variable name) to measure the interaction.

You can name it "inter" or something more descriptive.  compute inter=IndependentVar*ZVar.

5.  Once you have made all necessary recodes, declared missing values and created an interaction term, enter all variables (including the variables used to create the interaction) into a multiple regression equation with two steps, or blocks.

regression variables= DVar IVar1 IVar2 Inter     /statistics coeff outs r tol     /dependent=DVar/method=enter IVar1 IVar2 /method=enter Inter.

6.  Based on the output, determine whether the dummy variables and the interaction term are significant.  If neither are, repeat the process until you find an appropriate set.

DISCUSSION As we have already mentioned, the two methods for analyzing interaction effects in a regression simply express the interaction (or specifrication) effect in a slightly different way.  But the two methods have different advantages and disadvantages:

When you have only one interaction (specification) of interest, the

1/19/2015 Regression with Dummy Variables

http://groups.chass.utoronto.ca/pol242/Labs/LM­9B/LM­9B_content.htm 11/11

regression with a subset of cases approach is often easier to use and interpret. An example of one such an interaction (specification) is geographic region: many of the relationships between independent and dependent variables differ in different parts of the world (e.g. Francophone Quebec vs. the rest of Canada; Africa versus other parts of the world).  Regression with a subset of cases doesn't readily allow you to examine several different kinds of interaction effects simultaneously:  you may, for example, want to test not only whether gender affects the relationship between age and income, but also whether education affects the relationship between region and income.  These complex models cannot readily be analyzed using the regression with a subset of cases method.  Moreover, this approach is only appropriate when the control variable has very few categories. The approach of including an interaction term can often be difficult to set up and to interpret. However, the interaction term approach enables you to examine a variety of different interactions simultaneously.  Moreover, using this method you can directly compare the R­squares for the additive and interactive models to see whether the interaction explains more variation on y.