2.4 — OLS: Goodness of Fit and Bias — Class Content

Tuesday, September 21, 2021

Problem Set 2 is due by the end of the day today.

Overview

Today we continue looking at basic OLS regression. We will cover how to measure if a regression line is a good fit (using R2 and σu or SER), and whether OLS estimators are biased. These will depend on four critical assumptions about u.

In doing so, we begin an ongoing exploration into inferential statistics, which will finally become clear in another week. The most confusing part is recognizing that there is a sampling distribution of each OLS estimator. We want to measure the center of that sampling distribution, to see if the estimator is biased. Next class we will measure the spread of that distribution.

We continue the extended example about class sizes and test scores, which comes from a (Stata) dataset from an old textbook that I used to use, Stock and Watson, 2007. Download and follow along with the data from today’s example:1

I have also made a RStudio Cloud project documenting all of the things we have been doing with this data that may help you when you start working with regressions (next class):

Readings

  • Ch. 3.2-3.4, 3.7-3.8 in Bailey, Real Econometrics

Slides

Below, you can find the slides in two formats. Clicking the image will bring you to the html version of the slides in a new tab. Note while in going through the slides, you can type h to see a special list of viewing options, and type o for an outline view of all the slides.

The lower button will allow you to download a PDF version of the slides. I suggest printing the slides beforehand and using them to take additional notes in class (not everything is in the slides)!

2.4-slides

Download as PDF

Assignments

Problem Set 2

Problem Set 2 is due by Tuesday September 21. Please see the instructions for more information on how to submit your assignment (there are multiple ways!).

Math Appendix

Deriving the OLS Estimators

The population linear regression model is:

Yi=β0+β1Xi+ui

The errors (ui) are unobserved, but for candidate values of β0^ and β1^, we can obtain an estimate of the residual. Algebraically, the error is:

ui^=Yiβ0^β1^Xi

Recall our goal is to find β0^ and β1^ that minimizes the sum of squared errors (SSE):

SSE=i=1nui^2

So our minimization problem is:

minβ0^,β1^i=1n(Yiβ0^β1^Xi)2

Using calculus, we take the partial derivatives and set it equal to 0 to find a minimum. The first order conditions are:

SSEβ0^=2i=1n(Yiβ0^β1^Xi)=0SSEβ1^=2i=1n(Yiβ0^β1^Xi)Xi=0

Finding β0^

Working with the first FOC, divide both sides by 2:

i=1n(Yiβ0^β1^Xi)=0

Then expand the summation across all terms and divide by n:

1ni=1nYiY¯1ni=1nβ0^β0^1ni=1nβ1^Xiβ1^X¯=0

Note the first term is Y¯, the second is β0^, the third is β1^X¯.2

So we can rewrite as: Y¯β0^β1=0

Rearranging:

β0^=Y¯X¯β1

Finding β1^

To find β1^, take the second FOC and divide by 2:

i=1n(Yiβ0^β1^Xi)Xi=0

From the formula for β0^, substitute in for β0^:

i=1n(Yi[Y¯β1^X¯]β1^Xi)Xi=0

Combining similar terms:

i=1n([YiY¯][XiX¯]β1^)Xi=0

