- [Instructor] Good morning, everyone,
or at least it's morning here.
I hope you're doing well.
Welcome to week two of Panel Data.
As an overview,
this whole section on panel data last week and this week
is how do you deal with data
when you have multiple subjects over multiple years?
So both our N and our T are greater than one.
And last week, we did pooling,
and we started to get into fixed effects.
So now, we're gonna do another kind of fixed effects
as well as random effects.
Again, as an overview, we talked about pooling.
This is where you have different subjects each time,
where you are drawing a random sample each time,
but asking the same questions.
And we noted how we often include dummy variables
for things like years.
And if they're sort of a treatment and control,
like the difference-in-difference models,
we have a dummy variable for that, and we interact them.
And in this, we don't know how an individual's responses
might change over time
because the sample changes every time
we have a random sample.
So someone who's in the sample in period two
may not be in one or three, et cetera.
In the fixed effects model,
we are assuming that we are tracking
the same people over time.
And so we assume
that there is this ai sort of dummy variable
that doesn't change over time.
Again, that we interpret as what makes you you,
what makes me me, what makes Burlington Burlington.
And that it's highly correlated with the regressor,
so if we don't do something about it,
like last time, we subtracted it away,
it will cause bias in all of our estimators.
Last time, we learned about pooled data,
where since we're drawing a new sample each time,
we don't have to worry
about either the AI or auto-correlated errors.
And we also learned about
how you can difference one time period from another,
so take all of my Ys and my Xs,
and subtract my period two Y minus my period one Y.
So subtract my period one X2 and my...
Sorry.
Subtract my X1 from time two,
minus my X1 from time one, and et cetera.
That's what we did last time.
Now, we're gonna learn about two other things
that we can do, another transformation for fixed effects,
and then dealing with so-called random effects.
So first, let's take the fixed effects,
where, assume we only have one regressor,
and we have an equation that looks like this,
this Y equals it equals beta one X1t plus ai plus uit.
Here, we take the mean of every individual's observation
of Y and X.
So thinking back to the city market example,
taking my mean local food expenditure,
my mean income, and my mean household size,
and subtracting it from each of my observations
from each time.
So we take the Y bar i,
so the Y bar for each individual,
the X bar for each individual,
and the mean error term for each individual,
and subtract it from the observation.
So if you have two observations,
that is two times for each individual,
you subtract the time one observation
and subtract the mean of that person,
and take the time two observation
and subtract the mean of that person.
Same with the Xs.
With the k regressor, we do much the same thing.
We take each individual,
and take the mean of their Y, their X1, dot dot dot,
their Xk to get the yi bar, the x bars, and the u bars.
And we subtract each of these from the observation.
We take the observation of an individual on one time
and subtract the mean of all the observations
for that individual.
So we have these funky Y umlaut and that weird X thing
and the U umlaut
because I didn't really know how else to do it.
So this weird Y umlaut it
is what we actually use in the regression,
where we have the real observation Y
that they actually said in time t,
and subtract their mean observation of Y
over the observations.
Same for each value of X.
Take the observation of each X,
so that's k being regressor k, i, individual i, and time t,
and subtract the mean of each one of those.
And the same for the error term.
When we do that, the degrees of freedom
are NT minus N minus k.
And note that any predictor that is constant over time
is lost.
So a gender dummy variable,
if the person's gender doesn't change,
the elevation of a city, the area of a city,
their race, things like that that don't change,
we will lose all of that information.
Two big consideration with this kind of fixed effects model
is that we need homoscedasticity and no serial correlations.
You will need to do tests for homoscedasticity
and also for serial correlation,
which we'll learn about later.
And the degrees of freedom is NT minus N minus k.
So note that if this was pooled data,
the degrees of freedom is NT minus k.
But by time demeaning, we lose N degrees of freedom.
So I wanna say a little bit more about this variable ai.
So it can be estimated.
And really, as I said before,
a good way of thinking about it
is it's a dummy variable for every observation.
It is that which makes you you.
It's just I get my own dummy variable
that controls for who I am,
and you get one for you, et cetera.
Note that in a single time period,
so going back to cross section, you couldn't do this
because there would be N plus k variables
and only N observations.
So you could not solve this with econometrics.
There's more unknowns than equations.
And you'd have negative degrees of freedom.
You can actually compute this ai.
And the way that you would do it
is to take the mean of every individual's observation.
So take the yi bar, so, say, my observations,
the mean of them, over all the time periods
for my Y, my X1, and my Xk.
And then multiply them by their betas and subtract.
So you can see the formula here,
that ai is just yi bar minus beta one x1i bar,
minus dot dot dot, minus beta k Xki.
And that would yield sort of the intercept
or the dummy variable for each individual.
And we'll need that soon.
So thinking about...
We've looked at, first, differencing versus time demeaning,
which we'll call FD for differencings,
and this demeaning is more generally called fixed effects.
So what drives which model that you use?
So if T equals two, if you have only two times,
they are identical, and what we're gonna do in SPSS
is show that that is true.
If you have greater than three,
then you have a decision to make.
Both of them are unbiased and consistent
under the same assumptions,
as long as all the assumptions that we had before are true,
the classic linear regression assumptions
that we dealt with back in the beginning of class.
So as long as those are true, it's unbiased.
And in many ways,
it depends on the degree of serial correlation.
If there's none, if there is no serial correlation,
this implies demeaning is more efficient,
because you have one more observation.
And if you remember in first differencing
that you lose an observation every time that you subtract.
If you have three time periods,
since you're doing time three minus two
and time two minus one,
you go from three observations to two.
So as long as there is no serial correlation,
demeaning, this fixed effects model we learned this time,
is more efficient.
However, serial correlation,
much like heteroscedasticity,
causes a loss in efficiency.
And if it's large, if it's a significant issue,
then it's best to do the first differencing model
to eliminate this serial correlation,
and that would be the most efficient model.
In general, when T is large and N is small,
so you have a small number of observation N
and a large number of T,
it starts to look more like a time series model,
and so, at first, differencing is better.
And as I say in bold here,
and I've said this many times in many circumstances,
often the best approach is to do both, look at both,
report both, and discuss why and how they are not the same.
Sometimes you have unbalanced panels,
that is, you don't have observations
for every time period for every individual.
So for example, our fictitious city market example,
someone might have taken the survey in 2012, but moved away.
Someone might've moved in that wasn't here in 2012
and taken it in 2017.
So when you have all observations over all persons,
that's a balanced.
If you don't, it's unbalanced.
So it's important to ask,
why are some of the observations missing?
For two reasons.
One, certainly, any observation with only one time period
is lost under both of these techniques that we lose.
Under fixed effects, the mean of a one-time observation,
and it subtracts to zero.
And in first differencing,
there isn't anything to subtract, so you lose it all.
It's also important to think about why they dropped out.
And if there's a reason
that is correlated with the regressors
and with the error term,
then bias may occur.
So so far, we have looked at fixed effects,
where we assumed that our ai
was going to be highly correlated with our regressors,
and to omit it, to not do anything, results in bias.
Now, we're starting with the same model as before,
where we have N individual and T times,
and the Yit and everything is much the same as before.
But now, we're assuming that this ai is uncorrelated
with the error term, or rather, that this ai is uncorrelated
with any of the Xs at any time.
So even if we don't account for it
since it appears in the error term,
if it's not correlated with the regressors,
it doesn't matter.
There's no bias.
And by using one of the two techniques that we learned,
differencing or demeaning,
this fixed effects or first differencing models,
we lose information.
And therefore, it results in a less efficient estimator.
And as we'll see in a few minutes,
this is another time when we're really balancing
and doing a trade-off of bias versus efficiency.
So if we're using this random effects model,
it is essential that the ai and the Xits
are all uncorrelated,
that their covariance equal zero.
Now, why is this? There's two related reasons.
Really, it's two ways of saying the same thing.
First, that we have controlled
for quote, "everything," unquote, through the Xs,
that we did such an amazing job of choosing the Xs
that there isn't anything left
in the individual variability.
And that the ai is negligibly small.
And again, those are sort of two ways
of saying the same thing.
If this is true, pooled OLS, fixed effects,
and first differencing are all unbiased,
but they are not efficient.
And then, as a result,
we can use this random effects
to maybe add a little bit of bias
to gain a whole lot of efficiency.
The way we run this model,
we get an error term that includes both the ai,
the sort of dummy variable for each individual
that's not measurable, and the uit,
the regular kind of error term
that we've been dealing with all along,
the spin-the-bingo-ball error term.
Note that these errors, the vit,
that they will be very highly correlated across individuals
because they have ai in them each time.
And much like we dealt with heteroscedasticity
with a form of FGLS,
random effects is in itself a form of FGLS,
FGLS, F-G-L-S, feasible generalized least squares.
So we calculate a new factor called lambda.
And we define lambda, as you can see here in the slides,
the numerator...
So it's one minus this big thing.
And this big thing is raised to the 1/2 power,
so we take its square root.
And the thing in the square brackets in the numerator
is the variance of the regular error term.
In the denominator is the sum of the variance
of the regular error term u,
plus T, the number of time periods in the study,
times the variance of the a term, the ai term.
So we take all that,
and we make this new variable called lambda.
Lambda is always between zero and one.
And then we use the lambda to weigh the mean values
that we used in fixed effects.
So we weight them, these mean values.
So now, instead of subtracting out
the full value of the mean,
we subtract out part of the value of the mean.
And we call this quasi-demeaned data.
In the fixed effects model, we use demeaned,
so we subtracted the mean from each observation.
Now, we're subtracting part of the mean.
So this is what it looks like.
So we are multiplying each of our mean values
for each individual, each of these y bar, x bars,
by this factor lambda.
And basically, instead of in fixed effects,
where we subtract out the whole value
of the individual's mean, we're just doing a portion of it.
And it depends on the values of a, u,
and the number of time periods, T.
And here again is what lambda is equal to.
And you could see that it's a function of u, T, and a,
the variance of u, T time periods,
and the variance of a, this individual dummy term.
So you can use pooled OLS and fixed effect models
to calculate the as and the us,
take their variance, which you could do in SPSS,
and then use that to calculate
an estimate of sigma, sigma hat.
So we use sigma hat to get the estimate of this sigma...
Or this lambda hat. I'm sorry.
So we get this lambda hat using pooled and fixed effects.
And there is a full formula for this in the Wooldridge book.
And there's also a YouTube video here
that lets you see how it's done.
But I wanna dwell more
on conceptually what this all means.
So again, I think if you're going to use random effects,
this would be another case
where you would talk to your advisor, talk to me,
and we'll walk you through it.
Especially in SPSS, it takes a lot of math
and a lot of probably switching between Excel-
(crackling drowns out speaker)
I would advise you that if you're going to do this,
to see your advisor and me,
and I'm not going to expect you
to be able to do the actual calculations.
But I do wanna think about what it looks like conceptually.
So here's the formula again for lambda.
So if lambda equals one, it's the same as fixed effects.
We are subtracting the full value of the mean
from every person's observation.
If lambda equals zero, it's the same as pooled OLS.
We do not subtract anything from anybody's observation.
And what drives this?
So if a varies a lot, if sigma squared a is large,
it means that a is important,
a lends a lot of information to the model.
And in this case, when a is large,
sigma squared a is large, a as important
that lambda will approach one,
and it becomes more like fixed effects.
Hopefully, this makes intuitive sense,
that if a is important, it's going to cause bias,
and we want to remove it through the fixed effects model.
As T gets large, lambda also approaches one,
and it is also more like fixed effects.
But if a is not important,
if it does not lend a lot of information to the model,
then leaving it in really does not cause
a great deal of bias.
Our lambda approaches zero,
and it becomes more like a pooled OLS model.
So I would spend some time with this
and make sure that what I said makes sense.
Because really, it depends on the values of T
and of this sigma squared a.
And make sure that it makes sense of what I'm saying here.
So again, in random effects,
we weigh a by one minus lambda.
If lambda goes to one,
then the bias caused by putting the error term goes to zero,
and there's little error in random effects.
And we use a fixed effects model that...
And if lambda is zero,
a lot of our a stays in the error term.
It becomes more biased, and it's more like our pooled model.
As is always the case, or almost always the case,
do all three.
When it's pooled, all of a is in the error term.
When it's random effects, part of it is in the error term.
And of course, there is a test
which allows you to measure which one is better,
how much of the random effects or fixed effects
should we use.
Short way of saying it,
I'm going to call it the Hausman test.
It's also known as the Durbin-Wu-Hausman test.
And I don't know how Hausman
jumped to the top of the line here,
but for now, we're gonna call it the Hausman test.
You might also encounter it in other books
as the Durbin-Wu-Hausman test.
So recall that if the covariance...
Again, here is the formula for this Hausman test,
and this tests that W.
So if the null is true...
Our null is that the covariance of our a and our regressors
equals zero.
If this is true, the numerator will be very small.
There won't be a whole lot of bias
between the random effects, which we know
may have a little bit of bias or a lot of bias,
and the fixed effects, which we know has no bias.
So if the null is true, the denominator is small,
a very small bias.
If the null is true,
the denominator will see a big difference,
that the change in variance
from going to random effects to fixed effects
that you're putting in a lot more information
in the random effects,
it's going to make a smaller variance.
And if this number is large,
then the overall value of this W is small
if the null is true.
So just like every other test stat,
when we have a small test stat,
you tend to fail to reject the null.
You accept that the null is true.
When we have a very large test stat,
we will reject the null, just like every other test stat.
We reject the null
that the covariance of a and the regressors equal zero,
and we use fixed effects to take away the bias,
even at the cost of a loss of efficiency.
So that's the last slide.
I hope that this is going well for you,
and we can discuss it on Wednesday in class.
Have a great day, everyone.