Linear Regression with One Regressor p p p

  • Slides: 62
Download presentation
Linear Regression with One Regressor

Linear Regression with One Regressor

p p p Introduction Linear Regression Model Measures of Fit Least Squares Assumptions Sampling

p p p Introduction Linear Regression Model Measures of Fit Least Squares Assumptions Sampling Distribution of OLS Estimator

Introduction Empirical problem: Class size and educational output. p Policy question: What is the

Introduction Empirical problem: Class size and educational output. p Policy question: What is the effect of reducing class size by one student per class? by 8 students/class? p What is the right output (performance) measure? n parent satisfaction. n student personal development. n future adult welfare. n future adult earnings. n performance on standardized tests.

What do data say about class sizes and test scores? The California Test Score

What do data say about class sizes and test scores? The California Test Score Data Set All K-6 and K-8 California school districts (n = 420) Variables: p 5 th grade test scores (Stanford-9 achievement test, combined math and reading), district average. p Student-teacher ratio (STR) = number of students in the district divided by number of full-time equivalent teachers.

An initial look at the California test score data:

An initial look at the California test score data:

Question: Do districts with smaller classes (lower STR) have higher test scores? And by

Question: Do districts with smaller classes (lower STR) have higher test scores? And by how much?

The class size/test score policy question: p What is the effect of reducing STR

The class size/test score policy question: p What is the effect of reducing STR by one student/teacher on test scores ? p Object of policy interest: . p This is the slope of the line relating test score and STR.

This suggests that we want to draw a line through the Test Score v.

This suggests that we want to draw a line through the Test Score v. s. STR scatterplot, but how?

Linear Regression: Some Notation and Terminology The population regression line is

Linear Regression: Some Notation and Terminology The population regression line is

p p p β 0 and β 1 are “population” parameters? We would like

p p p β 0 and β 1 are “population” parameters? We would like to know the population value of β 1 We don’t know β 1, so we must estimate it using data.

The Population Linear Regression Model— general notation p p X is the independent variable

The Population Linear Regression Model— general notation p p X is the independent variable or regressor. Y is the dependent variable. β 0 = intercept. β 1 = slope.

p ui = the regression error. p The regression error consists of omitted factors,

p ui = the regression error. p The regression error consists of omitted factors, or possibly measurement error in the measurement of Y. In general, these omitted factors are other factors that influence Y , other than the variable X.

Ex : The population regression line and the error term

Ex : The population regression line and the error term

Data and sampling The population objects (“parameters”) 0 and 1 are unknown; so to

Data and sampling The population objects (“parameters”) 0 and 1 are unknown; so to draw inferences about these unknown parameters we must collect relevant data. Simple random sampling: Choose n entities at random from the population of interest, and observe (record) X and Y for each entity Simple random sampling implies that {(Xi, Yi)}, i = 1, …, n, are independently and identically distributed (i. i. d. ). (Note: (Xi, Yi) are distributed independently of (Xj, Yj) for different observations i and j. )

The Ordinary Least Squares Estimator How can we estimate β 0 and β 1

The Ordinary Least Squares Estimator How can we estimate β 0 and β 1 from data? We will focus on the least squares (“ordinary least squares” or ”OLS”) estimator of the unknown parameters β 0 and β 1, which solves

The OLS estimator solves: p p p The OLS estimator minimizes the sum of

The OLS estimator solves: p p p The OLS estimator minimizes the sum of squared difference between the actual values of Yi and the prediction (predicted value) based on the estimated line. This minimization problem can be solved. The result is the OLS estimators of β 0 and β 1.

Why use OLS, rather than some other estimator? p p The OLS estimator has

Why use OLS, rather than some other estimator? p p The OLS estimator has some desirable properties: under certain assumptions, it is unbiased (that is, E(β 1 )=β 1), and it has a tighter sampling distribution than some other candidate estimators of β 1. This is what everyone uses— the common “language” of linear regression.

Why use OLS, rather than some other estimator? p p p OLS is a

