Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Statistics
  • Discussion

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Books

Bookmark and Share
Lecture Comments (3)

2 answers

Last reply by: Kristen Gravlee
Fri Sep 28, 2012 12:05 AM

Post by NASER HOTI on January 23, 2012

it will be very helpful if we have handouts of these lecture...


Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Roadmap 0:05
    • Roadmap
  • Summarizing a Scatterplot Quantitatively 0:47
    • Shape
    • Trend
    • Strength: Correlation ®
  • Correlation Coefficient ( r ) 2:30
    • Correlation Coefficient ( r )
  • Trees vs. Forest 11:59
    • Trees vs. Forest
  • Calculating r 15:07
    • Average Product of z-scores for x and y
  • Relationship between Correlation and Slope 21:10
    • Relationship between Correlation and Slope
  • Example 1: Find the Correlation between Grams of Fat and Cost 24:11
  • Example 2: Relationship between r and b1 30:24
  • Example 3: Find the Regression Line 33:35
  • Example 4: Find the Correlation Coefficient for this Set of Data 37:37

Transcription: Correlation

Hi and welcome to

Today we are going to talk about correlation. 0002

First let us go back in and just briefly review summarizing scatter plots quantitatively 0007

and talk about all the other things we have talked about scatter plots.0013

Then we will talk about eyeballing the correlation coefficient or what we call r, persons r.0018

Actually if you have a set of data that looks a particular way often you could sort of ballpark where the correlation coefficient falls.0026

We already talked about precisely calculating it.0036

Then we are going to go back and talk about the relationship between r and b1 or slope of our regression line.0039

First let us talk about summarizing a scatter plot quantitatively.0049

We did not deal with shape.0056

We just looked at it and maybe that is pretty good.0058

We will talk about shape in the next couple of lessons, but for now we are going to leave shape alone in terms of quantitatively calculating it.0062

We did look at how to precisely calculate the trend or by looking at the regression line, 0072

that middle line in between all those lines that summarizes the middle of all those points.0080

And that middle line really gives us the relationship between X and Y, because it is the function that gives us if we have x, we get y and if we get y we get x.0087

We can get the relationship between those two variables.0101

Finally today we are going to talk about how calculating strength and not just looking at it as pretty strong right, 0106

but instead we are going to actually calculate the correlation coefficients r.0115

That idea is simply, how pact around the regression line is our data points.0120

Are they tightly packed?0130

Is it a strong correlation like it strongly packed around that regression line?0132

Or is it very loose?0138

Is it dispersed?0139

It is not really sticking close to that line, then we would have low strength or low correlation.0141

For instance I am just eyeballing it and there are a lot of data.0152

You might have no relationship between two variables, and in that case, the spread looks something like this where there is no real line in there. 0157

It is just sort of this cloud of dots.0168

Remember each of these points is a case.0172

Each of those cases has two variables.0178

One variable x is on it the x-axis and the other variable we will call it y is represented on the y-axis.0183

That point represents x here and y here.0192

In this case there is no relationship between X and Y just because you know what x is.0199

Let us say we know x is here.0204

Do you have any certainty as to where y might be?0209

There is some y down here and some y up here.0213

Even more so what about if we got X was here do we have any reason to say y is in a particular place?0218

No not really.0226

Because of that a line would not help us here.0228

A regression line does not actually summarize this very well, and it is because the correlation coefficient is very low. 0233

There is very low strength. 0240

There is very low adherence to the line.0241

Moving out a little bit further, you see that this one is starting to have more of a elongated shape.0245

This is still a fairly low correlation, but you can see that they are starting to be a linear relationship between X and Y, namely as x goes up, y also goes up.0255

This is what we call a positive correlation.0270

There is a relationship between x and y that is linear and positive.0273

Notice that y on the other side of this is the exact opposite where it is the same shape, 0280

but it is been almost like flipped around like we put a mirror here and looked at the mirror reflection.0286

In this case it is the same shape cloud but now as x goes down y goes up.0294

