1 / 86

Introduction to Linear Regression

Introduction to Linear Regression. You have seen how to find the equation of a line that connects two points. You have seen how to find the equation of a line that connects two points. Often, we have more than two data points, and usually the data points do not all lie on a single line.

nasya
Download Presentation

Introduction to Linear Regression

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Linear Regression

  2. You have seen how to find the equation of a line that connects two points.

  3. You have seen how to find the equation of a line that connects two points. • Often, we have more than two data points, and usually the data points do not all lie on a single line.

  4. You have seen how to find the equation of a line that connects two points. • Often, we have more than two data points, and usually the data points do not all lie on a single line. • It is possible to find the equation of a line that most closely fits a set of data points. Such a line is called a regression line or a linear regression equation.

  5. You have seen how to find the equation of a line that connects two points. • Often, we have more than two data points, and usually the data points do not all lie on a single line. • It is possible to find the equation of a line that most closely fits a set of data points. Such a line is called a regression line or a linear regression equation. • Our goal here is to learn what a regression line is. You can then watch the presentation on how to find the equation of a regression line on Excel.

  6. Consider the following table that the average price of a two-bedroom apartment in downtown New York City from 1994 to 2004, where t=0 represents 1994.

  7. Consider the following table that the average price of a two-bedroom apartment in downtown New York City from 1994 to 2004, where t=0 represents 1994.

  8. Consider the following table that the average price of a two-bedroom apartment in downtown New York City from 1994 to 2004, where t=0 represents 1994. • We can plot each of these data points on a graph. Each point is of the form (t, p), so we have 6 points to plot.

  9. Consider the following table that the average price of a two-bedroom apartment in downtown New York City from 1994 to 2004, where t=0 represents 1994. • We can plot each of these data points on a graph. Each point is of the form (t, p), so we have 6 points to plot. • They are (0, 0.38), (2, 0.40), (4, 0.60), (6, 0.95), (8, 1.20), and (10, 1.60). Just looking at them like this doesn’t give much indication of a pattern, although we can see that the p-values are increasing as t increases.

  10. When we plot the points all together on a set of axes, we get the following scatter plot:

  11. When we plot the points all together on a set of axes, we get the following scatter plot: • It seems that the data do follow a somewhat linear pattern.

  12. We can find the line the line that most closely fits the equation and graph it over the data points.

  13. We can find the line the line that most closely fits the equation and graph it over the data points.

  14. We can find the line the line that most closely fits the equation and graph it over the data points. • Notice that the line does not go through all of the data points.

  15. We can also find the equation of this “line of best fit”.

  16. We can also find the equation of this “line of best fit”.

  17. We can also find the equation of this “line of best fit”. • We can also get what’s called the correlation coefficient.

  18. We can also find the equation of this “line of best fit”. • We can also get what’s called the correlation coefficient.

  19. We can also find the equation of this “line of best fit”. • We can also get what’s called the correlation coefficient. • You will be able to do all of this on Excel once you watch the instructional video and read the PDFs for this material. For now, we just want to get an idea of what the regression line is and what the correlation coefficient tells us about the regression equation.

  20. What does the regression equation tell us about the relationship between time and sale price?

  21. What does the regression equation tell us about the relationship between time and sale price? • The slope and the vertical intercept (usually the y-intercept, here the p-intercept) tell us different things.

  22. In this case, the p-intercept tells us what the sale price is predicted to be when t=0 (that is, in the year 1994).

  23. In this case, the p-intercept tells us what the sale price is predicted to be when t=0 (that is, in the year 1994). • The regression equation is p=0.1264t+0.2229. Recall that price is in millions of dollars.

  24. In this case, the p-intercept tells us what the sale price is predicted to be when t=0 (that is, in the year 1994). • The regression equation is p=0.1264t+0.2229. Recall that price is in millions of dollars. • Thus, if t=0, the regression equation predicts a price of $0.2229 million or $222,900.

  25. In this case, the p-intercept tells us what the sale price is predicted to be when t=0 (that is, in the year 1994). • The regression equation is p=0.1264t+0.2229. Recall that price is in millions of dollars. • Thus, if t=0, the regression equation predicts a price of $0.2229 million or $222,900. • According to the table, the actual price was $0.38 million or $380,000. These values don’t have to be the same however, since the regression equation can’t match every point exactly. It is only a model that most closely fits the data points.

  26. What does the slope of the regression equation tell us?

  27. What does the slope of the regression equation tell us? • The slope of our regression equation is 0.1264.

  28. What does the slope of the regression equation tell us? • The slope of our regression equation is 0.1264. • We can always write a number x as x divided by 1, so we can write this slope as .

  29. What does the slope of the regression equation tell us? • The slope of our regression equation is 0.1264. • We can always write a number x as x divided by 1, so we can write this slope as . • Recall that the definition of slope is .

  30. What does the slope of the regression equation tell us? • The slope of our regression equation is 0.1264. • We can always write a number x as x divided by 1, so we can write this slope as . • Recall that the definition of slope is . • In this case we are using p and t, so it’s .

  31. What does the slope of the regression equation tell us? • The slope of our regression equation is 0.1264. • We can always write a number x as x divided by 1, so we can write this slope as . • Recall that the definition of slope is . • In this case we are using p and t, so it’s . • So for our problem, we have .

  32. What does the slope of the regression equation tell us? • The slope of our regression equation is 0.1264. • We can always write a number x as x divided by 1, so we can write this slope as . • Recall that the definition of slope is . • In this case we are using p and t, so it’s . • So for our problem, we have . • We can interpret this to mean that when t increases by 1, we can expect that p will increase by 0.1264.

  33. For this problem, t is measure in years and p is measured in millions of dollars.

  34. For this problem, t is measure in years and p is measured in millions of dollars. • So more specifically, the slope can be interpreted to mean that if t increases by 1 year, the model predicts that the average price p of a two-bedroom apartment will increase by about $0.1264 million dollars, or $126,400.

  35. For this problem, t is measure in years and p is measured in millions of dollars. • So more specifically, the slope can be interpreted to mean that if t increases by 1 year, the model predicts that the average price p of a two-bedroom apartment will increase by about $0.1264 million dollars, or $126,400. • Even more plainly, we can say that the model predicts that the average price of a two-bedroom apartment in New York City will increase by about $126,400 per year.

  36. For this problem, t is measure in years and p is measured in millions of dollars. • So more specifically, the slope can be interpreted to mean that if t increases by 1 year, the model predicts that the average price p of a two-bedroom apartment will increase by about $0.1264 million dollars, or $126,400. • Even more plainly, we can say that the model predicts that the average price of a two-bedroom apartment in New York City will increase by about $126,400 per year. • We can now use the linear regression model to predict future prices. For example, if we wanted to predict what the price of an apartment was in 2008, we could plug in 14 for t in the regression equation (since t=0 is 1994).

  37. Plugging in 14 for t into the regression equation gives p=0.1264(14)+0.2229=1.9925.

  38. Plugging in 14 for t into the regression equation gives p=0.1264(14)+0.2229=1.9925. • This means that if the trend continued, we can expect that the price of a two-bedroom apartment was around $1,992,500 in 2008.

  39. Plugging in 14 for t into the regression equation gives p=0.1264(14)+0.2229=1.9925. • This means that if the trend continued, we can expect that the price of a two-bedroom apartment was around $1,992,500 in 2008. • You can also use the regression equation to check how closely the model matches the actual price in some years that were given on the table. For example, for 2000 the equation predicts a price of p=0.1264(6)+0.2229=0.9813, or $981,300.

  40. Plugging in 14 for t into the regression equation gives p=0.1264(14)+0.2229=1.9925. • This means that if the trend continued, we can expect that the price of a two-bedroom apartment was around $1,992,500 in 2008. • You can also use the regression equation to check how closely the model matches the actual price in some years that were given on the table. For example, for 2000 the equation predicts a price of p=0.1264(6)+0.2229=0.9813, or $981,300. • According to the table, the actual price was $950,000, so the regression equation is pretty close.

  41. It is important to remember that the regression equation is just a model, and it won’t give the exact values.

  42. It is important to remember that the regression equation is just a model, and it won’t give the exact values. • If the equation is a good fit to the data however, it will give a very good approximation, so it can be used to forecast what may happen in the future if the current trend continues.

  43. It is important to remember that the regression equation is just a model, and it won’t give the exact values. • If the equation is a good fit to the data however, it will give a very good approximation, so it can be used to forecast what may happen in the future if the current trend continues. • Next, let’s take a quick look at how a regression equation is derived, and then take a look at what the correlation coefficient (or the r-squared value on Excel) tell us about the regression equation.

  44. Let’s take another look at the data points and the regression line.

  45. Let’s take another look at the data points and the regression line. • Why does this particular line give the best “fit” for the data? Why not some other line?

  46. It has to do with what is called a residual.

  47. It has to do with what is called a residual. • A residual is the difference between a particular data point and the regression line.

  48. If we zoom in on a particular data point, we can see what a residual is.

  49. If we zoom in on a particular data point, we can see what a residual is. • Let’s zoom in on this particular data point.

  50. Zooming into this box:

More Related