Why use OLS, rather than some other estimator? p p p OLS is a generalization of the sample average: if the “line” is just an intercept (no X), then the OLS estimator is just the sample average of Y 1, …Yn ( ). Like , the OLS estimator has some desirable properties: under certain assumptions, it is unbiased (that is, E( ) = 1), and it has a tighter sampling distribution than some other candidate estimators of 1 (more on this later) Importantly, this is what everyone uses – the common “language” of linear regression.

Derivation of the OLS Estimators and are the values of b 0 and b

Derivation of the OLS Estimators and are the values of b 0 and b 1 the above two normal equations.

From equations (1) and (2), and divide each term by n, we have From

From equations (1) and (2), and divide each term by n, we have From (3), , substitute in (4) and collect terms, we have

Application to the California Test Score. Class Size data p p p Estimated slope

Application to the California Test Score. Class Size data p p p Estimated slope = = - 2. 28 Estimated intercept = = 698. 9 Estimated regression line: = 698. 9 - 2. 28 ST R

Interpretation of the estimated slope and intercept p p Districts with one more student

Interpretation of the estimated slope and intercept p p Districts with one more student per teacher on average have test scores that are 2. 28 points lower. That is, =-2. 28. The intercept (taken literally) means that, according to this estimated line, districts with zero students per teacher would have a (predicted) test score of 698. 9. This interpretation of the intercept makes no sense – it extrapolates the line outside the range of the data – in this application, the intercept is not itself economically meaningful.

Predicted values and residuals: One of the districts in the data set is Antelope,

Predicted values and residuals: One of the districts in the data set is Antelope, CA, for which ST R = 19. 33 and Score = 657. 8

Measures of Fit A natural question is how well the regression line “fits” or

Measures of Fit A natural question is how well the regression line “fits” or explains the data. There are two regression statistics that provide complementary measures of the quality of fit: p The regression R 2 measures the fraction of the variance of Y that is explained by X; it is unitless and ranges between zero (no fit) and one (perfect fit). p The standard error of the regression (SER) measures the magnitude of a typical regression residual in the units of Y.

The R 2: The regression R 2 is the fraction of the sample variance

The R 2: The regression R 2 is the fraction of the sample variance of Yi “explained” by the regression. from equations (1) and (2).

Definition of R 2: p p R 2 = 0 means ESS = 0.

Definition of R 2: p p R 2 = 0 means ESS = 0. R 2 = 1 means ESS = T SS. 0 ≤ R 2 ≤ 1. For regression with a single X, R 2 = the square of the correlation coefficient between X and Y. (Exercise 4. 12)

The Standard Error of the Regression (SER) The SER measures the spread of the

The Standard Error of the Regression (SER) The SER measures the spread of the distribution of u. The SER is (almost) the sample standard deviation of the OLS residuals: The second equality holds bacause

The SER: p has the units of u, which are the units of Y.

The SER: p has the units of u, which are the units of Y. p measures the average “size” of the OLS residual (the average “mistake” made by the OLS regression line) p The root mean squared error (RMSE) is closely related to the SER: p This measures the same thing as the SER—the minor difference is division by 1/n instead of 1/(n-2).

Technical note: why divide by n-2 instead of n-1? p p p Division by

Technical note: why divide by n-2 instead of n-1? p p p Division by n-2 is a “degrees of freedom” correction— just like division by n-1 in , except that for the SER, two parameters have been estimated (β 0 and β 1, by and ), whereas in only one has been estimated ( , by ). When n is large, it makes negligible difference whether n, n-1, or n-2 are used— although the conventional formula uses n-2 when there is a single regressor. For details, see Section 17. 4.

Example of the R 2 and the SER R 2 = 0. 05, SER=18.

Example of the R 2 and the SER R 2 = 0. 05, SER=18. 6 STR explains only a small fraction of the variation in test scores. Does this make sense? Does this mean the ST R is unimportant in a policy sense? No.

The Least Squares Assumptions p p p What, in a precise sense, are the