Here we see the opposite relationship between X and Y and we call it a negative correlation.0305

Because of that the signs act accordingly. 0312

Here the sign for this slope that is negative is -.4.0316

Here for slope that is positive as x goes up y goes up, as x goes down y goes down, that is a positive number.0325

We could easily just by looking at the correlation coefficient immediately know what kind of roughly what kind of relationship x and y have.0336

Notice that as we go out even further, not only do the numbers get bigger and bigger out from 0 but the numbers correspond to how whiny the data are.0346

How much they correspond to a line.0361

It is not really about having more dots but it is about how much do all those dots fit to a line.0364

That is what we often call collect fitting the data to a regression line.0373

We want to see is it a good fit? Is it a bad fit?0378

Correlation coefficient gives us the strength of that it is really strong fit or is it very week and loose.0381

The actual maximum for a correlation coefficient is 1 and the minimum -1.0390

That is as far as it will go.0398

You cannot have a correlation of like 1.1.0400

We will talk a little bit about y.0407

Here what you see is that it might have the same number of points of all of these, but it is just that there is very, very little variation from the line. 0409

There is not a lot of variation out from the line, whereas coming like .8 you could see it is better than .4 but it is not quite as whiny as 1.0.0423

That is one way to just very quickly eyeball correlation coefficient.0435

You can just look at a data and it is elongated a little bit. 0440

Maybe it is .4 but if it looks like tighter eclipse we will use .8.0445

If it looks very close to a line perhaps it is close to 1.0453

I want you to notice something.0466

Correlation coefficient, other than caring about positive and negative slope, it does not otherwise care very much about slope.0467

For instance, look at all of the situations, these are all lines.0477

They are all very lined, they are maximum lined.0482

Notice that these lines have positive slope but they all have the coefficient correlation of 1.0486

It does not matter whether x changes y changes very quickly or as x changes 1 y changes very slowly.0497

A slope does not matter, except for just the positive or negative part.0507

The same thing with the negative slopes, even though the slopes are all different they all have a correlation coefficient of 1.0514

There is an exception to this rule and it is this line right here, the perfect horizontal line.0527

Let us think about what the equation for the regular horizontal line is.0533

In a regular horizontal line it does not matter what x is y is always the same. 0539

Let us say here like y=3 that would be like a horizontal line or y=-2 or y=.1.0547

Those are all example of horizontal lines.0556

Let us think about in the case of a horizontal line.0561

It is a perfect prediction because we know where the x is.0564

You could tell me whatever x you want. 0570

I can exactly tell you the y because y is always negative. 0572

y in this case is 3.0577

It is perfect prediction and it is perfect lining this but the correlation coefficient is 0.0578

We will try to figure out y as the horizontal line as we figure out the formula for correlation coefficient 0589

and that hopefully that will become more clear.0599

There are many, many ways in which data can have seemingly no linear pattern 0606

or very weak linear pattern because that is what the correlation coefficients tell us.0613

If you see our data have a 0 as its correlation coefficient do we know that it looks just like a cloud?0618

No, in fact it can look like anyone of these crazy shapes down here.0627

All of these distributions, all of the scatter plots have a very, very weak correlation because remember correlation just means how whiny is it.0634

This one is whiny.0642

Even though some of these are very, very regular shapes correlation coefficient cannot tell you that this has an interesting shape.0647

All it tells you is whether it coheres to that regression line or not.0656

Although these are very interesting set of data for instance here there is a certain 4 rough cluster and even though we could see and eyeball it, 0661

The correlation coefficient would not tell us that.0672

Or in this case, this sort of our data set but even here the correlation coefficient would not tell us that either.0675

Are all of these data the correlation coefficient is very close to 0.0683

I want you to see there are many ways in which you can have a correlation coefficient of 1 or -1.0689

There are many ways in which you can have a coefficient of 0.0696

Just because we get the correlation coefficient does not mean we can see the shape of the distribution.0703

