Regression Calculator

Perform linear regression analysis with slope, intercept, and R-squared.

By Konstantin Iakovlev · Updated April 2026 · Source: Khan Academy

R-Squared

0.9985

Predicted Y

11.89

Regression Results

Slope1.9700
Intercept0.0700
Equationy = 1.97x + 0.07
r0.9992
R-Squared0.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 and does not constitute tax, financial, or legal advice. Results are estimates based on the information you provide and current rates. Always consult a qualified tax professional or financial advisor for advice specific to your situation.

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, that relationship is the kind of signal businesses lean on as they sharpen decisions heading into 2026.

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.

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 2026 Q3 Sales Based on Q2 Marketing Spend

  1. 1 Input Q2 2026 marketing spend (X) and corresponding sales (Y) for the past 5 quarters: (50000, 1200000), (65000, 1450000), (70000, 1550000), (55000, 1300000), (80000, 1700000).
  2. 2 The calculator processes these data points to find the linear relationship: Slope (b) = 17.5, Intercept (a) = 325000, R-squared (R²) = 0.96.
  3. 3 Assuming a Q2 2026 marketing spend of $75,000, the predicted sales (Y) would be: Y = 325000 + 17.5 * 75000.
  4. 4 The predicted sales for Q3 2026, based on a $75,000 marketing spend in Q2 2026, are $1,637,500. The high R² of 0.96 suggests this prediction is quite reliable within the observed data range.

Source: Khan Academy · Last updated: April 2026

Frequently Asked Questions

What does R-squared mean in regression?
R-squared measures the proportion of variance in the dependent variable explained by the independent variable(s). An R-squared of 0.85 means the model explains 85% of the variation. Higher values indicate a better fit, but R-squared alone does not prove causation.
What is the difference between correlation and regression?
Correlation measures the strength and direction of the linear relationship between two variables (-1 to +1). Regression goes further by providing an equation (y = mx + b) that predicts one variable from the other and quantifies the rate of change.
When should I use linear regression?
Use linear regression when you expect a linear relationship between variables, your data has roughly constant variance, observations are independent, and residuals are approximately normally distributed. Always plot your data first to check for linearity.