The Least Squares Assumptions p p p What, in a precise sense, are the properties of the OLS estimator? We would like it to be unbiased, and to have a small variance. Does it? Under what conditions is it an unbiased estimator of the true population parameters? To answer these questions, we need to make some assumptions about how Y and X are related to each other, and about how they are collected (the sampling scheme). These assumptions— there are three—are known as the Least Squares Assumptions.

The Least Squares Assumptions The conditional distribution of u given X has mean zero,

The Least Squares Assumptions The conditional distribution of u given X has mean zero, that is, . This implies that is unbiased. p (Xi , Yi) , i= 1, … , n, are i. i. d. n This is true if X, Y are collected by simple random sampling. n This delivers the sampling distribution of and . p Large outliers in X and/or Y are rare. n Technically, X and u have four moments, that is: E(X 4)<∞ and E(u 4)<∞. n Outliers can result in meaningless values of . p

Least squares assumption #1: E(u|X=x)= 0. For any given value of X, the mean

Least squares assumption #1: E(u|X=x)= 0. For any given value of X, the mean of u is zero.

Example: Assumption #1 and the class size example. “Other factors” include p parental involvement

Example: Assumption #1 and the class size example. “Other factors” include p parental involvement p outside learning opportunities (extra math class, . . ) p home environment p family income is a useful proxy for many such factors So, E(u|X=x)0 means E(Family Income|STR) = constant (which implies that family income and STR are uncorrelated).

Least squares assumption #2: (Xi , Yi) , i= 1, … , n, are

Least squares assumption #2: (Xi , Yi) , i= 1, … , n, are i. i. d. This arises automatically if the entity (individual, district) is sampled by simple random sampling. The entity is selected then, for that entity, X and Y are observed (recorded). The main place we will encounter non-i. i. d. sampling is when data are recorded over time (“time series data”) – this will introduce some extra complications.

Least squares assumption #3: Large outliers are rare. Technical statement: E(X 4)<∞ and E(u

Least squares assumption #3: Large outliers are rare. Technical statement: E(X 4)<∞ and E(u 4)<∞. p A large outlier is an extreme value of X or Y. p On a technical level, if X and Y are bounded, then they have finite fourth moments. (Standardized test scores automatically satisfy this; STR, family income, etc. satisfy this too). p However, the substance of this assumption is that a large outlier can strongly influence the results.

OLS can be sensitive to an outlier p p Is the lone point an

OLS can be sensitive to an outlier p p Is the lone point an outlier in X or Y ? In practice, outliers often are data glitches (coding/recording problems)— so check your data for outliers! The easiest way is to produce a scatterplot.

Sampling Distribution of OLS Estimator The OLS estimator is computed from a sample of

Sampling Distribution of OLS Estimator The OLS estimator is computed from a sample of data; a different sample gives a different value of . This is the source of the “sampling uncertainty” of . We want to: p quantify the sampling uncertainty associated with . p use to test hypotheses such as β 1 = 0. p construct a confidence interval for β 1.

All these require figuring out the sampling distribution of the OLS estimator. Two steps

All these require figuring out the sampling distribution of the OLS estimator. Two steps to get there. p Probability framework for linear regression. p Distribution of the OLS estimator.

Probability Framework for Linear Regression The Probability framework for linear regression is summarized by

Probability Framework for Linear Regression The Probability framework for linear regression is summarized by the three least squares assumption. p Population population of interest (ex: all possible school districts) p Random variables: Y, X (ex: Test Score, STR) p Joint distribution of (Y, X) The population regression function is linear. E(u|X) = 0 X, Y have finite fourth moments. p Data collection by simple randomsampling {(Xi , Yi)} , i= 1, … , n are i. i. d.