That is often useful to do a scatter plot anyway even for ourselves just so that we know what the numbers are probably going to be describing. 0709

Let us say we have this graph and this shows us this nice correlation. 0721

It was probably pretty high like r=.8.0728

It is closer to 1 than 0 but not quite 1.0736

This is a pretty good correlation and you might have two variables here.0740

For instance, perhaps this gives us the z scores for some variable like we are looking at twins and then we want to know does the intelligence of one twin, 0748

does the IQ of one twin helps us predict the IQ of the other twin?0759

Maybe it is true. 0765

Maybe that does seem to be the case.0767

Here we might put something like the intelligence of twin 1 on this axis and then we will put the intelligence of twin 2 on the z score from their IQ score.0771

We will put that on the y-axis.0783

When we have the scatter plot it is very important that we could toggle between the 3’s, the individual little dots and the forest, the big overall pattern.0786

When we will we look at correlation coefficients we are looking back.0801

We are sort of getting a bird’s eye view and looking very far away and trying to see the overall pattern and that is the forest.0804

It is really important to remember what are my trees?0816

What are my cases?0820

It is important to remember what this dot mean.0822

That is what I mean by the trees like you want to remember what are your cases?0826

What are your variables?0832

That is always step one of looking at a scatter plot.0834

In this case, it is not that each of these dots represents just one twin it is these dots represent a set of twins, a pair of twins.0838

This represents both twin 1 who is a little bit below average and twin 2 was actually a little bit above average.0848

Let us pick out another one.0862

Let us say this one.0866

This twin has a little bit above average and guess what, so is their twin.0868

Their twin is also little bit above average.0878

Each of these dots actually represents 2 people in this case, a set of twins.0881

You want to be able to switch your perspective and to zoom in and see the trees but also zoom out and see the forest 0888

and try to estimate things like correlation coefficient or even try to estimate the regression line and try to eyeball where that might be.0896

Okay, now let us get to the business of calculating r.0909

You could think of the correlation coefficient as roughly that average product of z scores for x and y. 0913

Let us recap a little bit what the z scores are.0922

z scores are just giving you how many standard deviations away you are but we do not want to know it in terms of the raw numbers.0927

We want to know it in terms of standard deviation.0936

We do not want to know, like how many feet away, but we want to know how many standard deviations away.0941

We could think of the standard deviation as jumps away from the mean.0947

How many of those jumps away are you?0952

That is the z score.0954

Here is how we calculate r.0957

The average product of z scores for x and y.0958

Let us put the z scores for x and y and multiply them together because we are getting the product.0965

The product is z(x) × z(y) and I’m going to sum them together and then divide by n-1.0971

Later on we will talk more about y and -1 as more frequent.0987

You can roughly see it is about the average and mostly because we are jumping from samples to populations we need to make a little bit of correction.0992

This formula of adding something up and dividing by n is an average and the thing that we are averaging are the product of the 2 z scores. 1005

Now for all of these formulas you can think of these little z scores as you can double-click them and if you double-click what is inside.1017

Each z score let me write this in blue, so each z score is the distance away from the mean, 1030

but not the raw distance and I want it in terms of standard deviation jumps away from the mean.1038

That would just be something like my y - y bar for mean and so that distance divided by the standard deviation.1045

Here I will just use little s and also for z(x) that is just x - x bar.1058

That is the raw distance away from the mean but divided by x standard deviation.1069

I will put a little x to indicate the standard deviation of x’s and a little y there to indicate the standard deviation of the y’s.1077

I’m going to multiply those together and add them up for every single data point that I have.1085

If that is my twin data for every single set of twins that I have.1092

When we divide all of that by n-1 and n is my number of cases. 1098

How many twins how you got?1105

How many sets of twins have you got?1107

If we want to do although it goes without saying this just implicitly have an i that goes from 1 all the way to n 1109

because it is for every single one of my data points that I need to do this.1117

Furthermore, we can double click on each of these little standard deviation.1125

