This document is linked from Linear Relationships – Correlation.

]]>This document is linked from Linear Relationships – Regression.

]]>This document is linked from Scatterplots.

]]>From the online version of Little Handbook of Statistical Practice, this reading contains a detailed discussion of correlation.

This document is linked from Linear Relationships – Correlation.

]]>A line is described by a set of points **(X,Y)** that obey a particular relationship between **X** and **Y**. That relationship is called the equation of the line, which we will express in the following form: **Y = a + bX **In this equation, **a** and **b** are constants that can be either negative or positive. The reason to write the line in this form is that the constants **a** and **b** tell us what the line looks like, as follows:

- The
**intercept (a)**is the value that**Y**takes when**X**= 0 - The
**slope (b)**is the change in**Y**for every increase of 1 unit in**X**.

The slope and intercept are indicated with arrows on the following diagram:

The technique that specifies the dependence of the response variable on the explanatory variable is called **regression**. When that dependence is linear (which is the case in our examples in this section), the technique is called **linear regression**. Linear regression is therefore the technique of finding the line that best fits the pattern of the linear relationship (or in other words, the line that best describes how the response variable linearly depends on the explanatory variable).

To understand how such a line is chosen, consider the following very simplified version of the age-distance example (we left just 6 of the drivers on the scatterplot):

Consider the line:

The intercept is 1. The slope is 1/3, and the graph of this line is, therefore:

Consider the line:

The intercept is 1. The slope is -1/3, and the graph of this line is, therefore:

This document is linked from Linear Relationships – Linear Regression.

]]>Add points to the scatterplot, then draw your guess at the regression line, and then check your answer.

This document is linked from Linear Relationships – Linear Regression.

]]>Here is another interactive demonstration from the Rosman/Chance collection which has extensive options and illustrates many ideas about linear regression and correlation.

And, remember the two-variable calculator we introduced earlier.

This document is linked from Linear Relationships – Correlation.

]]>http://phhp-faculty-cantrell.sites.medinfo.ufl.edu/files/2012/07/qz-LBD02016.swf

This document is linked from Linear Relationships – Correlation.

]]>**Related SAS Tutorials**

- 9A – (3:53) Basic Scatterplots
- 9B – (2:29) Grouped Scatterplots
- 9C – (3:46) Pearson’s Correlation Coefficient
- 9D – (3:00) Simple Linear Regression – EDA

**Related SPSS Tutorials**

- 9A – (2:38) Basic Scatterplots
- 9B – (2:54) Grouped Scatterplots
- 9C – (3:35) Pearson’s Correlation Coefficient
- 9D – (2:53) Simple Linear Regression – EDA

So far we’ve used the scatterplot to describe the relationship between two quantitative variables, and in the special case of a linear relationship, we have supplemented the scatterplot with the correlation (r).

The correlation, however, doesn’t fully characterize the linear relationship between two quantitative variables — it only measures the strength and direction. We often want to describe more precisely how one variable changes with the other (by “more precisely,” we mean more than just the direction), or predict the value of the response variable for a given value of the explanatory variable.

In order to be able to do that, we need to summarize the linear relationship with a line that best fits the linear pattern of the data. In the remainder of this section, we will introduce a way to find such a line, learn how to interpret it, and use it (cautiously) to make predictions.

Again, let’s start with a motivating example:

Earlier, we examined the linear relationship between the age of a driver and the maximum distance at which a highway sign was legible, using both a scatterplot and the correlation coefficient. Suppose a government agency wanted to predict the maximum distance at which the sign would be legible for 60-year-old drivers, and thus make sure that the sign could be used safely and effectively.

How would we make this prediction?

It would be useful if we could find a line (such as the one that is presented on the scatterplot) that represents the general pattern of the data, because then,

and predict that 60-year-old drivers could see the sign from a distance of just under 400 feet we would simply use this line to find the distance that corresponds to an age of 60 like this:

