ToolPatch

One page. One job. Done.

← Back to all tools
Math

Linear Regression Calculator

Fit a best-fit line from point data and compute r and R².

Formula reviewed: 2026-02-14 Math

Linear Regression Calculator fits a straight-line model to paired x and y data. The slope describes the expected change in y for a one-unit increase in x, while the intercept is the predicted y value when x equals zero. Least-squares regression chooses the line that minimizes the sum of squared vertical residuals, where residuals are differences between observed and predicted y values. R-squared describes the share of variation in y explained by the linear model, but it does not prove causation or guarantee that predictions are valid outside the observed range. Regression is useful for trend estimation and calibration, provided the relationship is approximately linear, residual patterns are reasonable, and influential outliers are examined.

Permalink

Input Pattern

Enter values in the left panel, keep units explicit, run the calculation, then copy or share the result. Invalid fields are highlighted immediately.

How to use this tool

  1. Enter the required fields for the linear regression calculator, keeping units, dates, or text format consistent with the form labels.
  2. Confirm sample size, ordering, and distribution assumptions before relying on the calculated result.
  3. Click "Run the tool" and review Point Data, Model for the primary output.
  4. Check the statistical assumptions and sample context before using the result in a report or decision.

Point Data

One point per line: `x,y`

Model

Line: y = 0.900000x + 1.300000

r: 0.900000

R²: 0.810000

Points used: 5

Linear Regression and Straight-Line Models

A Model for Average Change

Linear regression models the relationship between an outcome variable and one or more predictors. In simple linear regression, the model fits a straight line: y = a + bx. The slope b estimates the average change in y for a one-unit increase in x, while the intercept a estimates y when x equals zero.

The fitted line is not usually expected to pass through every point. Instead, it summarizes the central trend in noisy data. The difference between an observed value and the fitted value is called a residual. Regression analysis studies both the line and those residuals.

Least Squares

The most common fitting method is ordinary least squares. It chooses the line that minimizes the sum of squared residuals. Squaring makes positive and negative errors add rather than cancel, and it penalizes large errors strongly. The result is a line with convenient mathematical properties when assumptions are reasonable.

Least squares is sensitive to outliers. A single extreme point can pull the slope or intercept noticeably, especially in small datasets. That does not make regression flawed; it means the data should be plotted and checked before the coefficients are treated as meaningful.

Interpretation and Assumptions

A regression slope is an association unless the study design supports a causal claim. If advertising spend and sales move together, the slope does not automatically prove the spend caused the sales. Confounding variables, reverse causality, seasonality, and selection effects can all create misleading relationships.

Common assumptions include linearity, independent errors, roughly constant error variance, and residuals that behave well enough for inference. Prediction can still be useful when some assumptions are imperfect, but confidence intervals, p-values, and extrapolation become riskier.

Prediction Limits

Regression is safest inside the range of observed data. Extrapolating far beyond that range assumes the same linear pattern continues, which may be false. Many real systems are linear only over a limited interval before saturation, thresholds, or nonlinear dynamics appear.

A good regression workflow includes a scatter plot, residual plot, coefficient interpretation, uncertainty estimates, and a clear statement of scope. The line is a useful simplification, not a replacement for domain knowledge.

How to interpret the result

Confidence and limitations

Formula References

Assumptions

Explore more versions

Tailored guides for specific audiences, regions, and scenarios.

Related tools and workflows