Now how do we find standard deviation?1135

A standard deviation is the square root of the average distance away from the mean.1137

The average distance away. 1146

The square root of average squared distance which is average distance away.1148

S sub y and this is think about the distance we already know how to do distance because we have already done it.1154

Its average squared distance because remember its sum of squares over n-1.1168

It is sum of squared distances because if we just got the sum of the differences then we just get something very close to 0.1179

We want that and we divide the n-1 because that sum of squares is very small so we need to correct for that by going from samples to populations.1193

That is what we do by n-1.1203

Because we want the standard deviation and not the variance we are going to square root this whole thing.1205

Same thing for s(x) it is a same thing except we substitute an x here instead of y.1211

I forgot to put my little sigma notation because I want to do this for every single y.1220

Although it looks sort of complicated if we write the whole thing out 1227

but if we wrote the actual n or double-click diversion of s sub y in there it might look very crazy.1232

What you do have to remember it alternately less is the main idea you want to get out of today and you want to take a moment to think what z score.1242

Once you unpack z score you want to take a moment to think what standard deviation and hopefully you will be able to unlock those things as you go.1256

Then you do not have to remember all of that stuff at once you can just remember them one at a time.1265

Now that you know the formula for correlation coefficient let us talk about the relationship between correlation and slope.1272

We already know that b1 and r have the same sign.1280

If B1 is negative r will be negative.1285

If b1 is positive r will be positive and vice versa.1288

We already know that they have the same sign and because of that they already slant in the correct way.1292

Remember r does not have any thing about y’s and run in it.1300

All it cares about this is how much like a line it is.1305

B1 and r have a very strict relationship where r when you multiply it by the proportion of standard deviation 1309

of all y over the standard deviation of x as long as you multiply r by this and you can almost see rise over run then you get this slope.1321

Let us just think about this in our head and let us say r is 1 it is always 1 then whatever this proportion is that will perfectly get us b1.1335

Also if r is 1 as always 1 these 2 have a very similar standard deviation.1349

The spread of y is very similar to the spread of x then we should have perfect correlation of 1.1357

In that case you would be able to sort of say that makes sense if y is varying in a similar way as x then they should have correlation version of a slope of about 1.1368

If y is changing more slowly than x for every x you only go a tiny bit of y.1385

In that case this number would be smaller than this one and then that would give us less rise more run.1399

Something that looks sort of less slanted.1411

Something like this versus a slope of 1.1415

Something a little more shallow and that make sense less rise more run.1424

On the other side if for every y you go will go a little x then that would look something like this more rise less run.1431

This gives us this perfect relationship between r and b1.1446

Using that information let us try to solve this problem. 1454

Example 1, here are the 3 pizza companies that we have looked at before, Papa John's, Dominoes and Pizza Hut.1458

It says find the correlation between grams of fat and cost.1466

I think these are for whole pizza and let us make this 17.50. 1475

Let us make this $18 and $20 because this is really cheap to have $1.75 pizza.1485

It would be ridiculous to have 100g of fat in one slice of pizza.1492

If you look at the examples provided in the download below we can use the data in order to find correlation coefficient.1498

In order to find correlation coefficient I will break it down into the component pieces and the big component pieces 1513

and the big component pieces I’m going to need are the z scores for x and the z scores for y.1519

I will say that the score for fat and that the z score for cost.1525

Z score for fat and z score for cost.1529

In order to find the z score I would need to put in the difference between this and the average.1541

One thing that might be easier is if we actually just create a column for averages because we are probably going to need this again and again.1549

Let me go ahead and get those averages. 1564

I’m just getting the average cost, as well as average grams of fat.1571

I’m going to color it in a different color so that we know that this is the entirely different thing here.1578

We have that it would be easier for us to find the score for fat.1586

Here we want to get x of fat - the average and probably want to lock that in place and we want to divide that by standard deviation 1591

and the nice thing about Excel is that it already has the function for standard deviation.1620

This one will give us the n -1 version so I can just lock that data down in order to move.1624