How and why did we pick this particular line (the one shown in red in the above walkthrough) to describe the dependence of the maximum distance at which a sign is legible upon the age of a driver? What line exactly did we choose? We will return to this example once we can answer that question with a bit more precision.

The technique that specifies the dependence of the response variable on the explanatory variable is called **regression**. When that dependence is linear (which is the case in our examples in this section), the technique is called **linear regression**. Linear regression is therefore the technique of finding the line that best fits the pattern of the linear relationship (or in other words, the line that best describes how the response variable linearly depends on the explanatory variable).

To understand how such a line is chosen, consider the following very simplified version of the age-distance example (we left just 6 of the drivers on the scatterplot):

There are many lines that look like they would be good candidates to be the line that best fits the data:

It is doubtful that everyone would select the same line in the plot above. We need to agree on what we mean by “best fits the data”; in other words, we need to agree on a criterion by which we would select this line. We want the line we choose to be close to the data points. In other words, whatever criterion we choose, it had better somehow take into account the vertical deviations of the data points from the line, which are marked with blue arrows in the plot below:

The most commonly used criterion is called the **least squares** criterion. This criterion says: Among all the lines that look good on your data, choose the one that has the smallest sum of squared vertical deviations. Visually, each squared deviation is represented by the area of one of the squares in the plot below. Therefore, we are looking for the line that will have the smallest total yellow area.

This line is called the **least-squares regression line**, and, as we’ll see, it fits the linear pattern of the data very well.

For the remainder of this lesson, you’ll need to feel comfortable with the algebra of a straight line. In particular you’ll need to be familiar with the **slope **and the **intercept **in the equation of a line, and their interpretation.

Like any other line, the equation of the least-squares regression line for summarizing the linear relationship between the response variable (**Y**) and the explanatory variable (**X**) has the form: **Y = a + bX**

All we need to do is calculate the intercept * a*, and the slope

The **slope** of the least squares regression line can be interpreted as the estimated (or predicted) **change in the mean (or average) value of the response variable when the explanatory variable increases by 1 unit.**

Let’s revisit our age-distance example, and find the **least-squares regression line**. The following output will be helpful in getting the 5 values we need:

- Dependent Variable: Distance
- Independent Variable: Age
- Correlation Coefficient (
**r**) = -0.7929 - The
**least squares regression line**for this example is:

- This means that for every 1-unit increase of the explanatory variable, there is, on average, a 3-unit decrease in the response variable. The interpretation
**in context**of the slope (-3) is, therefore: In this dataset, when age increases by 1 year the**average**maximum distance at which subjects can read a sign is expected to**decrease by 3 feet.** - Here is the regression line plotted on the scatterplot:

As we can see, the regression line fits the linear pattern of the data quite well.

Let’s go back now to our motivating example, in which we wanted to predict the maximum distance at which a sign is legible for a 60-year-old. Now that we have found the least squares regression line, this prediction becomes quite easy:

Practically, what the figure tells us is that in order to find the predicted legibility distance for a 60-year-old, we plug Age = 60 into the regression line equation, to find that:

**Predicted distance = 576 + (- 3 * 60) = 396**

396 feet is our best prediction for the maximum distance at which a sign is legible for a 60-year-old.

**Comment About Predictions:**

- Suppose a government agency wanted to design a sign appropriate for an even wider range of drivers than were present in the original study. They want to predict the maximum distance at which the sign would be legible for a 90-year-old. Using the least squares regression line again as our summary of the linear dependence of the distances upon the drivers’ ages, the agency predicts that 90-year-old drivers can see the sign at no more than 576 + (- 3 * 90) = 306 feet:

(The green segment of the line is the region of ages beyond 82, the age of the oldest individual in the study.)

** Question: **Is our prediction for 90-year-old drivers reliable?

** Answer: **Our original age data ranged from 18 (youngest driver) to 82 (oldest driver), and our regression line is therefore a summary of the linear relationship

