Using the Linear Regression & Correlation Calculator
Put corresponding X and Y observations in the same order, with equal list lengths. Inspect the scatter and residual plots before relying on a prediction: a curve or changing residual spread can make a straight-line summary misleading.
Worked example
Use the example inputs below to reproduce this result. These are the form's starting values, not recommended targets. Changing your inputs updates your result above; this worked example stays fixed for comparison. Results are rounded for display.
Example inputs
- X observations
- 1, 2, 3, 4, 5
- Y observations in matching order
- 2, 4, 5, 4, 5
- X value to predict
- 6
Example result
- Slope
- 0.6
- Intercept
- 2.2
- Pearson r
- 0.77459667
- R-squared
- 0.6
- Predicted Y at supplied X
- 5.8
- Residual standard error
- 0.89442719
- Residuals in input order
- Row 1: -0.80000000 Row 2: 0.60000000 Row 3: 1.0000000 Row 4: -0.60000000 Row 5: -0.20000000
Method and assumptions
Ordinary least squares with an intercept: slope = centered cross-product / centered X sum of squares; intercept = mean(Y) − slope × mean(X). Pearson r uses centered sums; R² = r² when Y varies. Residual standard error uses n−2 degrees of freedom. Constant X is rejected; constant Y has a defined fitted line but undefined correlation/R². Extrapolation can be misleading and correlation does not establish causation.
Reference: itl.nist.gov — method and further reading
Check what the data represents
A statistical result is only meaningful in relation to the observations and assumptions behind it. Keep track of whether values describe a whole population or a sample, whether observations are independent, and which distribution the method uses. More decimal places cannot compensate for a sample that does not represent the question you are trying to answer.
Common question
Can a high correlation show that X causes Y?
No. Correlation measures a linear association in the observed sample. A common cause, selection bias or time trend can create association without a causal effect. The regression output does not replace a defensible study design or assess confounding.