I probably want to copy it over to E later so I’m just going to unlock the B part.1645

As long as they in the same column, as long as I stay in column D it will use column B.1652

If I move over to Column E it should use column C.1657

Let us try that.1663

Here we see that the z score is -1, that is 0 and 1 and that makes sense.1664

Your z score is totaled together shared roughly equal 0 because you are getting how many distance away on the positive side.1669

How many distance away on the negative side, and they should balance out if you really have the mean.1677

Let us check this formula yet it is using B3 that it has average that is getting that Standard deviation perfect. 1683

Once I have that I can actually just copy and paste this over here.1692

Here we see now it is using C and this average and getting the standard deviation of this data.1700

We see roughly the negative side as to the positive side.1711

We have these individual z scores, now we need to get the z scores for fat multiplied by the z score for costs.1719

That is real easy, this times this for every single data point or case that we have and we have 3 cases here. 1729

The 3 different brands of pizza.1736

Once we have that instead of the average actually we could just get the average all at once because we could put it in-one formula.1739

We could just sum these together, sum those together, and we want to divide by n -1.1751

In this case, it is 2.1762

If you wanted to put in a formula you could put in counts -1, but I'm just going to put for our purposes 2 here.1765

We get a very, very high correlation where it is very, very close to 1 as cost goes up fat goes up.1774

As cost goes down fat goes down. 1788

They have a very positive correlation and it is very whiny it. 1792

Here it is very closely to the line.1796

Here we could see that this data is very highly correlated.1802

It has a strong correlation.1813

We do not have a lot of points, but apparently they fall very, very close to the line. 1815

Previously, we found that the regression line for this data is this.1827

I believe that in that case, the cost is 17.50 that previously is $18.00 and $20.1834

Previously in the regression we already found this so check that the relationship between r from the previous example and b1.1844

It is asking us is this really true that b1 in this example, and we are not going to do this formula proof but just to see for ourselves.1856

Is b1 really equal the proportion of r times the proportion of the variation from y over the variation from x.1867

Is this relationship really true?1878

While we already know b1 .125 and we already know r.1882

We know r this is .94 and so we know this .94 multiply by s sub y over s(x) does all of this equal .125.1894

Let us see.1915

That is not too hard and then move that up here.1916

We have r over here I'm just going to find s sub y s sub x and multiplied by it.1922

I will just create another column for standard deviation, and let us get the standard deviation for x and the standard deviation for y.1935

Now you know that this r × the standard deviation of y over the standard deviation of x and that is going to be equal to .125.1948

That relationship holds here we have the b1 and r over to this side so we know what these things are.1968

There you have it.1988

We see that the relationship between r and b1 holds.1989

There is sort of a little bit of y for all a lot of run and we know that this line is pretty shallow and that makes sense.1994

This is a pretty shallow slope. 2005

There is little rise over run and because of that is the fraction less than 1.2006

Example 3, the mean score on a math achievement test for community college was 504 with a standard deviation of 112.2018

For the corresponding reading achievement test the mean was 515 and a standard deviation was 160.2026

The correlation coefficient is very high. 2035

Use this information to find the regression line. 2038

Here we see that we have the correlation coefficient, but we but they do not give us the data.2041

Can we still do this?2049

Yes, we can because there is a relationship between the correlation coefficient and the standard deviation.2051

There is a relationship between the correlation coefficient and slope at all and we need to know are the standard deviation in order to find this. 2058

B1 = r × s sub y / s sub x.2066

We actually know s sub y and s sub x and r so we could find b1.2073

Once we know b1 and we have the point of averages.2077

We have point of averages, which is x bar and y bar.2083

In fact, let us say this is x and let us say the reading is y so here we have 504 – 515.2090

We could get the slope and we can have one point of averages and we could find the intercept.2103

Let us go ahead and r is going to be .7 and s sub y which is the reading one is 116.2111

S sub x is 112.2122

