This document is linked from Linear Relationships – Correlation.

]]>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.

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

- Observe how an outlier can affect the correlation coefficient by comparing the value using data with and without an outlier.

Use the following output to answer the questions that follow.

The average gestation period, or time of pregnancy, of an animal is closely related to its longevity — the length of its lifespan. Data on the average gestation period and longevity (in captivity) of 40 different species of animals have been recorded.

Here is a summary of the variables in our dataset:

**animal:**the name of the animal species.**gestation:**the average gestation period of the species, in days.**longevity:**the average longevity of the species, in years.

Remember that the correlation is only an appropriate measure of the **linear **relationship between two quantitative variables. First produce a scatterplot to verify that gestation and longevity are nearly linear in their relationship.

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-LBD02017.swf

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

(Optional) SPSS Steps:

**Label Variables amd Define Variable Properties****Create Scatterplot:**GRAPHS > CHART BUILDER, create a simple scatterplot relating X = longevity to Y = gestation**Calculate Correlation:**ANALYZE > CORRELATE > BIVARIATE, calculate the correlation between longevity and gestation as illustrated**Remove Outlier and Save New Data:**select the row containing the outlier, right-click on the row number and choose CUT**Re-create Scatterplot:**GRAPHS > CHART BUILDER, create a simple scatterplot relating X = longevity to Y = gestation using the new dataset**Re-calculate Correlation:**ANALYZE > CORRELATE > BIVARIATE, calculate the correlation on the new dataset

**Label Variables:**Using a DATA step create a new dataset (animals2) where you label the varibles longevity and gestation as Longevity (years) and Gestation (days) using a LABEL statement.**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=longevity by Y=gestation.**Calculate Correlation Coefficient:**Use PROC CORR to calculate the correlation coefficient between X=longevity by Y=gestation. In SAS 9.3 you will likely get the scatterplot matrix automatically, in SAS 9.2 you must request this by using ODS GRAPHICS ON before the procedure and ODS GRAPHIC OFF to stop producing this output after the procedure (or whenever you wish to stop producing ODS GRAPHICS).**Delete Outlier:**Using a DATA step create a new dataset (animals3) and use an IF-THEN statement to delete the observation corresponding to the outlier. This outlier is an elephant with average longevity of 40 years and average gestation of 645 days.**View Dataset Information in SAS:**Use PROC CONTENTS to view the information about the new dataset where you have removed the outlier.**Create Basic Scatterplot:**Use PROC SGPLOT and the SCATTER statement to create a scatterplot of X=longevity by Y=gestation on the dataset with the outlier removed.**Calculate Correlation Coefficient:**Use PROC CORR to calculate the correlation coefficient bewteen X=longevity by Y=gestation on the dataset with the outlier removed.

This document is linked from Linear Relationships – Correlation.

]]>

http://phhp-faculty-cantrell.sites.medinfo.ufl.edu/files/2013/01/qzDIG02005.swf

http://phhp-faculty-cantrell.sites.medinfo.ufl.edu/files/2013/01/qzDIG02006.swf

This document is linked from Linear Relationships – Correlation.

]]>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.

]]>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.

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

This document is linked from Scatterplots.

]]>**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 have visualized relationships between two quantitative variables using scatterplots, and described the overall pattern of a relationship by considering its direction, form, and strength. We noted that assessing the strength of a relationship just by looking at the scatterplot is quite difficult, and therefore we need to supplement the scatterplot with some kind of numerical measure that will help us assess the strength.

In this part, we will restrict our attention to the **special case of relationships that have a linear form**, since they are quite common and relatively simple to detect. More importantly, there exists a numerical measure that assesses the strength of the **linear** relationship between two quantitative variables with which we can supplement the scatterplot. We will introduce this numerical measure here and discuss it in detail.

Even though from this point on we are going to focus only on **linear** relationships, it is important to remember that **not every relationship between two quantitative variables has a linear form.** We have actually seen several examples of relationships that are not linear. The statistical tools that will be introduced here are **appropriate only for examining linear relationships,** and as we will see, when they are used in nonlinear situations, these tools can lead to errors in reasoning.

Let’s start with a motivating example. Consider the following two scatterplots.

We can see that in both cases, the direction of the relationship is **positive** and the form of the relationship is **linear**. What about the strength? Recall that the strength of a relationship is the extent to which the data follow its form.

The purpose of this example was to illustrate how assessing the strength of the **linear** relationship from a scatterplot alone is problematic, since our judgment might be affected by the scale on which the values are plotted. This example, therefore, provides a motivation for the **need **to supplement the scatterplot with a **numerical measure** that will **measure the strength** of the **linear** relationship between two quantitative variables.

The numerical measure that assesses the strength of a **linear** relationship is called the **correlation coefficient**, and is denoted by r. We will:

- give a definition of the correlation r,
- discuss the calculation of r,
- explain how to interpret the value of r, and
- talk about some of the properties of r.

**Calculation: **r is calculated using the following formula:

