Regression Calculator
Perform linear regression analysis with slope, intercept, and R-squared.
By Konstantin Iakovlev · Updated September 2026 · Source: Khan Academy
R-Squared
0.9985
Predicted Y
11.89
Regression Results
| Slope | 1.9700 |
| Intercept | 0.0700 |
| Equation | y = 1.97x + 0.07 |
| r | 0.9992 |
| R-Squared | 0.9985 |
Use the Regression Calculator above to calculate your results. Enter your values and see instant results — all calculations run in your browser.
Disclaimer: This calculator is for informational purposes only. Results are estimates based on the information you provide and the assumptions described on this page.
How It Works
Linear regression turns a scatter of paired observations into a single line you can use to forecast and compare. Feed in your data points and the calculator returns the fitted equation along with the statistics that tell you how trustworthy it is. Whether you are weighing marketing spend against sales or tracking how interest rates move alongside loan defaults, the fitted line puts a number on how one variable moves with the other.
The fit comes from the least squares method, which positions the line so the sum of the squared vertical distances between the points and the line is as small as possible. From that, the slope (b) is computed as Cov(x,y) / Var(x) and the intercept (a) as mean(y) - b * mean(x). The R-squared (R²) value then reports the share of variation in the dependent variable that the independent variable accounts for. Enter X and Y as two lists of the same length, separated by commas or spaces and without thousands separators: the calculator pairs the values in order, so "1,200" would be read as two numbers, 1 and 200.
A handful of outliers can drag the line and inflate or deflate R² out of proportion to the bulk of your data, so it pays to inspect extreme points before trusting the output. Watch the interpretation, too: a strong R² confirms that two variables move together, not that one drives the other. Small or narrow datasets compound the problem, so the more observations and the wider their range, the more dependable the line becomes.
Example: Predicting Sales From Marketing Spend
- 1 A company has five quarters of marketing spend (X) and sales (Y), both in thousands of dollars. Enter X = 50, 65, 70, 55, 80 and Y = 1200, 1450, 1550, 1300, 1700, and put 75 in the "Predict Y for X" box. Working in thousands keeps the numbers free of thousands separators, which the fields would split apart.
- 2 Means: x̄ = 320 / 5 = 64 and ȳ = 7,200 / 5 = 1,440. The cross-deviations (x − 64)(y − 1,440) sum to 3,360 + 10 + 660 + 1,260 + 4,160 = 9,450, and the squared x-deviations sum to 196 + 1 + 36 + 81 + 256 = 570.
- 3 Slope = 9,450 / 570 = 16.5789 and intercept = 1,440 − 16.5789 × 64 = 378.9474, so the calculator shows y = 16.58x + 378.95, r = 0.9990 and R² = 0.9979: in these five quarters spend accounts for 99.8% of the variation in sales.
- 4 Prediction for X = 75: 16.5789 × 75 + 378.9474 = 1,622.37, about $1.62 million of sales for $75,000 of spend. 75 lies inside the observed 50–80 range; five points are a thin basis, and the fit shows that the two moved together, not that the spending caused the sales.
Source: Khan Academy · Last updated: September 2026
Frequently Asked Questions
What does R-squared mean in regression?
What is the difference between correlation and regression?
When should I use linear regression?
You might also need
Percentage Calculator
Calculate percentages three ways: what is X% of Y, X is what % of Y, and percentage change from X to Y.
Fraction Calculator
Add, subtract, multiply, and divide fractions. Results shown as fraction, mixed number, and decimal.
Standard Deviation Calculator
Calculate mean, variance, and standard deviation (population and sample) from a data set.