Correlation & Regression Calculator
Enter paired X and Y values. Calvo calculates Pearson and Spearman correlation, the least-squares regression line with p-values, an ANOVA table, predictions and a scatter plot with the line of best fit.
Correlation & regression calculator
Correlation vs regression
Correlation measures how strongly two variables move together (r from −1 to +1). Regression goes further: it fits the line ŷ = a + bx that predicts Y from X. Correlation does not prove that X causes Y.
Formulas
| Quantity | Formula |
|---|---|
| Pearson r | r = Sxy / √(Sxx Syy), where Sxy = Σ(x − x̄)(y − ŷ̄) |
| Slope | b = Sxy / Sxx |
| Intercept | a = ȳ − b x̄ |
| Coefficient of determination | R² = r² = SSR / SST |
| Test for r | t = r√(n − 2) / √(1 − r²), df = n − 2 |
| Residual standard error | s = √(SSE / (n − 2)) |
| Spearman ρ | Pearson r computed on the ranks of X and Y |
Worked example
X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. Here x̄ = 3, ȳ = 4, Sxy = 6, Sxx = 10, Syy = 6.
Slope b = 6/10 = 0.6, intercept a = 4 − 0.6×3 = 2.2, so ŷ = 2.2 + 0.6x. The correlation is r = 0.7746, R² = 0.60, and the p-value for the slope is 0.1240. With only 5 points, r = 0.77 is not statistically significant at α = 0.05.
How strong is r?
| |r| | Strength |
|---|---|
| 0.00 – 0.19 | Very weak |
| 0.20 – 0.39 | Weak |
| 0.40 – 0.59 | Moderate |
| 0.60 – 0.79 | Strong |
| 0.80 – 1.00 | Very strong |
These are rules of thumb; what counts as strong depends on your field. Always look at the scatter plot as well: outliers and curved patterns can distort r.
FAQ
What is the difference between correlation and regression?
Correlation (r) describes the strength and direction of a linear relationship between two variables. Regression gives an equation to predict one variable from the other.
What does R-squared mean?
R squared is the proportion of the variation in Y that is explained by the regression on X. An R squared of 0.60 means 60 percent of the variation in Y is explained by the line.
What is the difference between Pearson and Spearman correlation?
Pearson measures linear association between the raw values. Spearman works on ranks, so it captures any consistently increasing or decreasing relationship and is less affected by outliers.
Does a high correlation mean X causes Y?
No. Correlation shows association only. A third variable or coincidence can produce a strong correlation without any causal link.
How do I interpret the p-value of the slope?
It tests H0: slope = 0, meaning X has no linear effect on Y. A p-value at or below your significance level (usually 0.05) suggests a real linear relationship.
Is it safe to predict outside my X range?
Predicting far outside the X values you observed (extrapolation) is risky because the relationship may not stay linear. Calvo warns you when you do this.