[Instructor] Now I wanted to show you
how to do the Breusch-Pagan,
and the white tests for heteroscedasticity.
We're gonna test a model to see
if it is heteroscedastic or homoscedastic.
The first thing that we do is to run the regular model.
It's, again, using the sleep model,
and we're gonna regress sleep on total work, educ,
age, age squared, young kid, and male like we did before.
I'm gonna analyze, oh, I think I have to go back
and unsplit the file.
Okay, good.
This is what we want.
Do it to all groups.
We're gonna just do a linear regression
with sleep as our dependent.
And then our independents are total work,
educ,
age,
age squared,
and male.
And I just wanna make sure that those are the right ones,
total work, educ, age, age squared, and male.
Let's go back here and make sure that's right.
Total work, educ, age, age squared, oh, and young kid.
Don't forget about young kid.
It's there.
We put that over there.
Now, we've run this before, but what we wanna do now,
this is where we wanna save things.
We wanna save both of our, the Y hats and the U hats
because when we do the BP test,
it's on the squared residuals,
and when we do the white test,
it's on the Y hat and the Y hat squared.
Let's run this.
Say okay, boom.
And we see that we have over here two new variables.
This is Y hat and U hat.
I'm gonna go to variable view
and I'm gonna rename them so we remember what they are.
This is Y hat and this is U hat.
And we're gonna wanna then square them both.
We do that by going to transform, compute,
and we're gonna call it U hat squared
as our name, and it is simply...
no, that's wrong.
We actually want
U hat times U hat
so it's taking the U hats and squaring them.
And we should see now that there is a new variable
that is called U hat squared.
We're gonna do the same thing
and square the Y hats for the white test.
Now, we're gonna reset this and we're gonna go to,
we're gonna call it Y hat squared.
Make this a function of Y hat times Y hat
and say okay.
For the BP test, we regress U hat squared
on the regressors from the original model.
We analyze with a regression
and we just take out sleep now and we put in U hat squared.
Now what this is saying is
once we get the residuals and square them,
do these regressors still have an effect on that?
What we want is we want our null hypothesis to be true,
that these are all equal to zero
both individually and jointly.
If that is true, we have homoscedasticity
and that's a good thing and we don't have to deal with it.
If we cannot reject our null,
then we do have heteroscedasticity
and we need to deal with it
as we learned with to do inference
and to get a more efficient model.
Let's see what this says.
Boom.
We do see just barely these are significant.
It's kind of a borderline case.
It looks like it's not a very severe case.
And for things like weighted least squares
that we might wanna see, what is the culprit of that?
And the only one that is significant is educ.
Again, this is kind of a borderline case.
It's a significant, the .08, so it wouldn't be
at a P less than .05, but it is less than .1.
It might be good to sort of do it both ways,
compute the standard errors
or weighted least squares or FGLS.
And let's do the other test to see
if that gives us anything else.
Now, we're gonna do a linear regression
and instead of regressing it on the regressors,
we're gonna do it on Y hat squared,
on Y hat,
and Y hat squared.
Then let's turn off, it keeps saving 'em
because we didn't tell it not to.
And again, we want this to be not significant.
We want all our betas to be jointly zero.
And we look and we find that they are.
The whole thing is not significant.
And so again, these are, so again,
this is kind of a borderline case,
but that shows you how to do the the Breusch-Pagan test
and the second version of the white test
for heteroscedasticity.