Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objectives (IPS Chapter 2.3)

Similar presentations


Presentation on theme: "Objectives (IPS Chapter 2.3)"— Presentation transcript:

1 Objectives (IPS Chapter 2.3)
Least-squares regression Regression lines Prediction: interpolation Correlation and r2

2 But which line best describes our data?
Correlation tells us about strength (scatter) and direction of the linear relationship between two quantitative variables. In addition, we would like to have a numerical description of how both variables vary together. For instance, is one variable increasing faster than the other one? And we would like to make predictions based on that numerical description. But which line best describes our data?

3 The least-squares regression line
Error=observed value – predicted value. The least-squares regression line is the unique line such that the sum of the squared vertical (y) distances between the data points and the line is the smallest possible. Distances between the points and line are squared so all are positive values. This is done so that distances can be properly added (Pythagoras).

4 How to: First we calculate the slope of the line, b; from statistics we already know: r is the correlation. sy is the standard deviation of the response variable y. sx is the the standard deviation of the explanatory variable x. Once we know b, the slope, we can calculate a, the y-intercept: where x and y are the sample means of the x and y variables This means that we don't have to calculate a lot of squared distances to find the least-squares regression line for a data set. We can instead rely on the equation. But typically, we use a 2-var stats calculator or stats software.

5 Example 1: Beer v.s. BAC Q1: Find the regression line.
Here, we have two quantitative variables for each of 16 students. 1) How many beers they drank, and 2) Their blood alcohol level (BAC) We are interested in the relationship between the two variables: How is one affected by changes in the other one? Student Beers Blood Alcohol 1 5 0.1 2 0.03 3 9 0.19 6 7 0.095 0.07 0.02 11 4 13 0.085 8 0.12 0.04 0.06 10 0.05 12 14 0.09 15 0.01 16 Q1: Find the regression line. Q2: If a student has 6.5 cups of beers, what is the BAC we expect?

6 Example 1: Beer v.s. BAC Here, we have two quantitative variables for each of 16 students. 1) How many beers they drank, and 2) Their blood alcohol level (BAC) We are interested in the relationship between the two variables: How is one affected by changes in the other one? Student Beers Blood Alcohol 1 5 0.1 2 0.03 3 9 0.19 6 7 0.095 0.07 0.02 11 4 13 0.085 8 0.12 0.04 0.06 10 0.05 12 14 0.09 15 0.01 16 Q3: If a student turned out to drink 6.5 cups of beers, with BAC what is the corresponding prediction error?

7 Making predictions: interpolation
The equation of the least-squares regression allows to predict y for any x within the range studied. This is called interpolating. Q2: If a student has 6.5 cups of beers, what is the BAC we expect? Nobody in the study drank 6.5 beers, but by finding the value of from the regression line for x = 6.5 we would expect a blood alcohol content of mg/ml.

8 (in 1000’s) Example 2 Q1: Find the regression line; Q2: If there were 500,000 powerboats, what is the # of deaths we would expect? There is a positive linear relationship between the number of powerboats registered and the number of manatee deaths. The least squares regression line has the equation: ˆ y = . 125 x - 41 4 Thus if we were to limit the number of powerboat registrations to 500,000, what could we expect for the number of manatee deaths? Roughly 22 manatees.

9 Error=observed value – predicted value= 18-22 = -4.
(in 1000’s) Q3: Supposed in 1991, it turned out to have 500,000 powerboats and there were 18 manatee deaths, what is the corresponding prediction error? Thus if we were to limit the number of powerboat registrations to 500,000, what could we expect for the number of manatee deaths? Roughly 22 manatees. Error=observed value – predicted value= = -4.

10 Q3: How to plot a regression line?
The equation completely describes the regression line. To plot the regression line you only need to plug two x values into the equation, get y, and draw the line that goes through those points. Hint: The regression line always passes through the mean of x and y. The points you use for drawing the regression line are derived from the equation. They are NOT points from your sample data (except by pure coincidence).

11 The interpretation of the slope b
The interpretation of the slope b: for each unit change in X, the amount of change in Y For each 1k more boats, the deaths of Manatees increases by 0.125 For each extra beer , BAC will increase by 0.018 ˆ y = . 125 x - 41 4

