Linear Regression Spring 2014

Similar documents
Linear regression Class 25, Jeremy Orloff and Jonathan Bloom

Bootstrapping Spring 2014

Regression Models - Introduction

Post-exam 2 practice questions 18.05, Spring 2014

Regression and correlation. Correlation & Regression, I. Regression & correlation. Regression vs. correlation. Involve bivariate, paired data, X & Y

2 Regression Analysis

STAT 111 Recitation 7

Quantitative Analysis of Financial Markets. Summary of Part II. Key Concepts & Formulas. Christopher Ting. November 11, 2017

Regression, Ridge Regression, Lasso

Common Core Algebra 2 Review Session 1

Lecture 15. Hypothesis testing in the linear model

Class 8 Review Problems solutions, 18.05, Spring 2014

7.0 Lesson Plan. Regression. Residuals

Business Statistics. Lecture 9: Simple Regression

Regression. ECO 312 Fall 2013 Chris Sims. January 12, 2014

Interpolation and Polynomial Approximation I

Predicted Y Scores. The symbol stands for a predicted Y score

Regression Models - Introduction

Confidence Intervals for Normal Data Spring 2014

Correlation and Regression Theory 1) Multivariate Statistics

Regression Analysis. Regression: Methodology for studying the relationship among two or more variables

INTRODUCING LINEAR REGRESSION MODELS Response or Dependent variable y

The Double Sum as an Iterated Integral

Correlation 1. December 4, HMS, 2017, v1.1

Analysis of Bivariate Data

Applied Regression Modeling: A Business Approach Chapter 3: Multiple Linear Regression Sections

Recitation 1: Regression Review. Christina Patterson

Lecture 19 Multiple (Linear) Regression

Linear Regression. In this problem sheet, we consider the problem of linear regression with p predictors and one intercept,

Multiple Linear Regression

MIT Spring 2015

Continuous Expectation and Variance, the Law of Large Numbers, and the Central Limit Theorem Spring 2014

STAT 361 Fall Homework 1: Solution. It is customary to use a special sign Σ as an abbreviation for the sum of real numbers

Covariance and Correlation Class 7, Jeremy Orloff and Jonathan Bloom

5.3. Polynomials and Polynomial Functions

Nonlinear Regression Section 3 Quadratic Modeling

Lecture 14 Simple Linear Regression

Simple Linear Regression. (Chs 12.1, 12.2, 12.4, 12.5)

Regression. Marc H. Mehlman University of New Haven

Correlation and Regression

Regression Analysis: Basic Concepts

Conjugate Priors: Beta and Normal Spring January 1, /15

A matrix times a column vector is the linear combination of the columns of the matrix weighted by the entries in the column vector.

LINEAR REGRESSION ANALYSIS. MODULE XVI Lecture Exercises

Simple Linear Regression

MIT Spring 2016

Midterm 2 - Solutions

Comparison of Bayesian and Frequentist Inference

ECON3150/4150 Spring 2015

9. Linear Regression and Correlation

UNIT 12 ~ More About Regression

Regression. Bret Hanlon and Bret Larget. December 8 15, Department of Statistics University of Wisconsin Madison.

INFERENCE FOR REGRESSION

Taylor Series and Numerical Approximations

Day 4: Shrinkage Estimators

AMS 315/576 Lecture Notes. Chapter 11. Simple Linear Regression

Chapter 7. Scatterplots, Association, and Correlation

Chapter 7 Linear Regression

Inverse of a Square Matrix. For an N N square matrix A, the inverse of A, 1

Bootstrap and Linear Regression Spring You should have downloaded studio12.zip and unzipped it into your working directory.

Simple Linear Regression. Material from Devore s book (Ed 8), and Cengagebrain.com

Simple Linear Regression Analysis

Nature vs. nurture? Lecture 18 - Regression: Inference, Outliers, and Intervals. Regression Output. Conditions for inference.

14.6 Spring Force Energy Diagram

MAT2377. Rafa l Kulik. Version 2015/November/26. Rafa l Kulik

Bayesian Updating: Discrete Priors: Spring 2014

Simple Linear Regression

Oct Simple linear regression. Minimum mean square error prediction. Univariate. regression. Calculating intercept and slope

Correlation and Linear Regression

Linear regression COMS 4771

Chapter Goals. To understand the methods for displaying and describing relationship among variables. Formulate Theories.