The Sampling Distribution of Like , has a sampling distribution. p What is E(

The Sampling Distribution of Like , has a sampling distribution. p What is E( )? (where is it centered? ) p What is Var( )? (measure of sampling uncertainty) p What is its sampling distribution in small samples? p What is its sampling distribution in large samples?

The mean and variance of the sampling distribution of Thus because

The mean and variance of the sampling distribution of Thus because

 is unbiased. Law of Iterated Expectations: E(Y) = E(E(Y|X)).

is unbiased. Law of Iterated Expectations: E(Y) = E(E(Y|X)).

so – 1 = We can simplify this formula by noting that: = =

so – 1 = We can simplify this formula by noting that: = = -

Thus

Thus

Calculate the mean of E( – 1) = = = Now E(vi/ ) =

Calculate the mean of E( – 1) = = = Now E(vi/ ) = E[(Xi – )ui/ ] = 0 because E(ui|Xi=x) = 0 Thus, E( – 1) = = 0 so E( ) = 1 p That is, is an unbiased estimator of 1.

Because when n is large p is i. i. d. and has two moments.

Because when n is large p is i. i. d. and has two moments. That is Var( ) < ∞. Thus is distributed when n is large. (central limit theorem) p is approximately equal to when n is large. p when n is large. Putting these together we have:

Large-n approximation to the distribution of : which is approximately distributed Because , we

Large-n approximation to the distribution of : which is approximately distributed Because , we can write this as: is approximately distributed

The larger the variance of X, the smaller the variance of The math: where

The larger the variance of X, the smaller the variance of The math: where . The variance of X appears in its square in the denominator—so increasing the spread of X decreases the variance of β 1. The intuition If there is more variation in X, then there is more information in the data that you can use to fit the regression line. This is most easily seen in a figure.

The larger the variance of X, the smaller the variance of There are the

The larger the variance of X, the smaller the variance of There are the same number of black and blue dots— using which would you get a more accurate regression line?

Asymptotic Distribution Theory Consistency and convergence in probability. p Let S 1, S 2,

Asymptotic Distribution Theory Consistency and convergence in probability. p Let S 1, S 2, … , Sn, … be a sequence of random variable. The sequency of random variables {Sn} is said to converge in probability to a limit, μ (that is ), if the probability that Sn is within ±δ of μ tends to one as n→∞, as long as the constant δ is positive. That is if and only if Pr [|Sn − μ|≥δ] → 0 as n→∞ for every δ > 0. If , then Sn is said to be a consistent estimator of μ. p

p Law of Large Number: Under certain conditions on Y 1, … , Yn,

p Law of Large Number: Under certain conditions on Y 1, … , Yn, the sample average converges in probability to the population mean. If Y 1, … , Yn are i. i. d. , , and , then

Another apporach to obtain an estimator: Apply Law of Large Number The least square

Another apporach to obtain an estimator: Apply Law of Large Number The least square assumption #1 implies Apply LLN we have

Replacing the population mean with sample average is called the analogy principle. This leads

Replacing the population mean with sample average is called the analogy principle. This leads to the two normal equations in the bivariate least squares regression.

p Convergence in distribution. Let F 1, … , Fn, … be a sequence

p Convergence in distribution. Let F 1, … , Fn, … be a sequence of cumulative distribution functions corresponding to a sequence of random variables, S 1, … , Sn, …. Then the sequence of random variables Sn is said to converge in distribution to S ( denoted ) if the distribution functions {Fn} converge to F. That is, where the limit holds at all points t at which the limiting distribution F is continuous. The distribution F is called the asymptotic distribution of Sn.

p The central limit theorem. If Y 1, … , Yn are i. i.

p The central limit theorem. If Y 1, … , Yn are i. i. d. and then In other words, the asymptotic distribution of is N(0, 1).

Slutsky’s theorem combines consistency and convergence in distribution. Suppose that an where a is

Slutsky’s theorem combines consistency and convergence in distribution. Suppose that an where a is a constant, and Then

p Continuous mapping theorem: If g is a continuous function, then n n

p Continuous mapping theorem: If g is a continuous function, then n n

Summary for the OLS estimator : Under the three Least Squares Assumptions, p The

Summary for the OLS estimator : Under the three Least Squares Assumptions, p The exact (finite sample) sampling distribution of has mean ( is an unbiased estmator of ), and Var( ) is inversely proportional to n. p Other than its mean and variance, the exact distribution of is complicated and depends on the distribution of (X, u). p . (law of large numbers) p is approximately distributed N(0, 1). (CLT)