# Linear Regression Calculator

Free linear regression calculator. Find the best-fit line equation (y = mx + b), R-squared, and correlation coefficient from summary statistics.

## What this calculates

Calculate the linear regression equation using the least squares method. Enter your summary statistics to find the slope, y-intercept, R-squared value, and make predictions.

## Inputs

- **Number of Data Points (n)** — min 3 — Total number of (x, y) data points.
- **Sum of X (Σx)** — Sum of all x values.
- **Sum of Y (Σy)** — Sum of all y values.
- **Sum of XY (Σxy)** — Sum of the products of each x and y pair.
- **Sum of X² (Σx²)** — Sum of each x value squared.
- **Sum of Y² (Σy²)** — Sum of each y value squared.
- **Predict Y for X =** — Enter an x value to predict the corresponding y value.

## Outputs

- **Slope (m)** — The slope of the regression line.
- **Y-Intercept (b)** — The y-intercept of the regression line.
- **Regression Equation** — formatted as text — The linear regression equation y = mx + b.
- **R² (Coefficient of Determination)** — Proportion of variance in y explained by x.
- **Correlation Coefficient (r)** — Pearson correlation coefficient.
- **Predicted Y** — The predicted y value for the given x.

## Details

Linear regression finds the best-fit straight line through a set of data points.

Formulas

- Slope: m = (nΣxy - ΣxΣy) / (nΣx² - (Σx)²)

- Intercept: b = (Σy - mΣx) / n

- R² measures how well the line fits the data (0 = no fit, 1 = perfect fit)

Interpretation

- m > 0: positive relationship (y increases as x increases)

- m < 0: negative relationship

- R² > 0.7: strong fit

- R² < 0.3: weak fit

## Frequently Asked Questions

**Q: What is R-squared?**

A: R-squared (R²) is the coefficient of determination. It represents the proportion of variance in the dependent variable (y) that is explained by the independent variable (x). R² = 1 means a perfect fit; R² = 0 means x explains none of the variation in y.

**Q: How do I get the summary statistics for this calculator?**

A: You need: the number of data points (n), the sum of x values (Σx), the sum of y values (Σy), the sum of x*y products (Σxy), the sum of x² values (Σx²), and the sum of y² values (Σy²). These can be computed from your raw data in a spreadsheet.

**Q: When should I NOT use linear regression?**

A: Do not use linear regression when: (1) the relationship is clearly non-linear, (2) there are significant outliers, (3) the residuals are not normally distributed, or (4) the observations are not independent. Check a scatter plot first.

---

Source: https://vastcalc.com/calculators/statistics/linear-regression
Category: Statistics
Last updated: 2026-04-21
