Linear Regression Calculator

Slope & Intercept R² & Correlation Predictions Free · No Signup

Free online linear regression calculator: compute the regression equation (y = a + bx), , correlation, standard error, and make predictions. Interactive Plotly scatter plot with regression line, step-by-step KaTeX formulas, and Python scipy export.

Linear Regression
Separate X and Y with comma or space. Minimum 2 data points.
X =

Result

📉

Enter data and click Calculate

Compute the regression equation, R², correlation, and make predictions.

Scatter Plot & Regression Line

Python Compiler

What Is Linear Regression?

Linear regression models the relationship between a dependent variable (Y) and independent variable (X) by fitting the best straight line through the data using the least squares method.

Regression Equation:  y = a + bx
📈

Slope (b)

How much Y changes for each 1-unit increase in X. Positive = upward trend, negative = downward.

🎯

Intercept (a)

The predicted value of Y when X = 0. The starting point of the regression line.

📊

R² (Fit Quality)

Proportion of variance in Y explained by X. Ranges from 0 (no fit) to 1 (perfect fit).

Key Formulas

Slope:  b = Σ[(xi − x̄)(yi − ȳ)] / Σ(xi − x̄)²
Intercept:  a = ȳ − b × x̄
R²:  R² = 1 − SSres / SStot
Standard Error:  SEE = √[Σ(yi − ŷi)² / (n − 2)]

Understanding R²

R² RangeInterpretationFit Quality
0.90 – 1.0090–100% of variance explainedExcellent
0.70 – 0.8970–89% of variance explainedGood
0.50 – 0.6950–69% of variance explainedModerate
0.00 – 0.49Less than 50% explainedWeak

Tip: A high R² does not guarantee a good model. Always visualize residuals to check for patterns that indicate model violations (non-linearity, heteroscedasticity).

Assumptions of Linear Regression

Linearity

The relationship between X and Y is approximately linear. Check with a scatter plot.

Independence

Observations are independent of each other. No autocorrelation in residuals.

Homoscedasticity

Residuals have constant variance across all X values. Fan-shaped patterns indicate violation.

Normality

Residuals are approximately normally distributed. Less critical for large samples.

Frequently Asked Questions

R² is the proportion of variance in Y explained by the linear model. An R² of 0.85 means 85% of the variation in Y is captured by the regression line. Higher is better, but always check residual plots.
Linear regression assumes: linearity (X and Y have a linear relationship), independence of observations, homoscedasticity (constant residual variance), and approximately normal residuals. Inspect residual plots to verify.
Plug any X value into y = a + bx. Be cautious about extrapolating far beyond your data range, as the linear relationship may not hold outside the observed domain.
If residuals show a curve or pattern, consider polynomial regression, logarithmic transformation, or other nonlinear models. Always visualize your data with a scatter plot first.
The slope (b) tells you how much Y changes for each 1-unit increase in X. A slope of 2.5 means Y increases by 2.5 units on average when X increases by 1 unit.
SEE measures the average distance between observed Y values and predicted values from the regression line. Smaller SEE means the model makes more precise predictions.

Support This Free Tool

Every coffee helps keep the servers running. Every book sale funds the next tool I'm dreaming up. You're not just supporting a site — you're helping me build what developers actually need.

500K+ users
200+ tools
100% private
Privacy Guarantee: Private keys you enter or generate are never stored on our servers. All tools are served over HTTPS.