Prediction for ranges of the explanatory variable that are not in the data is called **extrapolation**. Since there is no way of knowing whether a relationship holds beyond the range of the explanatory variable in the data, extrapolation is not reliable, and should be avoided. In our example, like most others, extrapolation can lead to very poor or illogical predictions.

- A special case of the relationship between two quantitative variables is the
**linear**relationship. In this case, a straight line simply and adequately summarizes the relationship.

- When the scatterplot displays a linear relationship, we supplement it with the
**correlation coefficient (r)**, which measures the**strength**and direction of a linear relationship between two quantitative variables. The correlation ranges between -1 and 1. Values near -1 indicate a strong negative linear relationship, values near 0 indicate a weak linear relationship, and values near 1 indicate a strong positive linear relationship.

- The correlation is only an appropriate numerical measure for linear relationships, and is sensitive to outliers. Therefore, the correlation should only be used as a supplement to a scatterplot (after we look at the data).

- The most commonly used criterion for finding a line that summarizes the pattern of a linear relationship is “least squares.” The
**least squares regression line**has the smallest sum of squared vertical deviations of the data points from the line.

- The
**slope**of the least squares regression line can be interpreted as the estimated (or predicted)**change in the mean (or average) value of the response variable when the explanatory variable increases by 1 unit.**

- The
**intercept**of the least squares regression line is the average value of the response variable when the explanatory variable is zero. Thus, this is only of interest if it makes sense for the explanatory variable to be zero AND we have observed data in that range (explanatory variable around zero) in our sample.

- The least squares regression line predicts the value of the response variable for a given value of the explanatory variable.
**Extrapolation**is prediction of values of the explanatory variable that fall outside the range of the data. Since there is no way of knowing whether a relationship holds beyond the range of the explanatory variable in the data, extrapolation is not reliable, and should be avoided.

Optional: Create your own solutions using your software for extra practice.

- Create and interpret a simple scatterplot
- Create and interpret a labeled scatterplot

Use the following output to answer the questions that follow.

In this activity we will look at height and weight data that were collected from 57 males and 24 females, and use the data to explore how the weight of a person is related to (or affected by) his or her height. This implies that height will be our explanatory variable and weight will be our response variable. We will then look at gender, and see how labeling this third variable contributes to our understanding of the form of the relationship.

Our dataset contains the following variables:

**gender:**0 = male, 1 = female.**height:**in inches.**weight:**in pounds.

Answer the following questions using the output obtained. In this exercise we will:

- use the scatterplot to examine the relationship between two quantitative variables.
- use the labeled scatterplot to better understand the form of a relationship.

http://phhp-faculty-cantrell.sites.medinfo.ufl.edu/files/2012/07/qz-LBD02014.swf

http://phhp-faculty-cantrell.sites.medinfo.ufl.edu/files/2012/07/qz-LBD02015.swf

(Optional) SPSS Steps:

**Import Data:**FILE > OPEN > DATA, choose Excel file from the pull-down, find the file, continue**Define Variable Properties:**Provide labels for 0 and 1 as Male and Female, and label- Height: label as “Height (inches)
- Weight: label as “Weight (pounds)

**Scatterplots:**GRAPHS > CHART BUILDER, complete the wizard for each of the two requested graphs. Edit colors for males and females on the labeled scatterplot.

**Create FORMATS for Gender:**Use PROC FORMAT to create a format to translate 1 into “Female” and 0 into “Male” (we will associate it with the variable in the next step).**Label and Format Variables:**Using a DATA step, create a new dataset named height2 where you label the variables height and weight as Height (inches) and Weight (pounds) using a LABEL statement. Use a format statement to format the variable gender with the format created in the previous step.**View Dataset Information in SAS:**Use PROC CONTENTS to view the information about the new dataset.**Create Basic Scatterplot:**Use PROC SGPLOT and the SCATTER statement to create a scatterplot of X=height by Y=weight**Create Labeled Scatterplot:**Use PROC SGPLOT and the SCATTER statement to create a scatterplot of X=height by Y=weight with the GROUP= option to label the points by gender.

This document is linked from Scatterplots.