Linear Regression Calculator
StatisticsCalculate the simple linear regression line for paired X, Y data in seconds. Get the slope and R² so you can predict Y from any new X value instantly.
Reviewed by the thecalcu.com team · Last updated July 29, 2026
Add up to 12 data points. At least 2 pairs are required.
Regression Line
Slope
0
Intercept
0
R²
0
Fit Quality
Based on 0 data points, this line explains 0.0% of the variance in Y. Use the equation above to predict Y for any new X value.
What is a Linear Regression?
The Linear Regression Calculator fits a straight-line equation (y = mx + b) through your paired X, Y data points using the least-squares method. Enter your data pairs, and the calculator returns the slope, intercept, and R² (goodness of fit), so you can predict Y for any new X value using the resulting equation.
Linear regression is the foundational technique for modeling and predicting relationships between two continuous variables. Forecasting sales from advertising spend, predicting exam performance from study hours, estimating price from size, this calculator finds the best-fitting line through your data instantly and reports how well that line actually captures the relationship.
Before fitting a line, use the Correlation Coefficient Calculator with the same data to confirm a meaningful linear relationship exists, a very low correlation means a straight-line fit may not be the right tool for your data.
Why Use a Linear Regression Calculator?
Manually deriving the slope and intercept of a best-fit line requires computing several summed quantities (Σx, Σy, Σxy, Σx²) across your entire dataset and combining them in the least-squares formulas, arithmetic that becomes unmanageable by hand beyond a few data points.
This calculator computes the full regression instantly for any number of data pairs, and reports R² alongside the equation so you immediately know not just what the line is, but how much you should trust its predictions.
Who Should Use This Calculator?
Business analysts and forecasters modeling the relationship between a business driver (ad spend, headcount, price) and an outcome metric (sales, output, demand) to build simple predictive models.
Students in statistics, economics, or research methods courses learning least-squares regression as a foundational quantitative modeling technique.
Data scientists performing quick exploratory linear fits before deciding whether more complex modeling techniques are warranted.
Scientists and engineers fitting calibration curves or relationships between two measured physical quantities (e.g., voltage and temperature in a sensor calibration).
Real estate and pricing analysts modeling the relationship between a property characteristic (like square footage) and price to build a simple valuation tool.
What Insights Does This Calculator Give You?
Slope (m), how much Y is expected to change for every one-unit increase in X. This is the core "rate of change" insight from your fitted model.
Intercept (b), the predicted Y value when X = 0, useful mathematically but only meaningful if X = 0 is a realistic value in your data's context.
R² (Goodness of Fit), the proportion of variance in Y explained by the linear relationship with X, telling you how much to trust the fitted line's predictions.
Fitted equation display, the full y = mx + b equation, ready to use for predicting Y at any new X value within your data's range.
How to use this Linear Regression calculator
Enter your paired X, Y data points, each row represents one observation with both an X (predictor) and Y (outcome) value.
Add more pairs as needed, up to 12 data points can be entered; more data generally produces a more reliable fitted line.
Read the slope and intercept, these define your prediction equation y = mx + b.
Check R², a higher R² (closer to 1) means the line explains more of the variation in your data and predictions can be trusted more.
Predict new values, plug any new X value into the displayed equation to estimate the corresponding Y, staying within the range of X values in your original data.
Confirm linearity first, if R² is low, check the Correlation Coefficient Calculator and consider whether your data actually follows a non-linear pattern instead.
Show formula & methodology ↓Show less ↑
Formula & Methodology
Slope: m = [nΣxy − ΣxΣy] / [nΣx² − (Σx)²] Intercept: b = (Σy − mΣx) / n Variable definitions: - x, y, individual paired data values - n, number of data pairs - Σ, sum across all data pairs Worked example: Advertising spend in $1000s (X) vs monthly sales in $1000s (Y): (1, 2.1), (2, 3.9), (3, 6.2), (4, 7.8), (5, 10.1) Step 1, n = 5, Σx = 15, Σy = 30.1, Σxy = 112.5, Σx² = 55 Step 2, Slope: m = (5×112.5 − 15×30.1) / (5×55 − 15²) = (562.5 − 451.5) / (275 − 225) = 111 / 50 = 2.22 Step 3, Intercept: b = (30.1 − 2.22×15) / 5 = (30.1 − 33.3) / 5 = −0.64 Fitted equation: y = 2.22x − 0.64 This means each additional $1,000 in ad spend is associated with roughly $2,220 in additional monthly sales, based on this dataset. Assumption: Linear regression assumes the true relationship between X and Y is approximately linear across the range of your data. Predictions made far outside the range of your original X values (extrapolation) are unreliable, and the model does not account for other variables that may also influence Y.
Frequently Asked Questions