Calculate Both Regression Lines (Y on X and X on Y)
Enter paired data values below. You can separate numbers with commas, spaces, or new lines.
What are lines of regression?
When two variables are related, regression lines help you describe and predict that relationship. With paired observations (x, y), you can compute:
- Regression of Y on X: best for predicting Y when X is known.
- Regression of X on Y: best for predicting X when Y is known.
These two lines are generally different unless the correlation is perfect. Both pass through the point (x̄, ȳ), the means of X and Y.
Formulas used by this calculator
Step 1: Compute centered sums
- Sxx = Σ(x - x̄)2
- Syy = Σ(y - ȳ)2
- Sxy = Σ(x - x̄)(y - ȳ)
Step 2: Regression coefficients
- byx = Sxy / Sxx (slope of Y on X)
- bxy = Sxy / Syy (slope of X on Y)
Step 3: Equations
- Y on X: y = ayx + byxx, where ayx = ȳ - byxx̄
- X on Y: x = axy + bxyy, where axy = x̄ - bxyȳ
How to use this regression calculator
- Paste all X values into the X field.
- Paste all corresponding Y values into the Y field.
- Click Calculate Regression Lines.
- Review equations, correlation coefficient, and optional predictions.
Interpreting your results
Slope meaning
A positive slope means both variables tend to move together. A negative slope means one tends to decrease when the other increases. A slope near zero suggests weak linear association.
Correlation (r) and explained variation (R²)
The calculator also reports the Pearson correlation coefficient r and R². Values of |r| close to 1 indicate a stronger linear relationship. R² is the squared correlation and is often interpreted as the proportion of linear variation explained.
Common mistakes to avoid
- Using unmatched lists (different number of X and Y values).
- Mixing decimal separators and text symbols in numeric lists.
- Using Y-on-X to predict X (or vice versa) without checking the appropriate regression line.
- Assuming correlation means causation.
Quick example
Try entering X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 6. The calculator will output both regression equations and let you make predictions using each line appropriately.
FAQ
Do both regression lines always intersect?
Yes. They intersect at the mean point (x̄, ȳ).
Can I use this for nonlinear data?
This tool is designed for linear regression lines. For curved relationships, use polynomial or nonlinear models.
What is the minimum number of points required?
At least two paired observations are required, but more points usually give more stable estimates.