Linear Regression Calculator

Find a least-squares line of best fit, slope, y-intercept, correlation coefficient, R-squared, and predicted values from paired data.

Linear regression analysis
Enter at least two x,y pairs separated by semicolons or line breaks.

About linear regression

Simple linear regression describes a straight-line relationship between one explanatory variable x and one response variable y. The fitted equation takes the form y = mx + b, where m is the slope and b is the y-intercept. The calculator uses ordinary least squares to choose the line that minimizes the sum of squared vertical residuals between observed y values and the values predicted by the line. The slope measures the estimated change in y associated with a one-unit increase in x. A positive slope indicates that larger x values tend to accompany larger y values, while a negative slope indicates the opposite direction. The intercept is the fitted y value when x equals zero. It can be meaningful when zero is within the practical range of the data, but extrapolating the intercept far beyond observed x values may not make scientific sense. The Pearson correlation coefficient r summarizes the direction and strength of the linear association. It ranges from -1 to 1. Values near 1 indicate a strong positive linear pattern, values near -1 indicate a strong negative pattern, and values near zero indicate little linear association. Correlation is unitless and unchanged if either variable is rescaled by a positive constant. A high correlation does not prove that changes in x cause changes in y. R-squared is the square of the correlation coefficient in simple linear regression. It gives the proportion of variation in the observed response explained by the fitted straight line. An R-squared of 0.80 means that 80 percent of the sample variation in y is accounted for by its linear relationship with x. It does not guarantee unbiased predictions, a correct causal model, or a good fit outside the observed data range. Predictions use the fitted equation by substituting a requested x value. Predictions close to the center of the observed x range are generally safer than extrapolations beyond the smallest or largest x. A complete statistical analysis would also quantify uncertainty with confidence and prediction intervals. This calculator reports the deterministic least-squares estimates so you can quickly inspect the main relationship. Before interpreting a regression, plot the data and examine residuals. The standard model assumes a linear mean relationship, independent observations, roughly constant residual variance, and errors suitable for the intended inference. Outliers can strongly change the slope and correlation. Keep paired observations aligned, use consistent units, and avoid inserting duplicate points unless they represent genuine repeated measurements.

Linear regression examples

Data pointsFitted resultInterpretation
(1,2), (2,4), (3,5)y = 1.5x + 0.666667Strong positive relationship with R-squared about 0.964.
(1,9), (2,7), (3,5), (4,3)y = -2x + 11A perfect negative linear relationship with r equal to -1.
(0,1), (2,5), (4,9)y = 2x + 1Each two-unit increase in x corresponds to four additional y units.

How to use the linear regression calculator

  1. Enter each paired observation as x,y and separate pairs with semicolons or line breaks.
  2. Optionally enter an x value for which you want to predict y.
  3. Click Calculate Regression to fit the least-squares line.
  4. Review the equation, slope, intercept, correlation, R-squared, and optional prediction.

Linear regression FAQ

What does the slope mean?

The slope is the estimated change in y for each one-unit increase in x. Its sign gives the direction of the fitted linear relationship.

What is a good R-squared value?

There is no universal cutoff because acceptable fit depends on the field and purpose. Compare it with domain expectations and inspect residual patterns rather than relying on R-squared alone.

Can regression prove causation?

No. A fitted relationship can reflect confounding, selection, coincidence, or reverse causality, so causal claims require appropriate study design and assumptions.

Why should I avoid extrapolation?

The relationship may change outside the observed x range. Predictions far beyond the data therefore rely on an unverified continuation of the fitted line.

How are outliers handled?

Ordinary least squares includes every entered point and squares its residual. As a result, an extreme point can substantially influence the fitted slope and intercept.