Linear Regression Calculator

Slope and intercept form calculator using least square fitting — find the best-fit line through any set of data points and predict values with the linear regression equation.

Enter values and click Calculate

Slope and intercept form calculator using least square fitting

Find the best-fit line through any set of data points and predict values with the linear regression equation.

Formula

y = mx + b \quad \text{where} \quad m = \frac{n\sum xy - \sum x \sum y}{n\sum x^2 - (\sum x)^2}, \quad b = \bar{y} - m\bar{x}

How to Use?

  1. Enter X and Y values as comma‑separated lists (e.g., 1,2,3 and 2,4,6).
  2. Optionally, provide an X value to predict the corresponding Y.
  3. The calculator will show the regression equation, slope, intercept, Pearson r, R², and predicted Y.

Worked Examples

Example: Linear fit for (1,2), (2,4), (3,6)

Given:inputs
xValuesInput:1,2,3
yValuesInput:2,4,6
predictX:4
Result:calculated
slope:2
intercept:0
equation:y = 2x + 0
predictedY:8

Least Squares Method

The line of best fit is calculated by minimizing the sum of squared residuals between observed and predicted values.

Interpreting R²

R² indicates how well the regression line fits the data. A value close to 1 means the model explains most of the variability.

Table: Example Linear Regression Data

XY
12.1
23.9
36.2
47.8
510.1

FAQs

What is linear regression?

A statistical method to model the relationship between a dependent variable and one or more independent variables using a linear equation.

What does R² tell me?

R² measures how well the regression line fits the data; higher values indicate a better fit.