Regression. Estimation of the linear function (straight line) describing the linear component of the joint relationship between two variables X and Y.

bivariate correlation bivariate regression multiple regression

STAT FINAL EXAM

Scatter plot of data from the study. Linear Regression

Computational Physics

Simple Linear Regression

Simple Linear Regression

ECON The Simple Regression Model

Estadística II Chapter 5. Regression analysis (second part)

Describing Bivariate Relationships

Class 8 Review Problems 18.05, Spring 2014

ES-2 Lecture: More Least-squares Fitting. Spring 2017

2.830J / 6.780J / ESD.63J Control of Manufacturing Processes (SMA 6303) Spring 2008

Regression and Nonlinear Axes

Mathematics for Economics MA course

Math 423/533: The Main Theoretical Topics

Lecture 6. Regression

Linear Models Review

Lecture 3: Linear Models. Bruce Walsh lecture notes Uppsala EQG course version 28 Jan 2012

Lecture 26. Quadratic Equations

Applied Regression Modeling: A Business Approach Chapter 2: Simple Linear Regression Sections

Key Algebraic Results in Linear Regression

4.1 Least Squares Prediction 4.2 Measuring Goodness-of-Fit. 4.3 Modeling Issues. 4.4 Log-Linear Models

Statistics II Exercises Chapter 5

Lecture 18: Simple Linear Regression

Lecture 2 Simple Linear Regression STAT 512 Spring 2011 Background Reading KNNL: Chapter 1

Confidence Intervals for the Mean of Non-normal Data Class 23, Jeremy Orloff and Jonathan Bloom

Scatter plot of data from the study. Linear Regression

Correlation & Simple Regression

Transcription:

Linear Regression 18.05 Spring 2014

Agenda Fitting curves to bivariate data Measuring the goodness of fit The fit vs. complexity tradeoff Regression to the mean Multiple linear regression January 1, 2017 2 / 20

Modeling bivariate data as a function + noise Ingredients Bivariate data (x 1, y 1 ), (x 2, y 2 ),..., (x n, y n ). Model: y i = f (x i ) + E i where f (x) is some function, E i random error. n Total squared error: Ei 2 = n (y i=1 i=1 i f (x i )) Model allows us to predict the value of y for any given value of x. x is called the independent or predictor variable. y is the dependent or response variable. 2 January 1, 2017 3 / 20

Examples of f (x) lines: polynomials: other: other: y = ax + b + E y = ax 2 + bx + c + E y = a/x + b + E y = a sin(x) + b + E January 1, 2017 4 / 20

Simple linear regression: finding the best fitting line Bivariate data (x 1, y 1 ),..., (x n, y n ). Simple linear regression: fit a line to the data y i = ax i + b + E i, where E i N(0, σ 2 ) and where σ is a fixed value, the same for all data points. n Total squared error: E 2 i=1 i = n (yi i=1 ax i b) 2 Goal: Find the values of a and b that give the best fitting line. Best fit: (least squares) The values of a and b that minimize the total squared error. January 1, 2017 5 / 20

Linear Regression: finding the best fitting polynomial Bivariate data: (x 1, y 1 ),..., (x n, y n ). Linear regression: fit a parabola to the data y i = ax 2 i + bx i + c + E i, where E i N(0, σ 2 ) and where σ is a fixed value, the same for all data points. n Total squared error: Ei 2 = (y i axi 2 bx i c) 2. n i=1 i=1 Goal: Find the values of a, b, c that give the best fitting parabola. Best fit: (least squares) The values of a, b, c that minimize the total squared error. Can also fit higher order polynomials. January 1, 2017 6 / 20

Stamps 50 40 30 y 20 10 0 10 20 30 40 50 60 x Stamp cost (cents) vs. time (years since 1960) (Red dot = 49 cents is predicted cost in 2016.) (Actual cost of a stamp dropped from 49 to 47 cents on 4/8/16.) January 1, 2017 7 / 20

Parabolic fit 0 5 y 10 15 1 0 1 2 3 4 5 6 x January 1, 2017 8 / 20

Board question: make it fit Bivariate data: (1, 3), (2, 1), (4, 4) 1. Do (simple) linear regression to find the best fitting line. Hint: minimize the total squared error by taking partial derivatives with respect to a and b. 2. Do linear regression to find the best fitting parabola. 3. Set up the linear regression to find the best fitting cubic. but don t take derivatives. 4. Find the best fitting exponential y = e ax+b. Hint: take ln(y) and do simple linear regression. January 1, 2017 9 / 20

