- [Instructor] Good morning, everyone.
It's nice to be back at this,
I know that I wish
things were under slightly better circumstances,
but nonetheless, we're gonna get through this
and I'm excited for the rest of the semester.
So, this time, we're gonna start on panel data,
which is collecting responses
from multiple respondents over time.
You may remember that so far,
everything we've done is cross section
where it's one time period, T equals one, N equals many.
Later, we're going to be doing time series,
which is N equals one, T equals many,
but these next two sections are about
T equals many and N equals many.
So, here is a little bit of humor
that I hope that you appreciate.
So, this is the problem set based on panel data,
this reflects the next two weeks of work,
so, it's not due until April 3rd.
First, I want you to show the intuition and the math
of this difference of difference models,
show that this Delta one hat
reflects
the effect of the treatment and time too
and you'll see what this means when we go forward.
I want you to give an example of where we would use this,
two locations and two time periods or treatment and control
two time periods and explain what that is.
Next I want you to talk about the difference between fixed
and random effects, and which one is better and why.
And finally, the Hausman test,
which is tied to number three there,
where we talk about which model to use.
And I want you to describe this test much as you did
on the midterm exam for other tests.
So, again, so far we've been doing cross section,
which is T equals one, N equals many.
Now we're going to do both T and N, greater than one.
So, again at N and T, N being the number of respondents
and the T being the number of time periods,
both being greater than one.
And we're gonna talk about two main types,
independently pooled cross section and panel data.
So, in one case, it sort of the first one,
independently pooled is you're asking the same questions
to different people at different times,
and in sort of true panel data,
you're following people over time
and asking the same questions to the same people
and tracking responses.
So, if I were a panel member,
they would know what I said in the first time period
and the second time period, and the third,
and however many there are,
and knowing what I said on the survey each time.
So, again, the first part
is independently pooled cross section.
So, again, you pool a random sample each time.
So, you have a common set of questions that you ask
over multiple times,
but each time you're pooling a new sample,
a random sample, hopefully.
And because each observation each time
is sampled independently,
you're drawing a new sample each time,
this gets rid of a lot of problems,
especially autocorrelated errors.
And a good example of this might be that,
a common set of questions on the Vermonter poll.
So, we ask them in 2019,
we asked them in 2020, totally new sample each time,
but we record the answers
and see how the answers change over time.
Versus, again, panel data,
which is where we're following the same people,
usually people, but it may be households,
or firms or cities, or many other units of analysis.
Again, it's the same subject over time.
And we follow an individual respondent
and how they answer over time.
We pay attention to that,
of how each individual responses change over time.
So, now we get back to independently pooled cross section.
So, one of the things that we need to do
is account for how to do the responses
just naturally change over time,
that as time advances things change,
the responses to questions change over time.
So, the most obvious way to do this would be
to have a dummy variable for each year.
So, say again,
we're doing the Vermonter poll 2019, '21,
we simply have a dummy variable for one of those years,
probably 2020, that controls for everything
that changes over time.
So, holding all as equal,
what's simply the effect of time
of a year in advance on how people
answer the question?
You can also, as we learned in dummy variables,
interact this time dummy variable with our other regressors.
So, as income changes and as education changes
and as age changes, et cetera.
How does that change the slope
of those variables like income and age, et cetera,
over time?
What's the effect of a change in time on those?
And we remember that we did that,
that different slopes for different folks name
as we dealt with in dummy variables.
And you could also in theory,
have a different dummy variable for each person,
but think about what would be the problem there.
I will give you a second to think cue the Jeopardy Music.
So, the problem there is if there's a different dummy
for each individual,
you're very quickly going to run out of degrees of freedom
and because that's a whole lot of extra variables.
But most of the problem with this is dealt with
because we are drawing a new random sample each time.
In panel data it's a little different and we'll see.
So, again, thinking back to the different slopes
for different folks,
questions or this time it's different slopes
for different times question,
you can interact all the time dummies
with all your other regressors
like, we learned about in the dummy variable section,
or also as we learned about in that section.
Do a child test and split up the sample
into time period.
So, again, with the Vermonter poll,
split it up into the 2019 and 2020 responses
and run a child test, run each
year's data independently
and then pooled and use a child test
that F test to see if it works.
You could also do this in multiple time period.
So, if you had multi-year data
2018, 2019, 2020,
you could test the null hypothesis
that the slopes of all of our regressors are the same
over each time.
That time didn't change the fundamental way
over which people answer.
So, now we're going to use a very well-known
and it seems like kind of hot and sexy method
to look at certain applications of policy analysis.
The so-called difference in differences model.
And this is good for a sort of natural or quasi experiment.
So, you can think about something happening
to two different areas over two different times,
some sort of treatment where this thing happens,
some kind of control where it doesn't happen,
and then what is the effect of the change in time?
So, this is very often used and I'm gonna use an example
looking at the very bottom bullet
that sort of classic application is some sort of NIMBY,
some sort of Not In My Backyard,
like, some nasty trash incinerator or something else
that people probably wouldn't want
moves into a neighborhood.
And we want to measure the effects of property values.
So, imagine that our Y is the property value of homes
in each place.
So, if it happens in the neighborhood
where this trash incinerator is put in,
then they're coded as one as the treatment group
and the comparison neighborhood where this doesn't get
the trash incinerator is zero.
And then we have a time dummy variable
that after it's put in and we remeasure,
that's coded as one.
And before it's put in,
which is sort of a baseline measure is coded as zero.
So, the reason that we do that,
that we control for location is that it might be,
as we know, there's lots of sort of evidence out there
in the world of things like environmental racism,
where they tend to put the NIMBYs,
these nasty, polluting, dangerous things in neighborhoods
where poor folks live,
or maybe people of color or other marginalized groups,
that you're not gonna see a trash incinerator
put into a very wealthy neighborhood most of the time,
because those folks tend to have more political agency
and will raise a big fuss.
And so, that's kind of a non-starter,
but sadly, we do tend to put things
in marginalized neighborhoods.
So, we want to control for that.
We wanna look at choose a marginalized neighborhood
that doesn't get this trash incinerator and one that does.
So, we're controlling both for
what is the effect of property values
in those neighborhoods.
So, we take baseline measures.
So, we measure property values in a random sample
of control and treatment.
Then we look at, they put in this NIMBY,
this trash incinerator.
We wait until we think that the treatment has an effect
and we remeasure.
So, the way that we do this
is we run a regression of course,
where Y equals the property value,
DT is our dummy variable for the treatment.
So, that is the effect of the treatment independent of time.
This Delta naught is the effect of the time
independent of the treatment.
And then finally,
the real variable of interest is this Delta one
where we are multiplying,
D2 times DT.
So, multiplying both treatment and effect.
So, for everybody,
except those who are in the neighborhood
that gets the NIMBY
and in time two that will be zero.
So, this is seen as being the average treatment effect.
And I'm asking you on the homework to do the math
that shows that Delta hat is this equation.
So, it's the Y bar one that you see there
in the bullet points.
So, it is the first part
in parentheses is the change
in the time over treatment
and control, minus the second term,
the change in,
wait a minute, that's not right.
I'm sorry.
So, the first term is the difference
in the two neighborhoods in period two.
And the second term is the difference
in the two neighborhoods in period one.
So, I apologize for that.
And I'm going to have you measure how that works.
Now, we're going to panel data,
and this is again,
where we're not drawing a random sample each time
we are measuring responses
of the same people over time.
So, one of the things that we have to do
is account for the fact
that we're not drawing a random sample.
So, we use what's called the fixed effects model,
and there's a few of them,
and you're gonna see an example of one today,
and then we're gonna do another one next time.
So, it's very common that panel data
are prone to missing variable bias.
And they're also, as we'll see, very prone to endogeneity.
And it's very...
You can only ask for a certain number of questions
on a survey.
So, we're there's a danger of omitted variable bias.
Lots of things go into the error term.
And what we do in these fixed effect models
is we break our error term into fixed
and what we call idiosyncratic stochastic elements.
So, these idiosyncratic stochastic elements
are back to the beginning of the class.
That's the bingo ball wheel, spin the wheel,
draw an arrow term,
all kinds of random things that may or may not happen
to you, good and bad.
The fixed ones
are things that are really related
to you being you.
What are the factors that are really hard to measure
that are just fixed and being you
that every individual is different.
And we can't measure every factor about every individual.
So, we try to control for that.
And we're gonna see how we do that next.
So, here, is the classic fixed effects model.
We have one regressor,
that is the sort of the regressor of interest X one here.
So, we model it as,
and note that there's lots of I's and T's here.
So, I is the Ith person or city.
I'm going to show you an example of how this may be applied.
So, hang on in the next slide.
So, this assumes that we ask one,
sorry, two questions on a survey.
A Y question and an X and X one question.
So, Y is our dependent variable,
X is our independent variable,
and those are the variables of interests
that we want to model here.
So, YIT is the Ith person's observation in time T.
The D two is simply a dummy variable for time two.
So, it's coded as one
if these data came from the second time period
and zero, if they came from the first time period.
The really interesting thing here,
is this AI.
So, AI, or I'm just calling it A one here,
is all those individual factors
that affect the individual.
It's sort of the unique attributes
of a given person or place or time,
and individual respondent that don't change over time.
So, one way of sort of thinking about it
is just like your genetic potential
or if the unit of analysis is a city,
just what makes Burlington, Burlington,
and what makes Barry, Barry,
and what makes Winooski Winooski.
This is the fixed effect,
it's the unobserved things,
all those things that we really can't measure
that makes Burlington, Burlington,
and Winooski, Winooski
that really don't change over time.
But we assume that they really are highly correlated with X.
Usually they are, so that what,
or you can think of it as something like a dummy variable
for person I.
So, if we're looking at
how if our Y is expenditure and our X is income,
and we're following people over time
and seeing how their expenditure on some good changes
as X changes, that the AI is just what makes you, you.
If you're a respondent,
what are all those unique,
really hard to measure things that just make you, you.
So, if it's like controlling for you
for what makes you, you
and me, me, that's what we can think of as AI.
And then the UIT is the bingo ball error,
all those weird things that may or may not happen
to you over time.
And they're very much like the cross section errors
that we've learned about
that they have those same properties.
So, here's an example,
a food co-ops once to see how spending
in their store changes
by the household income and the household size.
So, I think we would hypothesize
that the slopes of both of these would be positive,
that as folks earn more income,
they're gonna spend a little bit more money there.
And as their household size increases,
they have more mouths to feed
and they are going to spend more money.
So, they did a survey.
Again, this is fictional in 2012 and 2017.
And they asked their members, these three questions
or maybe they know because they could scan the card,
what they spent and then they asked them,
what's your annual income in that year?
And what's your household size in that year?
So, here, is fictional data
of when members of this class took this survey.
So, Connor, Carrie, Hons, Katie, me, everybody
took this survey two times.
So, this is how the data would look like in a data table.
So, you see, the first two rows are the ways
that Connor answered this question,
you can see the, he did it in years, 2012 and 2017,
that they measured his expenditure.
He gave his household income and his household size,
and you can see how this...
So, the first number
so, if you look at Connor's income in 2012,
that's, X one, one, one
so, look at the sub, the ITs and all of that.
So, the X one is income
that'll stay the same.
The second one is that it is respondent one.
And then the third, so you can see in Connor's rows,
that goes from X one, one, one
to X one, one, two,
two would be time two.
And it would be the same for everybody else.
This is how the data would be presented and organized.
So, when you look at the Xs
the first subscript is for the variable number,
the regressor number.
The second one is for individual I.
It goes with the person and the third subscript
goes with the time period.
So, we are again, looking at this same slide
with the fixed effects model,
now that you maybe have your mind around it.
So, let's assume we're working with this City Market data.
So, YIT is expenditure peak in the store,
Beta naught as before is what would expenditure be
if all the regressors were zero.
DT or D two T is a dummy variable.
It's one in year 2017,
zero for all the data collected in 2012.
And then we see these two regressors,
X one and X two income and household size.
And then everybody gets this AI,
everybody has this.
And you can see here in the bullets,
it says A1 equals unobserved effect.
That should be AI,
but this is taking me so long.
I don't want to go back and fix it, I apologize.
So, this is the dummy variable for you.
So, you took this survey twice.
This is all the things that make you, you,
all those things that you really can't measure very easily
or just wouldn't fit on the survey,
but they don't change over time.
Like, where you like to shop
and how hungry you are
and lots and lots and lots of other things
that you really can't measure.
And then the UIT is roll the bingo ball wheel.
What's your random error term
based on what might happen or what not.
You get a flat tire or your dog gets sick,
or whatever.
So, when we would actually model this,
the error term is a composite error.
And it's composed of these two parts,
the AI, your individual
sort of dummy variable,
that what's makes you, you
as well, is this UT and all the things
that make you, you are almost certainly correlated
with your household size and your income.
So, if you don't include it,
it means that the error term that we observe
this VIT, it is going to be very highly correlated
with your Xs.
So, we have to control for it somehow
it's a form of omitted, variable bias.
It's called heterogeneity bias
that the observed error
is going to be highly correlated with your Xs.
The good news is since AI
is constant over time,
it only varies by place,
or it only varies in this City Market example by person.
We can difference it out
that we can subtract it out mathematically
and look in your book to see the math
of what we do here.
But basically we take every individual's observation
and we subtract time period two
minus time period one.
So again, this is where we're looking at,
what's called the first difference equation.
So, basically we transform all the variables,
subtracting the value
of the second time period
from the first time period.
So, in our City Market example,
we take my why.
That is what I spent in 2017
and subtract what I spent in 2012.
And that is this Delta YI, for me.
And in the same way,
the change
in X for me,
my income in 2017 minus my income in 2012
is my Delta XY.
So, one way of thinking about this,
is now we're looking
at my new Y
if you will, is what is the change
in what I spent and Beta one measures?
What is the change
in what I spent based on what is the slope of measuring
where the numerator is the change in expenditure
and the denominator of Beta one
is the change in income.
So, think about it as how does the change in income
drive the change in expenditure?
So, if I spend a lot, so you can think about
how does those changes.
And now we've basically just turned it into
a cross section equation
where we're looking at how does the change over time
of one variable effect
that change over time of another.
One of the big assumptions here
is the change in error term.
So, the change in, I roll the dice,
or I spin the bingo ball wheel this time,
and until 2012 and 2017,
how does that affect
or rather that has to be uncorrelated with,
the change in X, my change in expenditure.
So, this is called strict endogeneity.
The most important thing here perhaps
is that since this AI is constant,
it is subtracted out that the AI from 2017,
that which makes me, me in 2017 doesn't change.
And so, when you subtract AI in 2017,
from my AI in 2012 it equals zero,
it drops out of the equation.
So, we just subtracted away and got rid of
this really dangerous endogeneity that we know causes error.
So, and then what we call this Beta one,
and we can just run OLS on this.
And then as long as all of our other assumptions are met,
and it is, we call this the first difference decimators.
So, this looks at how does the change in Y
change as the change in X changes?
I know this is a little bit confusing,
but hopefully this makes sense.
And because the math in PowerPoint is so messy,
I really encourage you to go back and look at the textbook.
I will also post the textbooks slides,
which can do PowerPoint in a lot neater form.
So, here are some factors that are needed,
the requirements for this to work.
So again, once we transform our data
subtract time period two
minus time period one
for our Y and all our Xs, we can just run OLS.
The biggest thing is,
so, we still are being very careful
about avoiding endogeneity.
And so, the change in narrow term,
Delta XI must be uncorrelated with the change in X.
So that's much the same as the error term
and Xs in cross sectional OLS.
So, and we do it in the same way
that we include enough Xs
to make sure that all the error is truly random.
So, we control for as much as we can.
Note that we cannot use a lag dependent variable here,
because in sometimes,
when you're working with multiple time periods,
we might think that last year's expenditure
would be an important explanatory variable last year,
as a regressor might be important in explaining this year,
we cannot do that because last year's dependent variable
has last year's error in it.
And so, it will clearly populate that the error term
in this year is,
and all those other factors are uncorrelated.
Another important factor is that Delta X must vary over time
that if it is constant.
So, if the X doesn't change over time,
so, if at some sort of a dummy variable like female,
and the person is a female in both times,
then it will subtract out.
You completely lose that.
So, it's really important that we choose Xs
that will vary over time.
So, we can think about if the unit of analysis is a city.
So, we couldn't use something like elevation
or its area in square miles or things that don't change
because they will simply subtract out.
The other thing that we have to do
it's required that we have homoscedasticity.
So, we would test for it and adjust for it
much the same as before.
And this is another factor
where if you're going to be using panel data,
talk to your advisor, talk to me,
and we can walk you through these kinds
of homoscedasticity tests
and adjustments (indistinct) this class.
So, we can also difference more than two time periods,
and that this is pretty straightforward
when you only have two, but it might be that in our example,
so, City Market also measured these variables in 2007.
So, we have three time periods now,
and here we would each equation.
So, this that you see this YIT
equals Delta one and all of that.
Now, we're including dummy variables
for periods two and three.
So that would be,
if now the new period one is 2007
then D two is a dummy for 2012,
D three is a dummy for 2017 vary.
And we measure all of our Xs
and we get much the same result as before.
So now, that we still have the same number of N responses,
but now we have T one, two, three in this case.
So, now when we look at the intercepts,
so, what would be the intercepts for times one,
two and three.
So, in time one, it's just this Delta one,
in time two it's Delta one plus Delta two.
And in time three, it's Delta one plus Delta three.
And what we're really interested in
is these Betas as with any kind of econometric analysis,
we wanna know our Betas.
All we do all along is to just get good Betas.
All we want is good Betas.
So, again, it's important to
that there's strict exogeneity condition holds
that all the co-variants of all individuals
over all times is uncorrelated
with all of the error terms for all individuals.
Overall times, this is a strict exogeneity condition,
which if violated, we'll make for biased Betas.
Again, we need this strict exogeneity,
a very important assumption here.
So, now what we do with these three time periods
is we do two differencing.
So, first we take the equation of time two
and subtract it from time one and get these Delta.
What are the change in the Deltas,
or what are the change in our time that dummy variables
and most critically,
what are the changes in our Ys?
And what are our changes and Xs?
And this is what we are regressing.
So, to think back of our City Market example.
So, if we're looking at time two minus time one,
that's comparing the change from 2007 to 2012.
So, Delta X is the change in the Delta X one,
it's the change in income.
Delta X two is the change in household size
and Delta Y is the change in expenditure
in between these two years.
And then we have doing it for the second time period,
do the same sort of subtracting
for time three minus time two, which is 2017 and 2012.
So, here, we subtract the expenditure in 2017
minus expenditure in 2012
for every individual to get Delta Y.
And the same way we subtract
for each individual the income,
and in each of these years,
and the household size in each of these years
and save those variables as Delta.
So, we have new variables here.
As long as we do this,
if all those assumptions
that we've been working with so far,
and if we have this strict exogeneity ,
then we can use all the things
that we're most familiar with.
Our last T tests, F tests,
all the things that we've been working with so far,
all work and it all holds.
Note that there are a few things
that we need to deal with that there's no true intercept
in this model,
because Beta naught is a constant and it drops out.
It can also be a little bit problematic computing R squared.
So, this is again, the time when,
if you're going to be doing panel data in your thesis,
in your research, talk to your advisor,
talk to me, we'll walk you through it.
So, we can do this many ways for more than two times.
So, you simply include a dummy for each time period,
past your first one.
So, you're the very first time that you collect data.
That is your sort of omitted case that your baseline,
and for each other time,
you simply create a dummy for that time period.
That equal to one.
If the data were collected that year zero,
if not, ideally, we have what's called a balanced panel
where we have N observations
for everybody over T times.
It's also very important that we test for serial correlation
and for heteroscedasticity and doing it in that order
and this serial correlation test
we will learn about later on when we do times series.
There is a set of pitfalls with using this technique.
First, the strict exogeneity assumption
is, as I say, strict,
and it may or may not hold the two practical ones
is there's much less variation in the Xs
since you're just taking the difference.
And as we know, less variation in X leads
to a less efficient estimator,
as well as, so for every individual,
we lose one observation.
So, if we have two time periods,
we go from two and observations to an observations.
Again, less information,
and therefore a less efficient estimator.
So, those are the downfalls,
but these are the things that we do to get rid of the bias.
And this is a theme we're gonna talk about
through much of the rest of the semester,
the trade-off of bias and efficiency.
So, stay tuned.