- [Instructor] Hello, and welcome to the video lecture
on dummy variables.
So far, all of our variables,
all the ones that we've worked for,
have been numerical for the most part ratio
but can be expressed as a true number.
But many important attributes
that we use in social science
and other kinds of investigations are nominal or ordinal.
Thinking about marketing research,
you might wanna think about firmographic, demographic,
geographic, psychographic,
all of these may need a nominal or ordinal variable
to express them.
So such as do you live in Vermont?
Or your gender
or your race
or your attitude about certain things.
So it's important to have the ability to express these
and to be able to work with these in regression analysis.
The way that we address this is to create one or more binary
or so-called dummy variables.
So these can be expressed such as zero, one.
One if you are that thing, zero if you're not.
So Vermont resident.
And for me, it makes more sense
to do it like this than to call it residents or state.
Because if you call it Vermont resident
then you're sure what the one stands for,
where if it's state
it's like I don't know what state is a one.
Certified organic.
One of my favorites, of course, is full professor.
And,
gender may be expressed
by coding somebody as one if they're a female
and zero if they're not.
In some cases,
a series of them may be needed.
If there's more than one state,
more than, Vermont or not,
but you might wanna also say,
do you live in New Hampshire, Maine, et cetera?
You may need to express gender as more than two.
So you could have male, female
and a third such as non-binary
or none of these.
So focusing a bit on gender.
This can be the single,
using a single dummy in a regression
such as how does being female impact wage?
Do females own or earn more or less
or the same as other genders?
So, and you might wanna think about,
do Vermont resident students have higher or lower
or the same GPA at UVM
as students that are not from Vermont.
So to ask the first question,
we have a very simple model here with two regressors,
female and education.
So how many years of education
and the effect of being female on wage.
You can think about controlling for gender.
What's the effect of education?
And controlling for education,
what is the effect of gender?
And note that the Wooldridge books use this funky D,
this delta D for dummy variables.
And I'm going to continue with this convention.
Here's our model wage.
We have female and we have education.
And the best way to think about the value of this delta
is to think of it as an intercept shift.
So depending on its magnitude,
if it's greater than zero or less than zero,
it's going to shift the intercept up and down.
So you can think about it as,
let's assume, or let's hypothesize
that delta naught is less than zero.
That all else equal,
being female has a negative effect on wages.
Which I think, historically, has largely been true.
So you can see it as,
that delta naught is,
the expected value of wage
given that someone is female
and given some amount of education,
or it's the difference,
this last point of the expected wage
for a given amount of education
between females and non-females.
And when we talk about this in class
I will draw a simple graph.
But you can think of it
as is it actually is an intercept shift.
So in this example,
the Y intercept for non-females is beta naught
and the intercept for females
is beta naught plus delta naught.
So it really does just shift the intercept.
One thing that you have to be very careful of,
is to not fall into the dummy variable trap.
Now, of course, this is a well-known phenomenon.
First discovered a long time ago in a galaxy far, far away
by Admiral Ackbar.
But the bottom line is,
you always have to have an omitted category.
So let's say that you're interested again in two groups,
Vermont residents, one,
and residents of other states.
And you've named them
and,
everyone is either a one or zero.
So if you live in Vermont,
you're a one for Vermont res
and a zero for other res.
And if you live in New York,
say, you're a zero for Vermont res
and a one for other res.
So why not use both?
Why not put them both into the regression?
What's the problem here?
I'll let you think about that for a moment.
Feel free to pause and think about it.
And then I will tell you.
So the problem is they always add to one.
They are perfectly collinear.
So adding up Vermont for any individual,
Vermont res plus other res equals one for any individual.
So you can only include one.
And the other way of thinking about it is,
if you include Vermont res,
the variable of other res adds no new information.
And actually, the regression will fall apart
because we have perfect collinearity.
So you always have to have at least one omitted group.
And that the way that you code that
will determine what is your omitted group.
So in this case,
this Vermont res would be, what is the intercept shift,
or what is the effect of a Vermont resident
on our Y holding all else equal?
And in the comparison is those who live in another state.
And I hopefully this all makes sense.
Again, we can see this graphically
as being literally an intercept shift.
Note that this, I know,
this graph I just got it from the Web.
And it assumes that that everyone is either female or male.
And of course that may or may not be true.
But just you can think of, on the graph here,
what it says male would just be non-females.
So here, non-females are the base group,
the benchmark or the omitted group.
So their y-intercept is just whatever,
alpha naught here or beta naught,
as we have been denoting it.
And the intercept for females is beta naught
plus delta naught,
or here in the graph, alpha naught plus delta naught.
And you can see in this case,
the coefficient delta naught is less than zero.
That the effect of female on wages is negative.
So holding education constant,
in this case,
the effect of female is negative.
So we would predict on average,
given an amount of education,
that a female's wage
would be delta naught less than a non-female's wage.
You can of course add many other regressors.
You may, not only education, but you might have experience,
how long have you been in the workforce in general,
and you'll have
how long have they been with this particular company?
You could add a bunch of others.
But how would you test for gender discrimination?
Basically, as says up here,
it would be a simple T-test on our delta naught.
And I will let you ponder what would be the advantages
or disadvantages of a one or a two-tailed test.
So think back to last week,
what would be the advantages to a one or two-tail test,
and we will discuss it in class.
But basically, what this analysis does is,
holding all else equal,
education, experience, et cetera,
do females earn lower ages?
If you could think about other examples that you might use.
Do Vermont students do better in class?
That's one we thought of.
Does owning a computer improve your GPA.
And I think you could think of a lot of other examples
where you would have a dummy variable as some,
just to test some kind of a policy.
And in some cases it might make sense
such as give half the students computer
and not give them half.
That you could see the omitted group,
those that are a zero,
didn't get a computer as a control group.
And the ones the got a computer would be the experimental
or the treatment group.
There may be times
when you want to include more than one dummy variable.
For example,
does marital status have an effect?
So that would be holding your gender constant
and all the other factors, education,
does your marital status impact your wage?
One of the things that you could do
is that the sort of simplest thing,
would just be to include one that says,
say, married, a dominant variable married.
One if you're married, zero if you're not married.
The thing is,
this assumes that the effect of marriage on females
and non-females is the same.
And it's been my experience, just say maybe anecdotally,
that, that is not true.
That marital status is not the same for men and women
or other genders.
That in many cases,
since it's still sort of a traditional structure
in many ways,
that women play a larger role in care and so forth,
that the effect of being female and married
is different than the effect of being male or non-female
and married.
So what we could do here
is create a dummy with each of,
so there's four of them
and create a dummy variable for three out of the four.
So we would omit single non-female.
So we would have married non-female,
single female, married female.
And then there would be three groups that we would look at,
and this would create a different intercept
for each of the three groups
with beta naught
being the intercept for the single non-female.
That tells you something about how to deal with nominal,
where you could say, are you this thing or are you not?
But what about ordinal?
So a five point scale, how often do you?
Or a five point scale of how likely are you?
Or how satisfied are you?
Or how much do you agree with this?
Thinking back to the market research,
many psychographics are probably best captured by a scale.
So say that you ask a five point scale on your survey,
you have data
where folks write down some number one through five,
such as here, one equals never five equals always,
how do we deal with these data?
The most obvious answer
would be to create up to four dummies.
And in this case, so you would create four of them.
Those who say occasionally, sometimes, often or never.
So they would get a one if they answered that,
and zero everything else.
And then never is the omitted group.
So the folks who said never,
their y-intercept is just beta naught,
and those who say always, say,
their y-intercept is the beta naught
plus the delta for the always do variable.
What I most often do is to find a cutoff that makes sense.
That is logical and create groups of roughly equal size.
So find a place where about half are above this
and half are below this and call it high or low,
and just create one dummy.
And the advantage of this is it saves degrees of freedom.
So, you know, be,
if about half say three or less,
and then another half say four or five,
then you could just do it like that
and call it high frequency
and then one would be those that said four or five
on the scale.
Zero would be those who answered one through three.
But the key thing is to do it so that it's both it's logical
So that you can kinda say,
oh, well, these folks are high and these folks are low,
as well as having about equal numbers in each group.
The problem of having them where say 95% are ones
and only 5% of the sample are zeros,
is you basically have a long column of ones
with hardly any zeros in that.
There's not a lot of information there.
Almost everyone's a one.
It really doesn't break out the groups bigger in anyway,
plus a long string of ones
or a long string of zeros in the data column
is going to be highly collinear with your intercept.
So that's why
you'll always want to create groups of about equal numbers.
And it may also make sense to create more than one dummy
to break it up into high, medium, low,
or something like that.
But again, you want it to be logical
and have about equal numbers in each group.
So far,
we've seen how a dummy variable can change the intercept
and we can have a number of dummies
and even interact them.
And that will change the intercept of the various group
depending on if you're a one or a zero
for the various regressors that we have.
But it's also possible
to interact a dummy with a continuous variable,
in which case it will change the slope of a line.
So let's say continuing on,
look at the effect of education and being female on wage,
here you see
that we can interact them and have,
we would, in SPSS,
compute a variable female times education
and then run this.
And in this case,
you can see that not only are there different intercepts
for each group,
but the slope of the line.
So you can see
what the intercept here
in the graph,
it's clear that when this D equals one,
that it has an intercept shift.
And that is what we have seen so far.
A closer look at this graph tells you what is going on here.
So let's say that,
again, we're looking at the effect of wages,
but let's say that in this world
that being female is an advantage.
So this beta two here
is the dummy variable for female.
So you can see females have an advantage on the y-intercept.
And not only that, but when you interacted with the X
such as education or experience,
these lines divert that the slope,
the effect of X on Y
if you're in the D one equals zero group is just beta one.
And if it is,
if you're in the D equals one group
then the slope is beta one plus beta three.
So in this case, this group not only starts off better,
but the returns through education are even greater.
So you can see it's both a change in the intercept
and the change in the slope.
And I will run an example in class
and put this on the board so you can see it more clearly.
You may think that your dummy variable
has an effect on all of your regressors.
So in this example, the dummy of female
might not only have an effect on returns to education
but returns to experience and age and other things.
So in theory, you could have an interaction for each one
but this is time consuming and it also really,
starts to eat into your degrees of freedom.
So what you can do is split the sample
and use an F-test, a special kind of F cast
called a Chow test,
to see are the two groups really different from each other?
Do sort of females and non-females,
are their betas the same or not?
So in this case, you would run three regressions.
First with all of the regressors,
next, only the females,
and then in the third case, only the non-females.
And you wanna look at the SSR
at the sum of squared residuals.
So you'll run these three regressions
and you can split the sample.
That's how you can do it in SPSS.
I'll show you how to do that.
And you get three of them.
And you look at the SSR and you plug it into this formula.
So you can see
it is the relative change in explanatory power
by running it as a group
versus running each group individually.
Note that the pooled will always be greater
because you're gonna get a better fit
if you give each group their own betas.
But when you sort of adjust
for the change in degrees of freedom,
what happens here?
So you do that and you get this to test that,
and you compare it with an F distribution
with K plus one and N minus two K
minus two degrees of freedom.
And the null is that the beta across the groups is equal.
So you can see that if the sum of squared residuals
are about the same,
that the pooled minus the sum of the other two
if they're really close,
then their betas are very much alike,
the numerator of your F stat is very small.
We will have, and we would fail to reject that null,
and that we would think that the betas are more
or less the same.
But if we see a big change,
if the betas in the two groups are a much better fit,
again, we're gonna see a big F stat
and a small P, and we will reject the null
and say that these two groups
do not experience the world in the same way.
And here is just a better,
(Instructor inhales)
(Instructor exhales) a more neatly laid out a way
to express this mathematically.
A few other asides about a Chow test.
That you can't use the R squared form of the F-test
that we learned about.
And it also assumes heteroscedasticity.
So you would need to test for homoscedasticity
and make sure that is the case.
And we'll learn how to do that soon.
This sort of Chow test
is also used in sort of regime switching.
So if there's some event
that you think will really sort of changes the world.
So you might wanna look at,
the years of the Trump administration on immigration
or on trade.
Because President Trump,
greatly changed how we go about our business
in these things.
We could see like,
are the betas in sort of before and after Trump,
or before and during Trump the same?
Or so was this like really a regime change?
Did it like fundamentally change
the nature of the model,
the nature of the betas or not?
The last thing that I want to cover here is,
how do we deal when our dependent is a dummy?
So that would be one.
So our dependent, our Y is a one.
Are you in a group or not?
Did you do some action or not?
Do you own a thing or not?
Do you own a bike?
Do you smoke?
Do you pass this class?
I hope everybody's a one, of course.
But sometimes we may want a model,
a binary dependence.
And when we have the model that we've worked for,
this Y equals beta naught plus the beta one K
plus dot dot dot beta K XK,
the beta kind of doesn't really make sense
of how does Y change as X changes,
because Y can only have a one or a zero of the values.
So neither changes it or it doesn't.
So what we do is we look at the probability.
So here,
we have the probability of Y equals one
given X is the expected value of Y.
Given X.
So you could think about it as,
if you put everybody's Xs in,
and the calculate Y,
that would be the probability that they are Y.
What we would guess, what we would forecast,
if someone gave all of these Xs on a survey,
what is the probability that they would be a Y equals one?
What's the probability that they own a bike?
Yeah, and we can think about that beta J
is a change in the probability that you would be a Y
holding all else equal.
This model is good because it's very simple
and straight forward,
but you could get Y hats that would be less than zero
or greater than one,
which of course make no sense,
because you can't have negative probability
nor probability greater than one.
These are very often heteroscedastitic.
So you would need to deal with that,
which we will learn how.
And in truth, there are better ways to deal with this.
But I just wanted to sort of show you this.
This is the way.
It can work well in certain cases,
but we're gonna learn a better way to deal with it
in a few weeks.
That's the end, and thank you.