Distribute Xi and expand terms into the subtraction of two sums (and pull out β1^ as a constant in the second sum:

i=1n[YiY¯]Xiβ1^i=1n[XiX¯]Xi=0

Move the second term to the righthand side:

i=1n[YiY¯]Xi=β1^i=1n[XiX¯]Xi

Divide to keep just β1^ on the right:

i=1n[YiY¯]Xii=1n[XiX¯]Xi=β1^

Note that from the rules about summation operators:

i=1n[YiY¯]Xi=i=1n(YiY¯)(XiX¯)

and:

i=1n[XiX¯]Xi=i=1n(XiX¯)(XiX¯)=i=1n(XiX¯)2

Plug in these two facts:

i=1n(YiY¯)(XiX¯)i=1n(XiX¯)2=β1^

Algebraic Properties of OLS Estimators

The OLS residuals u^ and predicted values Y^ are chosen by the minimization problem to satisfy:

  1. The expected value (average) error is 0: E(ui)=1ni=1nui^=0

  2. The covariance between X and the errors is 0: σ^X,u=0

Note the first two properties imply strict exogeneity. That is, this is only a valid model if X and u are not correlated.

  1. The expected predicted value of Y is equal to the expected value of Y: Y^¯=1ni=1nYi^=Y¯

  2. Total sum of squares is equal to the explained sum of squares plus sum of squared errors: TSS=ESS+SSEi=1n(YiY¯)2=i=1n(Yi^Y¯)2+i=1nu2

Recall R2 is ESSTSS or 1SSE

  1. The regression line passes through the point (X¯,Y¯), i.e. the mean of X and the mean of Y.

Bias in β1^

Begin with the formula we derived for β1^:

β1^=i=1n(YiY¯)(XiX¯)i=1n(XiX¯)2

Recall from Rule 6 of summations, we can rewrite the numerator as

=i=1n(YiY¯)(XiX¯)=i=1nYi(XiX¯)

β1^=i=1nYi(XiX¯)i=1n(XiX¯)2

We know the true population relationship is expressed as:

Yi=β0+β1Xi+ui

Substituting this in for Yi in equation 2:

β1^=i=1n(β0+β1Xi+ui)(XiX¯)i=1n(XiX¯)2 Breaking apart the sums in the numerator:

β1^=i=1nβ0(XiX¯)+i=1nβ1Xi(XiX¯)+i=1nui(XiX¯)i=1n(XiX¯)2

We can simplify equation 4 using Rules 4 and 5 of summations

  1. The first term in the numerator [i=1nβ0(XiX¯)] has the constant β0, which can be pulled out of the summation. This gives us the summation of deviations, which add up to 0 as per Rule 4:

i=1nβ0(XiX¯)=β0i=1n(XiX¯)=β0(0)=0

  1. The second term in the numerator [i=1nβ1Xi(XiX¯)] has the constant β1, which can be pulled out of the summation. Additionally, Rule 5 tells us i=1nXi(XiX¯)=i=1n(XiX¯)2:

i=1nβ1X1(XiX¯)=β1i=1nXi(XiX¯)=β1i=1n(XiX¯)2

When placed back in the context of being the numerator of a fraction, we can see this term simplifies to just β1:

β1i=1n(XiX¯)2i=1n(XiX¯)2=β11×i=1n(XiX¯)2i=1n(XiX¯)2=β1

Thus, we are left with:

β1^=β1+i=1nui(XiX¯)i=1n(XiX¯)2

Now, take the expectation of both sides:

E[β1^]=E[β1+i=1nui(XiX¯)i=1n(XiX¯)2]

We can break this up, using properties of expectations. First, recall E[a+b]=E[a]+E[b], so we can break apart the two terms.

E[β1^]=E[β1]+E[i=1nui(XiX¯)i=1n(XiX¯)2]

Second, the true population value of β1 is a constant, so E[β1]=β1.

Third, since we assume X is also “fixed” and not random, the variance of X, i=1n(XiX¯), in the denominator, is just a constant, and can be brought outside the expectation.

E[β1^]=β1+E[i=1nui(XiX¯)]i=1n(XiX¯)2

Thus, the properties of the equation are primarily driven by the expectation E[i=1nui(XiX¯)]. We now turn to this term.

Use the property of summation operators to expand the numerator term:

β1^=β1+i=1nui(XiX¯)i=1n(XiX¯)2β1^=β1+i=1n(uiu¯)(XiX¯)i=1n(XiX¯)2

Now divide the numerator and denominator of the second term by 1n. Realize this gives us the covariance between X and u in the numerator and variance of X in the denominator, based on their respective definitions.

β1^=β1+1ni=1n(uiu¯)(XiX¯)1ni=1n(XiX¯)2β1^=β1+cov(X,u)var(X)β1^=β1+sX,usX2

By the Zero Conditional Mean assumption of OLS, sX,u=0.

Alternatively, we can express the bias in terms of correlation instead of covariance:

E[β1^]=β1+cov(X,u)var(X)

From the definition of correlation:

cor(X,u)=cov(X,u)sXsucor(X,u)sXsu=cov(X,u)

Plugging this in:

E[β1^]=β1+cov(X,u)var(X)E[β1^]=β1+[cor(X,u)sxsu]sX2E[β1^]=β1+cor(X,u)susXE[β1^]=β1+cor(X,u)susX

Proof of the Unbiasedness of β1^

Begin with equation:3

β1^=YiXiXi2

Substitute for Yi:

β1^=(β1Xi+ui)XiXi2

Distribute Xi in the numerator:

β1^=β1Xi2+uiXiXi2

Separate the sum into additive pieces:

β1^=β1Xi2Xi2+uiXiXi2

β1 is constant, so we can pull it out of the first sum:

β1^=β1Xi2Xi2+uiXiXi2

Simplifying the first term, we are left with:

β1^=β1+uiXiXi2

Now if we take expectations of both sides:

E[β1^]=E[β1]+E[uiXiXi2]

β1 is a constant, so the expectation of β1 is itself.

E[β1^]=β1+E[uiXiXi2]

Using the properties of expectations, we can pull out 1Xi2 as a constant:

E[β1^]=β1+1Xi2E[uiXi]

Again using the properties of expectations, we can put the expectation inside the summation operator (the expectation of a sum is the sum of expectations):

E[β1^]=β1+1Xi2E[uiXi]

Under the exogeneity condition, the correlation between Xi and ui is 0.

E[β1^]=β1


  1. Note this is a .dta Stata file. You will need to (install and) load the package haven to read_dta() Stata files into a dataframe.↩︎

  2. From the rules about summation operators, we define the mean of a random variable X as X¯=1ni=1nXi. The mean of a constant, like β0 or β1 is itself.↩︎

  3. Admittedly, this is a simplified version where β0^=0, but there is no loss of generality in the results.↩︎

Previous
Next