How to calculate a correlation coefficient
Pearson's correlation coefficient () quantifies the strength and direction of the linear relationship between two continuous variables. Use this method when you have paired quantitative data and need to measure linear association, but not causation or non-linear trends.
The setup
Identify your paired dataset consisting of pairs of observations, . Ensure both variables are continuous and quantitatively measured. You will need the sample means for both variables, denoted as and .
The steps
- Calculate the sample means and .
- Compute the deviations from the mean for every data point: and .
- Calculate the sum of products of the deviations: .
- Calculate the sum of squares for both variables: and .
- Compute the correlation coefficient using the formula:
Checking the result
Verify that your result falls within the bounds . An value near indicates a strong positive linear correlation, a value near indicates a strong negative linear correlation, and a value near indicates a weak or non-existent linear correlation.
Common errors
A frequent error is breaking the pairing of data during sorting or calculation. Another is interpreting a high correlation coefficient as proof of causation. Finally, computing Pearson's for data that has a clear non-linear relationship (e.g., quadratic) will yield a misleading near-zero value.
Worked example
Calculate the correlation coefficient for the paired data: and .
- Calculate : .
- Calculate means: . .
- Calculate deviations : .
- Calculate deviations : .
- Calculate : .
- Calculate : .
- Calculate : .
- Compute : The correlation coefficient is approximately .
FAQ
Run your own problem
References: OpenStax Introductory Statistics, Chapter 12: Linear Regression and Correlation · Moore, McCabe, and Craig: Introduction to the Practice of Statistics
See also