lines of regression calculator

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.

Must contain the same number of values as Y.
Each Y corresponds to the X value in the same position.

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 = ȳ - byx
  • X on Y: x = axy + bxyy, where axy = x̄ - bxyȳ

How to use this regression calculator

  1. Paste all X values into the X field.
  2. Paste all corresponding Y values into the Y field.
  3. Click Calculate Regression Lines.
  4. Review equations, correlation coefficient, and optional predictions.
Tip: If all X values are identical, Y-on-X is undefined (division by zero in Sxx). If all Y values are identical, X-on-Y is undefined (division by zero in Syy).

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 . 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.

🔗 Related Calculators