If you understand the concept of correlation as being an association between two variables,
and how it should NOT be confused with causation, it’s now time to learn to calculate Pearson’s
r, also known as the correlation coefficient.
That’s what this video will focus on: how to calculate Pearson’s r correlation coefficient.
Once you’ve calculated Pearson’s r, it is just one more simple step to calculate
Pearson’s r squared (or the coefficient of determination).
For our example, we will test the hypothesis that the number of hours a student studies
for a final exam is positively related to the score they will receive on the exam.
You’ll remember that Pearson’s r is used when you are testing to see if there is a
relationship between two continuous level variables, which is what we have here: Number
of hours studying, and score on the exam.
You can calculate a mean on both of these variables.
To determine if a relationship exists between hours of study and exam score, you would calculate
Pearson’s r because it measures the linear relationship between two continuous level
variables: they could be gathering interval or ratio level data.
For the formula, you need to have all the scores in the data set—that means two sets
of scores for each “case.”
With this, you can calculate the mean of both continuous level variables, which would be
x and y, and the total number of Observations so you can calculate degrees of freedom.
You will need to establish your alpha level, which is usually .05, and you’ll need to
determine if your hypothesis necessitates a one-tailed or two-tailed test.
You’ll recall that a one-tailed test is when we hypothesize that the difference between
the two scores is directional, and a two-tailed test is when we are merely testing to see
if there is a difference or, in this case, a correlation, without specifying which direction
the correlation will be—it is non-directional.
For our example, we are hypothesizing that there is a positive correlation between hours
of study and exam score, so we would be using a one-tailed test.
And, of course, you’ll need a table of critical r values so you can compare your calculated
r with the critical r to determine whether you should accept or reject the null hypothesis.
That takes us to the formula for Pearson’s r.
Notice that you really only need to know the scores for each group and the means for each
group.
And, degrees of freedom, which you need to look up the critical r value on a table to
determine if your findings are, indeed, significant, is the number of observations minus two.
Back to our hypothesis that there is a correlation between the number of hours spent studying
for an exam and the resulting score on the final examination.
You gather data from seven students on the hours they studied which we will call the
x variable, and their exam scores—the y variable.
So the n for each variable is 7.
Even though you have 14 observations (7 for the x variable and 7 for the y variable),
you really have 7 sets of paired scores, so N = 7.
Again, you’ll need to know this to calculate degrees of freedom.
You can calculate the mean for each set of numbers, so for hours studied, 2+4+5+7+3+1+6
= 28, divided by 7 (the n for the x variable) = 4
Do the same thing for exam scores, the y variable, and you’ll come up with 62 as the mean.
So, the mean of x is 4 and the mean of y is 62.
So, now we have all we need to start doing our calculations.
Look at the numerator of the formula: the sum of each score in the group minus the group
mean.
You do this for the scores on the x variable (number of hours) and the y variable (score
on the exam).
So, starting with x: 2 minus the mean of x, which is 4, equals -2.
Then, 4 minus the mean of x (4), equals 0.
Continue doing this for all the scores in the x group.
Then do the same for y.
41 minus the mean of y, which is 62 equals -21.
Then, 63 minus the mean of y (62), equals 1, and so on.
The formula tells us to multiply these two scores together, so you have -2 times -21,
or 42.
Then 0 times 1 is 0.
And so on.
Sigma tells us to add all of these products together, which is 236.
That means that 236 is what goes in the numerator of this formula.
Now onto the denominator, which tells you to square the result of each score minus the
group mean.
Go back to “x” column.
-2 squared is 4.
0 squared is 0, and the rest of the x scores.
Sigma tells you to add all of these numbers together and we get 28.
We do the same for the y scores: -21 squared is 441, 1 squared is 1, and so on.
Add them all together and you get …2408.
Now you have all the data for the denominator. …and it’s time to finish off the formula.
Just a review of the formula and what we’ve calculated.
First, we have the sum of each score on the x variable minus the mean for the x group,
multiplied by the sum of each score on the y variable minus the y variable’s group
mean, so 236.
You’ve calculated the sum of each score minus the mean, squared for each of the two
variables, x and y.
Plugging that into the equation is 236 divided by the product of the square roots of 28 and
2408, which is 5.29 x 49.07, or 259.67.
Reducing that down becomes 236 divided by 259.67.
Finally, that tells you that r = .9089—we’ll round it to .91.
What this tells you is that, as .91 is close to the positive 1.0, it appears to be a fairly
strong positive correlation.
It appears, then, that the number of hours spent studying for an exam is positively correlated,
or connected, to the exam score.
But now we have to take the next step to compare our calculated r of .91 to determine whether
we should accept or reject the null hypothesis.
For that we will need our critical value table for Pearson’s r.
First, we need to calculate degrees of freedom, which is N – 2.
Remember that we had 7 “cases,” or 7sets of scores.
7-2 = 5 degrees of freedom.
You’ll recall that degrees of freedom refers to how many ways our data could be combined
and still produce the same values for a statistic.
Assuming an alpha of 0.05 for a one-tailed test, meaning that we are only willing to
accept a 5% chance of error—we want to be 95% confident, we can look for critical r.
Find where 5 degrees of freedom intersect with a one-tailed test at .05.
That’s 0.669—our critical r value.
We use that in our decision to reject or accept the null hypothesis.
Remember that if our calculated statistic is equal to or higher than the critical value,
you would reject the null hypothesis, while if it is less than the critical value, you
would accept the null hypothesis.
In this case, .91 is greater than the 0.669 critical value, meaning we reject the null
in favor of the alternative hypothesis.
We would conclude, then, that the number of hours studying for an exam does positively
correlate with scores on the exam.
We talked earlier about r squared which is… r squared.
This refers to what percent of the independent variable (x, or number of hours studying)
"explains" what happened to the dependent variable—y, or score on the exam.
In this case, it looks this positive correlation explains about 82% of the variation.
Remember that the closer r2 is to 1.0, the better x explains y.
Processing Time!
What do you need to calculate to plug into the Pearson’s r formula?
Really, you need the raw data—the actual scores—for each variable so you can to calculate
the means for the x and the y variable.
Once you do that, if you can add, subtract, multiply, divide, square, and square root,
you can calculate the r value.
What does an r2 of .79 mean?
Remember that r2 is looking to estimate the percentage of the independent variable that
"explains" what happened to the dependent variable in a linear model.
An r2 of0.00 (0%) indicates that the model explains none of the variability of the response
data around its mean, while an r squared of1.00 (100% means that the model explains all the
variability of the response data around its mean.
So an r squared of .79 means that about 79% of the variation can be explained—which
is a pretty high percentage.
So, if we calculated an r squared of .79 for our hypothesis that hours of studying is positively
correlated with exam scores, well, then, you should probably get started logging those
study hours so you can ace your exam!