Steps for Calculating r
We will begin by listing the steps to the calculation of the correlation coefficient. The data we are working with are paired data, each pair of which will be denoted by (xi,yi).
1.
We begin with a few preliminary calculations. The quantities from these calculations will be used in subsequent steps of our calculation of r:
Calculate x̄, the mean of all of the first coordinates of the data xi.
Calculate ȳ, the mean of all of the second coordinates of the data yi.
Calculate s x the sample standard deviation of all of the first coordinates of the data xi.
Calculate s y the sample standard deviation of all of the second coordinates of the data yi.
2.
Use the formula (zx)i = (xi – x̄) / s xand calculate a standardized value for each xi.
3.
Use the formula (zy)i = (yi – ȳ) / s y and calculate a standardized value for each yi.
4.
Multiply corresponding standardized values: (zx)i(zy)i
5.
Add the products from the last step together.
6.
Divide the sum from the previous step by n – 1, where n is the total number of points in our set of paired data. The result of all of this is the correlation coefficient r.
hope this helps.