Transcription of Chapter 7, Dummy Variable - Miami University
1 Chapter 7, Dummy Dummy Variable takes on 1 and 0 only. The number 1 and 0 have no numerical(quantitative) meaning. The two numbers are used to represent groups. In shortdummy Variable is categorical (qualitative).(a)For instance, we may have a sample (or population) that includes both femaleand male. Then a Dummy Variable can be defined asD= 1 for female andD= 0for male. Such a Dummy Variable divides the sample into two subsamples (or twosub-populations): one for female and one for male.(b) Dummy Variable follows Bernoulli distribution. The distribution is characterizedby the parameterpD={1;with probabilityp0;with probability 1 p(1) using Dummy Variable as regressorY= 0+ 1D+u(2)Regression (2) can be broken into two separate regressions asY={ 0+u;whenD= 0( 0+ 1) +u;whenD= 1(3)Taking expectation of (3) leads toE(YjD= 0) = 0(4)E(YjD= 1) = 0+ 1(5)and 0=E(YjD= 0)(6) 1=E(YjD= 1) E(YjD= 0)(7)Therefore 0is the mean ofYconditional onD= 0 (or mean ofYin the subpopulationwithD= 0), 1is the differencein meanYbetween the two mean is the estimate for population mean, so we have the following interpre-tation for the estimated coefficients in (2) 0= yD=0(8) 1= yD=1 yD=0(9)where yD=0denotes the averageYin the sub-sample for whichD= 0.}}
2 YD=1denotesthe averageYin the sub-sample for whichD= 1:Equation (2) provides a simple wayto carry out a comparison of means test(or two sample t test) between the two null hypothesis of two-sample t test says that there is no difference between twogroups:H0: 1= 0 This hypothesis is rejected when thep-value for 1is less than example, letYbe wage, andD= 1 for female, andD= 0 for male. Then considerthe regressionwage= 0+ 1D+u;and we know 0is the average wage for male, and 1equals average female wage minusaverage male wage. The two wages are significantly different if 1is consider a regression with regressorXY= 0+ 1D+ 2X+u(10)which can be rewritten asY={ 0+ 2X+u;whenD= 0( 0+ 1) + 2X+u;whenD= 1(11)It follows thatE(YjX;D= 0) = 0+ 2X(12)E(YjX;D= 1) = ( 0+ 1) + 2X(13) 1=E(YjX;D= 1) E(YjX;D= 0)(14)so 1measures the change in mean Y across two groups, holdingXconstant (or given2the same level ofX).}
3 For instance, ifXis edu(cation), in the regressionwage= 0+ 1D+ 2edu+u; 1equals the average female wage minus average male wage, given the same level (11) we can showdE(YjX)dX={ 2whenD= 0 2whenD= 1(15)So regression (10) is restrictive by assuming that the marginal effect ofXonYdoesnot depend onD:Go back to the wage example. This restriction assumes that wheneducation changes, wage changes at the same rate for female and Chapter 6 we know interaction term can be used to allow the marginal effect ofXtodepend on another regressor. The regression with both Dummy and interaction termof Dummy andXisY= 0+ 1D+ 2X+ 3(X D) +u(16)which can be rewritten asY={ 0+ 2X+u;whenD= 0( 0+ 1) + ( 2+ 3)X+u;whenD= 1(17)The last equation makes it clear thatDummy Variable allows for different intercepts (or intercept shift)Interaction term of Dummy Variable andXallows for different slopessee Figure in regression (16) contains the same amount of information as two separate regressionsofYonX;one using subsampleD= 0;and one using subsampleD= 1 : derive the marginal effect ofXonYimplied by (16) we have two subsamples, one for female and one for male.}}
4 We want to estimatethe effect of education on wage. We have two options. Option 1 is to run two separateregressions, one for female and one for male. Option two is pool (merge) the twosubsamples together and just run one regression. Which option is better?(a)Essentially this problem is about whether the relationship between education andwage depends on gender(b)To answer this question, we just pool the two subsample, and run regression (16).The point is, we need to use Dummy Variable and interaction term. The nullhypothesis is gender does not matter, so 1= 3= 0(18)We can use F test (called Chow test in this context) for this p-value is less than ,H0is rejected, so gender matters. We need to keepthe Dummy and interaction term in (16). That means, running two separateregressions, one for female and one for male, is better p-value is greater than ,H0is not rejected, so gender does not need to drop the Dummy and interaction term from (16).
5 That means,running one regression using both subsamples is better if we have information about gender and marital status? Option one is to definetwo Dummy variables asD1={1;female0;male(19)D2={1;married0;u nmarried(20)and use them to run the regression ofY= 0+ 1D1+ 2D2+u(21)4 For this regression we can showE(Y) = 0;ifD1= 0;D2= 0 0+ 1;ifD1= 1;D2= 0 0+ 2;ifD1= 0;D2= 1 0+ 1+ 2;ifD1= 1;D2= 1 Now we can see regression (22) is restrictive because it assumesE(YjD1= 1;D2= 1) E(YjD1= 1;D2= 0) =E(YjD1= 0;D2= 1) E(YjD1= 0;D2= 0);(22)In words, whenD2 changes from 0 to 1, the change in meanYdoes not depend onD1:This is a kind of no-interaction restriction. LetYbe wage. Then no-interactionrestriction says that when a person changes his/her marital status, the change in wagedoes not depend on the gender of the order to relax the no-interaction restriction, we can define four Dummy variables(because we have four groups of people) asE1={1;female and married0;otherwiseE2={1;female and unmarried0;otherwiseE3={1;male and married0;otherwiseE4={1;male and unmarried0;otherwiseand run a regression using only threeof themY= 0+ 1E1+ 2E2+ 3E3+u(23)If we use all four dummies, thenE1+E2+E3+E4= 1 so is perfectly correlated withthe intercept term.}}}}}}
6 This situation is called Dummy Variable trap. In order to avoiddummy Variable trap, we leave out one : Please show regression (23) does not impose no-interaction a special variableX= 1;using bus2;using subway3;driving car(24)Note thatXhas no numerical meaning, so is qualitative. Numbers 1, 2 and 3 are usedhere to define three categories. Number 2 does not mean it is twice of 1. Because thevariable is qualitative, we need to translate it into a set of Dummy variablesF1={1;using bus0;otherwiseF2={1;using subway0;otherwiseF3={1;driving car0;otherwiseWhen running regression, we do not useX(since it has no numerical meaning). Insteadwe use two of the three Dummy variables defined same idea can be applied to an ordinal Variable such asX= 3;exceeds expecation2;meets expecation1;fails expecation(25)For ordinal Variable we only know ranking. The number has no numerical we can replace number 3 with any number greater than 2 (to maintain theordering).}}}
7 Because ordinal Variable is qualitative, we need to translate it into a set ofdummy variables. We cannot directly use ordinal Variable in : Chapter use the data file , downloadable at my webpage. See example intextbook for see for the first observation, wage = , educ = 11, female = 1 (so is female), andmarried = 0 (so is unmarried). Female and married are both Dummy variables, forwhich the values 1 and 0 have no quantitative used to tabulate proportion (probability) for Dummy Variable . In thiscase percent observations are male (female=0), and percent are we run regression (2), , regress wage on Dummy Variable female. The estimatedintercept 0= yD=0= 7:099489 is the average wage for male. The estimated slope 1= yD=1 yD=0= 2:51183 is average female wage minus average male wage. Inthis example female earns less than male since 1is negative. Thep-value for 1isless than , so we reject the null hypothesis that female wage equals male wage.
8 Inother words, the two wages differ we can summarize wage separately for female and male. The commandissort femaleby female: sum wageOn average a male earns , and a female earns The difference is4:587659 7:099489 = 2:51183;which is the same as 1reported by regression (2).This finding confirms thatRegressingYon Dummy Variable carries out the two sample t we run regression (16) usingX= educ:wage= 0+ 1female+ 2educ+ 3(educ female) +u(a)The estimated intercept is 0=:2004963:It measures the average male wagewheneduc= 0:7(b) 1= 1:198523:It measures the average female wage wheneduc= 0 minusaverage male wage wheneduc= 0:In other words, when educ = 0, a female earns:2004963 + ( 1:198523) = :9980267:This number is not very meaningful sincein this sample no female has zero education (two males have zero educ, and youcan see them using commandlist if educ==0).(c) 2=:539476:So male wage rises by.
9 539476 when his educ rises by 1 unit.(d) 3= :085999:So female wage rises by:539476 + ( :085999) =:453477 whenher educ rises by 1 unit.(e)The null hypothesis that the relationship between wage and educ does not dependon gender (or there is NO difference in regression functions across female and male)can be formulated asH0: 1= 3= 0:The F test for difference in regression functions across groups is called Chow testThe stata command to conduct Chow test istest female fe. It is shown thatF= 33:51;p-value<0:05:So we reject the null hypothesis. That means thereIS difference in regression functions across female and male. In other words, therelationship between wage and educ depends on gender.(f)Note that 1and 3are individuallyinsignificant (thep-values are and ,respectively), whereas the Chow test indicates that they are lesson is, just focusing on individual coefficient can be the relationship between wage and educ depends on gender, we can run twoseparate (group-wise) regressions, one using female and one using male.
10 The statacommand isby female: reg wage educ. We see the coefficients in the male regres-sion are the same as 0and 2reported by the pooled regression (16). The femaleresults can also be derived based on the pooled regression (16). In other words,Regressing on Dummy and interaction terms is as informative as groupwise regressionsThe pooled regression (16) has one big advantage over groupwise regressions: we canrun Chow test based on (16). you are shown how to define a set of Dummy variables to represent multiplecategories of gender and marital status. In theory we should define four dummies since8there are four groups. But, aware of Dummy Variable trap, we only define three. Thegroup for which we do not define Dummy is base group. In this example, the basegroup is unmarried male. The three Dummy Variable sareD1 = 1for married maleD2 = 1for unmarried femaleD3 = 1for married femaleConsider the regression ofwage= 0+ 1D1 + 2D2 + 3D3 +uTo facilitate interpreting coefficients, let break down the above regression toEwage= 0;whenD1 =D2 =D3 = 0 0+ 1;whenD1 = 1 0+ 2;whenD2 = 1 0+ 3;whenD3 = 1 The interpretations of coefficients are(a) 0= 5:168023:It measures the average wage for unmarried male, the base group.