However, the calculation of the correlation (r) is not the focus of this course. We will use a statistics package to calculate r for us, and the **emphasis **of this course will be on the **interpretation** of its value.

Once we obtain the value of r, its interpretation with respect to the strength of **linear** relationships is quite simple, as these images illustrate:

In order to get a better sense for how the value of *r* relates to the strength of the **linear** relationship, take a look the following applets.

If you will be using correlation often in your research, I highly urge you to read the following more detailed discussion of correlation.

Now that we understand the use of *r* as a numerical measure for assessing the direction and strength of **linear** relationships between quantitative variables, we will look at a few examples.

Earlier, we used the scatterplot below to find a **negative linear** relationship between the age of a driver and the maximum distance at which a highway sign was legible. What about the strength of the relationship? It turns out that the correlation between the two variables is r = -0.793.

Since r < 0, it confirms that the direction of the relationship is negative (although we really didn’t need r to tell us that). Since r is relatively close to -1, it suggests that the relationship is moderately strong. In context, the negative correlation confirms that the maximum distance at which a sign is legible generally decreases with age. Since the value of r indicates that the **linear** relationship is moderately strong, but not perfect, we can expect the maximum distance to vary somewhat, even among drivers of the same age.

A statistics department is interested in tracking the progress of its students from entry until graduation. As part of the study, the department tabulates the performance of 10 students in an introductory course and in an upper-level course required for graduation. What is the relationship between the students’ course averages in the two courses? Here is the scatterplot for the data:

The scatterplot suggests a relationship that is **positive** in direction, **linear** in form, and seems quite strong. The value of the correlation that we find between the two variables is r = 0.931, which is very close to 1, and thus confirms that indeed the **linear** relationship is very strong.

**Comments:**

- Note that in both examples we supplemented the scatterplot with the correlation (r). Now that we have the correlation (r), why do we still need to look at a scatterplot when examining the relationship between two quantitative variables?

- The
**correlation**coefficient can**only**be interpreted as the**measure of the strength of a linear relationship**, so we need the scatterplot to verify that the relationship indeed looks**linear**. This point and its importance will be clearer after we examine a few properties of r.

We will now discuss and illustrate several important properties of the correlation coefficient as a numerical measure of the strength of a **linear** relationship.

- The correlation does not change when the units of measurement of either one of the variables change. In other words, if we
**change the units of measurement**of the explanatory variable and/or the response variable, this has**no effect on the correlation (r)**.

To illustrate this, below are two versions of the scatterplot of the relationship between sign legibility distance and driver’s age:

The top scatterplot displays the original data where the maximum distances are measured **in feet**. The bottom scatterplot displays the same relationship, but with maximum distances changed to **meters**. Notice that the Y-values have changed, but the correlations are the same. This is an example of how changing the units of measurement of the response variable has no effect on r, but as we indicated above, the same is true for changing the units of the explanatory variable, or of both variables.

This might be a good place to comment that the correlation (r) is **“unitless”**. It is just a number.

- The correlation
**only measures the strength of a linear relationship**between two variables.**It ignores any other type of relationship, no matter how strong it is.**For example, consider the relationship between the average fuel usage of driving a fixed distance in a car, and the speed at which the car drives:

Our data describe a fairly simple non-linear (sometimes called curvilinear) relationship: the amount of fuel consumed decreases rapidly to a minimum for a car driving 60 kilometers per hour, and then increases gradually for speeds exceeding 60 kilometers per hour. The relationship is very strong, as the observations seem to perfectly fit the curve.

Although the relationship is strong, the correlation r = -0.172 indicates a weak **linear** relationship. This makes sense considering that the data fails to adhere closely to a linear form:

- The correlation by itself is
**not**enough to determine whether or not a relationship is linear. To see this, let’s consider the study that examined the effect of monetary incentives on the return rate of questionnaires. Below is the scatterplot relating the percentage of participants who completed a survey to the monetary incentive that researchers promised to participants, in which we find a**strong non-linear (sometimes called curvilinear) relationship:**

The relationship is non-linear (sometimes called curvilinear), yet the correlation r = 0.876 is quite close to 1.

In the last two examples we have seen two very strong non-linear (sometimes called curvilinear) relationships, one with a correlation close to 0, and one with a correlation close to 1. Therefore, the correlation alone does not indicate whether a relationship is **linear** or not. The important principle here is:

**Always look at the data!**

- The correlation is heavily influenced by outliers. As you will learn in the next two activities, the way in which the outlier influences the correlation depends upon whether or not the outlier is consistent with the pattern of the
**linear**relationship.

Hopefully, you’ve noticed the correlation decreasing when you created this kind of outlier, which **is not consistent **with the pattern of the relationship.

The next activity will show you how an outlier that **is consistent** with the direction of the linear relationship actually strengthens it.

In the previous activity, we saw an example where there was a positive **linear** relationship between the two variables, and including the outlier just “strengthened” it. Consider the hypothetical data displayed by the following scatterplot:

In this case, the low outlier gives an “illusion” of a positive **linear** relationship, whereas in reality, there is no **linear** relationship between X and Y.