Presentation is loading. Please wait.

Presentation is loading. Please wait.

Correlation tells us about strength (scatter) and direction of the linear relationship between two quantitative variables. In addition, we would like to.

Similar presentations


Presentation on theme: "Correlation tells us about strength (scatter) and direction of the linear relationship between two quantitative variables. In addition, we would like to."— Presentation transcript:

1 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?

2 Explanatory (independent) variable: number of beers Response (dependent) variable: blood alcohol content x y Recall: explanatory and response variables A response variable measures or records an outcome of a study - the endpoint of interest in the study. An explanatory variable explains changes in the response variable. Typically, the explanatory or independent variable is plotted on the x axis, and the response or dependent variable is plotted on the y axis.

3 Some plots don’t have clear explanatory and response variables. Do calories explain sodium amounts? Does percent return on Treasury bills explain percent return on common stocks?

4 The regression line  A regression line is a straight line that describes how a response variable y changes as an explanatory variable x changes - the description is made through the slope and intercept of the line.  We often use a regression line to predict the value of y for a given value of x; the line is also called the prediction line, or the least-squares line, or the best fit line.  In regression, the distinction between explanatory and response variables is important - if you interchange the roles of x and y, the regression line is different. y-hat is the predicted value of y b 1 is the slope b 0 is the y-in tercept

5 Distances between the points and line are squared so all are positive values. This is done so that distances can be properly added… The regression line The least-squares regression line is the unique line such that the sum of the squares of the vertical (y) distances between the data points and the line is as small as possible ("least squares")

6 First we calculate the slope of the line, b 1 ; from statistics we already know: r is the correlation. s y is the standard deviation of the response variable y. s x is the the standard deviation of the explanatory variable x. Once we know b 1, the slope, we can calculate b 0, the y-intercept: Where and are the sample means of the x and y variables How to: Typically, we use the TI-83 or the R function lm (linear model) to compute the b's, rarely using the above formulas…

7 The equation completely describes the regression line. To plot the regression line you only need to plug two x values into the equation, get the two y's, and draw the line that goes through those points. Hint: The regression line always passes through the mean of x and the mean of y. Let R draw the regression line with the abline function after you've done the scatterplot: plot(x,y) lm(y~x) abline(lm(y~x))

8 Unlike in Correlation, 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 a different line. 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).

9 Making predictions The equation of the least-squares regression allows you to predict y for any x within the range studied - be careful about extrapolation! Confirm the regression line's equation below using R… 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 0.094 mg/ml.

10 There is a positive linear relationship between the number of powerboats registered and the number of manatee deaths. (in 1000s) The least squares regression line has the equation: Roughly 21 manatees. Thus if we were to limit the number of powerboat registrations to 500,000, what could we expect for the number of manatee deaths?  ˆ y  0.125x  41.4 ˆ y  0.125x  41.4 Confirm this slide by plotting the data, computing the l.s. line and evaluating it at x=500

11 Extrapolation is the use of a regression line for predictions outside the range of x values used to obtain the line. This is not a smart thing to do, as seen here. Height in Inches !!! Extrapolation - Beware!

12 Sometimes the y-intercept is not realistically possible. Here we have negative blood alcohol content, which makes no sense… y-intercept shows negative blood alcohol But the negative value is correct for the equation of the regression line. There is a lot of scatter in the data, and the slope and intercept of the line are both estimates. We'll see later the y- intercept is probably not "significantly different from zero" The y intercept

13 Coefficient of determination, r 2 In this example, r 2 represents the percentage of the variation in BAC (vertical scatter from the regression line) that can be explained by the regression of BAC on number of beers. r 2, the coefficient of determination, is the square of the correlation coefficient. r = 0.87 r 2 = 0.76

14 r = -1 r 2 = 1 Changes in x explain 100% of the variation in y. Y can be entirely predicted for any given value of x. Here the regression of y on x explains only 76% of the variation in y. The rest of the variation in y (the vertical scatter, shown as red arrows) must be explained by something other than the line. r = 0.87 r 2 = 0.76

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

16 r = 0.86, but this is misleading. The elephant is an influential point. Most mammals are very small in comparison. Without this point, r = 0.50 only. Body weight and brain weight in 96 mammal species Now we plot the log of brain weight against the log of body weight. The pattern is linear, with r = 0.96. The vertical scatter is homogenous → good for predictions of brain weight from body weight (in the log scale).

17  Homework:  You should have read through section 2.3, carefully reviewing what you know about lines from your algebra course…Go over Examples 2.18-2.21 in some detail so you understand them!  Do #2.66, 2.71-2.73, 2.78, 2.82, 2.83 Use R to make the scatterplots, describe the association you see between the two variables, and then let R (using the lm function) calculate the intercept and slope and use cor (square it's value) to get r-square for the regression line. Explain what the slope, intercept, and r-square mean in the context of the specific problem. Also, if you'd like, I can show you how to do all this on the TI-83 …


Download ppt "Correlation tells us about strength (scatter) and direction of the linear relationship between two quantitative variables. In addition, we would like to."

Similar presentations


Ads by Google