12 The interpretation of the slope b Exercise:
For each extra beer , BAC will increase by 0.018 For each extra 5 beer , BAC will increase by 5*0.018=0.09 For each extra 2 beer , BAC will increase by ________ For each extra 3 beer , BAC will increase by _________

13 Note: Only difference b/w these two examples is to switch x and y.
The distinction between explanatory and response variables is crucial in regression. If you exchange y for x in calculating the regression line, you will get the wrong line, even though correlation coefficient r does not distinguish x and y!. Regression examines the distance of all points from the line in the y direction only. Q: Find the regression line for the following two examples. Do you get the same regression line? Note: Only difference b/w these two examples is to switch x and y. x y 1 3 7 5 9 11 x y 3 1 7 9 5 11

14 The distinction between explanatory and response variables is crucial in regression. If you exchange y for x in calculating the regression line, you will get the wrong line, even though correlation coefficient r does not distinguish x and y!. Regression examines the distance of all points from the line in the y direction only. Hubble telescope data about galaxies moving away from earth: These two lines are the two regression lines calculated either correctly (x = distance, y = velocity, solid line) or incorrectly (x = velocity, y = distance, dotted line).

15 Coefficient of determination, r2
r2, the coefficient of determination, is the square of the correlation coefficient. r2 (square of the correlation coefficient) gives the percent of variation explained in the values of y that is explained by the least squares regression of y on x. r2 is always between 0 and 1 (closer to 1, the better the line is for prediction) Go over point that missing zero is OK - this is messy data, a prediction based on messy data. Residuals should be scattered randomly around the line, or there is something wrong with your data - not linear, outliers, etc.

16

17

18 ˆ y = . 125 x - 41 4

19 Here are two plots of height (response) against age (explanatory) of some children. Notice how r2 relates to the variation in heights... r=0.994, r-square=0.988 r=0.921, r-square=0.848

20 Here the change in x only explains 76% of the change in y
Here the change in x only explains 76% of the change in y. The rest of the change in y (the vertical scatter, shown as red arrows) must be explained by something other than x. r = 0.87 r2 = 0.76 r = -1 r2 = 1 Changes in x explain 100% of the variations in y. Y can be entirely predicted for any given value of x. r = 0 r2 = 0 Changes in x explain 0% of the variations in y. The value(s) y takes is (are) entirely independent of what value x takes.

21 Objectives (IPS Chapter 2.4, and 2.5)
Residuals Outliers and influential points Association and causation

22 Residuals The distances from each point to the least-squares regression line give us potentially useful information about the contribution of individual data points to the overall pattern of scatter. These distances are called “residuals.” The sum of these residuals is always 0. Points above the line have a positive residual. Points below the line have a negative residual. So where does this line come from? Predicted ŷ Observed y

23 Residual plots Residuals are the distances between y-observed and y-predicted. We plot them in a residual plot. If residuals are scattered randomly around 0, chances are your data fit a linear model, were normally distributed, and you didn’t have outliers.

24 The x-axis in a residual plot is the same as on the scatterplot.
The line on both plots is the regression line. Only the y-axis is different.

25 Residuals are randomly scattered—good!
Curved pattern—means the relationship you are looking at is not linear. A change in variability across plot is a warning sign. You need to find out why it is, and remember that predictions made in areas of larger variability will not be as good. HWQ: 2.74(c) 2.94(a,b) 2.95., 2.100,2.102

26 Association and causation
Association, however strong, does NOT imply causation. Only careful experimentation can show causation. Not all examples are so obvious…

27 Influential points Correlations are calculated using means and standard deviations, and thus are NOT resistant to outliers. Just moving one point away from the general trend here decreases the correlation from to -0.75

28 Outliers and influential points
Outlier: observation that lies outside the overall pattern of observations. “Influential individual”: observation that markedly changes the regression if removed. This is often an outlier on the x-axis. Child 19 = outlier in y direction Child 18 = outlier in x direction Child 19 is an outlier of the relationship. Child 18 is only an outlier in the x direction and thus might be an influential point.

29 Are these points influential?
All data Without child 18 Without child 19 outlier in y-direction influential Are these points influential? Php: 2.75


Download ppt "Objectives (IPS Chapter 2.3)"

Similar presentations


Ads by Google