We can find b1 and I’m just going to use a little bit of space down here to just do the calculations. 2127

Feel free to do this on your calculator.2134

.7 × 116/112 and that is .725.2137

I have here .725 as my slope.2148

Once I have my slope I could put that into my slope intercept line 4.2154

My y is 515 and I'm looking for the intercept.2160

I add that to .725 × x which is 504.2173

When I go ahead and solve that in here and let me go ahead just solve that in here that is going to be 515 -.725 × 504.2186

I will get 149.6.2194

My b sub 0 = 149.6.2210

We have these two ideas we can now find the regression line.2216

A regression line in order to predict y is going to b sub 0 or the intercept 149.6 + .725 × x and that is our regression line.2221

Here we see that this slope is less than 1 y is more run.2237

More shallow slope and you do not need to have all the points in order to find the regression line.2247

Example number 4, find the correlation coefficient for this set of data and this set of data is provided for you on the download below. 2259

If you go ahead and click on example 4 that data is all there.2269

Previously we looked at the data and we thought this is pretty good, pretty found linear correlation.2275

Let us see if our eyeballing was actually right.2282

I’m just going to move this one over a little bit because we are not going to need that as much.2285

Let me shrink this down a little bit.2296

It always helps me think about I’m trying to find correlation coefficient I know it is the average product of the z scores.2298

I need to find that the z scores.2311

I need to find that the z scores for the student faculty ratio the SFR.2315

I want to find the z score for cost per unit CPU.2323

Let us go ahead and do that.2329

In order to do that it is often helpful if you have the mean and standard deviation. 2331

How do we find the mean and standard deviation somewhere.2335

Here let me just get the means here and move this over by one column just so that I can write mean and standard deviation.2340

Sometimes it will get confused as to like what we are doing and it is often helpful to write these things down.2361

I like to put it in a different color because that helps me know this is not part of my data.2370

Let us get the average mean of all of our data here.2377

The data for the student faculty ratio, as well as the cost per unit.2384

Subtlety that same data and find the standard deviation because we are often going to need that for z score.2391

It is just useful to have it in advance.2400

We have the mean and the standard deviation.2405

Here I’m just going to put a little divider here for now so that I can move this down. 2408

Notice that it gets from row 7 to row 34.2416

Let us find the z scores.2422

Now that we have mean and standard deviation it should be really easy.2424

It is just the difference between my point and my average all divided by standard deviation.2427

I want to lock down that mean and average and as long as it is in the same column it will always use but I do want to use E when I move over.2437

I’m not going to lockdown the B part I’m just locking down the row.2453

I guess z score of -1.556.2458

If my z score calculations and my mean and all that stuff are correct. 2465

I should roughly have z scores that are both positive and negative, and they should roughly balance out.2471

Let us take a look at our data and it seems like half of them are negative and roughly half of them are positive.2481

They should balance out.2489

Once I have that I could actually take all of these guys and drag that over.2491

Let us check one of these formulas here.2499

This one it gives me this point at the deviation or the difference between this point and the mean divided by its standard deviation.2501


Once we have that I know I need to multiply and get the product of these z scores.2513

Z of s(r) × z(CPU).2518

Let us see what we could do here.2528

Here I’m just going to multiply this times this for every single one of my points.2532

Once I get down here and I know I need to find the mean of these points. 2545

I’m going to find but I do not want to use just the formula for mean because that is going to divide by n.2550

We are going to divide by n -1. 2558

When I split it up into adding all of these up.2560

I am going to sum them all up and divide by count instead of counting all of these.2563

I’m just going to use the same points here I’m going to say count all of this and subtract one and put all in my green parentheses.2584

We get a negative slope that is pretty high. 2601

It is you know above .8 and so let us take a look at our data to see if that makes sense to us.2608

We certainly understand y it is negative.2615

It makes sense that r is negative and we did not think it was pretty good. 2619

We did think it was pretty strong and if it does end up being pretty strong .6 or .7.2623

That is correlation coefficient see you next time on