How to calculate pearson correlation
![](https://www.thetechedvocate.org/wp-content/uploads/2023/10/pearsoncorrelation_python_banner.png)
Pearson correlation, also known as the Pearson product-moment correlation coefficient, is a statistical measure used to determine the strength and direction of a linear association between two variables. It is denoted by the symbol ‘r’ and ranges from -1 to 1. A value of -1 implies a strong negative relationship, 0 indicates no correlation, and a value of 1 suggests a strong positive relationship between the two variables. In this article, we will provide a step-by-step guide on how to calculate the Pearson correlation coefficient.
Step 1: Gather Your Data
Collect paired data points (x,y) for the two variables you want to analyze. The data sets should be of equal length (i.e., have the same number of data points).
Step 2: Calculate the Means
Compute the mean (average) value of each variable using the formula:
Mean (X) = ΣX / n
Mean (Y) = ΣY / n
where Σ represents the sum of all data points and n denotes the total number of data points in each variable.
Step 3: Compute Deviations from Means
Find the deviations from mean for each data point in both X and Y series:
xi – Mean(X)
yi – Mean(Y)
Step 4: Multiply Deviations and Sum Them Up
Now, multiply each X deviation with its corresponding Y deviation and compute their sum:
Σ [(xi – Mean(X)) * (yi – Mean(Y))]
Step 5: Calculate Variance and Standard Deviation
Next, calculate variance for both variables by squaring deviations from their means and obtaining their sums:
Var(X) = Σ [(xi – Mean(X))^2]
Var(Y) = Σ [(yi – Mean(Y))^2]
Compute standard deviation using square root of variance:
SD(X) = √Var(X)
SD(Y) = √Var(Y)
Step 6: Calculate the Pearson Correlation Coefficient
Finally, determine the Pearson correlation coefficient using the following formula:
r = [Σ[(xi – Mean(X)) * (yi – Mean(Y))]] / [(n * SD(X) * SD(Y))]
where n represents the total number of data points.
Conclusion
The Pearson correlation coefficient allows you to determine the strength and direction of a linear relationship between two variables. By following these six steps, you can easily calculate this important statistical measure using raw data. To further assist with the calculations, consider using tools such as Microsoft Excel or online calculators that provide built-in functions for computing correlation coefficients.