Linear Regression Calculator
Linear regression finds the straight line that best fits a cloud of paired data points. Enter X and Y values and this calculator computes the least-squares line, its equation, and the correlation statistics that tell you how trustworthy the fit is.
Results
Formula
How to use this calculator
- Enter the X values, then the Y values in the matching order.
- Make sure both lists have the same number of entries.
- Press Calculate and read the equation plus r and R².
Worked example
X: 1, 2, 3, 4, 5 and Y: 2, 4, 5, 4, 5.
- Means: x̄ = 3, ȳ = 4.
- Slope: 6 ÷ 10 = 0.6.
- Intercept: 4 − 0.6 × 3 = 2.2.
- r ≈ 0.775, so R² ≈ 0.60 — about 60% of Y’s variation is explained.
Result: The regression line is y = 0.6x + 2.2.
Frequently asked questions
What does R² actually tell me?
R² is the share of the variation in Y accounted for by the line: 0.60 means 60% explained, 40% left to other factors and noise. Higher is a stronger linear fit — not proof of causation.
Can I use the equation to predict new values?
Yes, within (and cautiously near) the range of your X data. Extrapolating far beyond the observed range is unreliable because the linear pattern may not continue.
What if my data is curved?
A low R² with a visible curve in a scatter plot suggests a non-linear model (exponential, quadratic) fits better than a straight line.
Related calculators
Covariance Calculator
Calculate sample and population covariance between two data sets, plus the Pearson correlation coefficient.
MathStandard Deviation Calculator
Calculate standard deviation (population and sample), variance and mean for any data set.
MathMean Calculator
Find the mean (average) of any list of numbers, plus the sum, count, minimum, maximum and range.
MathP-Value Calculator
Convert a z-score or t-statistic into a p-value for left, right or two-tailed tests.