Linear Regression Calculator

Paste paired data, fit a least-squares line, inspect r and R², and estimate y for a chosen x without building the formulas yourself.

How It Works

Formula

b=(xixˉ)(yiyˉ)(xixˉ)2b = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2}

a=yˉbxˉa = \bar{y} - b\bar{x}

r=(xixˉ)(yiyˉ)(xixˉ)2(yiyˉ)2r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}}

R2=r2R^2 = r^2

Variables, symbols and units

xix_i

Observed x value in pair i

yiy_i

Observed y value in pair i

xˉ\bar{x}

Mean of the x values

yˉ\bar{y}

Mean of the y values

bb

Least-squares slope of the fitted line

aa

Least-squares intercept of the fitted line

rr

Correlation coefficient for the linear association

R2R^2

Share of y variation explained by the line
Calculation method explained

Linear regression fits one straight line to your paired data. The slope shows how much y tends to change when x increases by 1, and the intercept is the line value when x = 0.

Use this tool when you already have paired observations, such as study time vs quiz score or concentration vs response. A larger absolute r means a tighter linear pattern in the entered points, while tells you how much of the variation in y the line accounts for. A useful line can still have a weak fit, and a strong fit still does not prove causation.

Frequently Asked Questions

What does the slope mean here?
The slope **b** is the line change in **y** for each 1-unit increase in **x**. A positive slope means the fitted line rises; a negative slope means it falls.
What does R² tell me?
R² is the share of variation in **y** explained by the fitted line. Values near 1 mean the line tracks the entered points closely; values near 0 mean it explains little of the variation.
Does a high correlation prove causation?
No. Regression describes an association in the data you entered. It cannot show whether one variable causes the other.
Should I trust predictions far outside my data?
Be careful. The predicted y is only the line value for the x you typed. Estimates get less defensible when you predict well beyond the observed x range.

Related Calculators

All calculators

Ready to Calculate?

Free calculators.