What is linear about linear regression? Linear in the parameters a, b,.... y = ax + b. y = ax 2 + bx + c. It is not because the curve being fit has to be a straight line although this is the simplest and most common case. Notice: in the board question you had to solve a system of simultaneous linear equations. Fitting a line is called simple linear regression. January 1, 2017 10 / 20

Homoscedastic BIG ASSUMPTIONS: the E i are independent with the same variance σ 2. y 0 5 10 15 20 e 3 2 1 0 1 2 3 4 0 2 4 6 8 10 x 0 2 4 6 8 10 x Regression line (left) and residuals (right). Homoscedasticity = uniform spread of errors around regression line. January 1, 2017 11 / 20

Heteroscedastic 20 15 y 10 5 0 0 2 4 6 8 10 x Heteroscedastic Data January 1, 2017 12 / 20

Formulas for simple linear regression Model: Using calculus or algebra: where y i = ax i + b + E i where E i N(0, σ 2 ). s xy â = and bˆ = ȳ â x, s xx 1 x = xi s xx = 1 ( xi x ) 2 n n 1 1 ȳ = yi s xy = 1 (x i x )( y i ȳ). n n 1 WARNING: This is just for simple linear regression. For polynomials and other functions you need other formulas. January 1, 2017 13 / 20

Board Question: using the formulas plus some theory Bivariate data: (1, 3), (2, 1), (4, 4) 1.(a) Calculate the sample means for x and y. 1.(b) Use the formulas to find a best-fit line in the xy-plane. s xy â = ˆb = y âx sxx 1 1 s xy = (xi x)(y i y) s xx = ( xi x) 2. n 1 n 1 2. Show the point (x, y) is always on the fitted line. 3. Under the assumption E i N(0, σ 2 ) show that the least squares method is equivalent to finding the MLE for the parameters (a, b). Hint: f (y i x 2 i, a, b) N(ax i + b, σ ). January 1, 2017 14 / 20

Measuring the fit y = (y 1,, y n ) = data values of the response variable. ŷ = (ŷ 1,, ŷ n ) = fitted values of the response variable. TSS = (y i y) 2 = total sum of squares = total variation. RSS = (y i ŷ i ) 2 = residual sum of squares. RSS = unexplained by model squared error (due to random fluctuation) RSS/TSS = unexplained fraction of the total error. R 2 = 1 RSS/TSS is measure of goodness-of-fit R 2 is the fraction of the variance of y explained by the model. January 1, 2017 15 / 20

Overfitting a polynomial Increasing the degree of the polynomial increases R 2 Increasing the degree of the polynomial increases the complexity of the model. The optimal degree is a tradeoff between goodness of fit and complexity. If all data points lie on the fitted curve, then y = ŷ and R 2 = 1. R demonstration! January 1, 2017 16 / 20

Outliers and other troubles Question: Can one point change the regression line significantly? Use mathlet http://mathlets.org/mathlets/linear-regression/ January 1, 2017 17 / 20

Regression to the mean Suppose a group of children is given an IQ test at age 4. One year later the same children are given another IQ test. Children s IQ scores at age 4 and age 5 should be positively correlated. Those who did poorly on the first test (e.g., bottom 10%) will tend to show improvement (i.e. regress to the mean) on the second test. A completely useless intervention with the poor-performing children might be misinterpreted as causing an increase in their scores. Conversely, a reward for the top-performing children might be misinterpreted as causing a decrease in their scores. This example is from Rice Mathematical Statistics and Data Analysis January 1, 2017 18 / 20

A brief discussion of multiple linear regression Multivariate data: (x i,1, x i,2,..., x i,m, y i ) (n data points: i = 1,..., n) Model ŷ i = a 1 x i,1 + a 2 x i,2 +... + a m x i,m x i,j are the explanatory (or predictor) variables. y i is the response variable. The total squared error is n i=1 n (y i ŷi) 2 = (y i a 1 x i,1 a 2 x i,2... amx i,m ) i=1 2 January 1, 2017 19 / 20

MIT OpenCourseWare https://ocw.mit.edu 18.05 Introduction to Probability and Statistics Spring 2014 For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.