Free Linear Regression Calculator
Enter your data points below (one pair per line), click calculate, and instantly get the least-squares regression line, correlation coefficient, R², and optional prediction.
What Is Linear Regression?
Linear regression is a statistical method used to model the relationship between one independent variable x and one dependent variable y. In plain terms, it finds the straight line that best fits your data, then uses that line to explain trends and make predictions.
This online linear regression calculator uses the classic least squares method. It picks the line that minimizes the total squared difference between observed values and predicted values.
How to Use This Online Linear Regression Calculator
Step-by-step
- Enter at least two data points in the form x, y (one per line).
- Click Calculate Regression.
- Review the slope, intercept, correlation, and R² values.
- Optionally enter a future x value to estimate y.
Input tips
- Works with decimals, negatives, and whole numbers.
- Each line must contain exactly two numeric values.
- If all x values are identical, a regression line cannot be computed.
Understanding the Results
Regression Equation
The tool returns the equation:
y = a + bx
- b = slope (how much y changes when x increases by 1)
- a = intercept (the predicted y value when x = 0)
Correlation Coefficient (r)
The correlation coefficient ranges from -1 to +1:
- +1 means a perfect positive linear relationship
- -1 means a perfect negative linear relationship
- 0 means no linear relationship
Coefficient of Determination (R²)
R² explains how much of the variation in y is accounted for by x. For example, an R² of 0.84 means 84% of the variability in y is explained by the fitted line.
Practical Use Cases
- Business: estimate sales from ad spend
- Finance: approximate trend relationships between variables
- Science: model dose-response or growth relationships
- Education: learn and verify regression homework quickly
Formula Used by This Calculator
Given n paired points (xᵢ, yᵢ):
- Slope (b): (nΣxy − ΣxΣy) / (nΣx² − (Σx)²)
- Intercept (a): ȳ − b x̄
- Correlation (r): (nΣxy − ΣxΣy) / √[(nΣx² − (Σx)²)(nΣy² − (Σy)²)]
- R²: r²
These are standard statistical formulas for simple linear regression and Pearson correlation.
Important Notes and Assumptions
- Linear regression assumes an approximately linear relationship.
- Outliers can strongly affect slope, intercept, and correlation.
- Prediction quality is usually best within the range of observed x values.
- Correlation does not prove causation.
Quick FAQ
Is this calculator free?
Yes. You can run unlimited calculations directly in your browser.
Does it send my data to a server?
No. All computations happen locally in JavaScript on this page.
Can I use decimal and negative numbers?
Absolutely. The parser supports both.
What is a good R² value?
That depends on your field and data noise. Higher values indicate a tighter linear fit, but context always matters.