Free browser tool · Browser-only processing

Free Linear Regression Calculator with Graph & p-value

Fit a regression line to your (x, y) data and get the full equation, R², slope p-value, residual plot, and confidence intervals — instantly. Paste directly from Excel. No sign-up, no data point limit.

  • ✓Equation, slope, intercept, r and R²
  • ✓Slope t-test, p-value, F-statistic and ANOVA table
  • ✓Scatter plot with confidence and prediction bands
All calculations run in your browser — nothing is uploaded to our servers.
📉

Your regression results will appear here

Paste data on the left and click Calculate regression

Regression Equation
ŷ = — + — · x
Fit Statistics
—
n
—
Slope (b₁)
—
Intercept (b₀)
—
r
—
R²
—
SE of Estimate
Statistical Inference (Slope Test)
—
SE(b₁)
—
t-statistic
—
p-value (2-tail)
—
F-statistic
—
95% CI for Slope
—
Analysis of Variance (ANOVA)
SourceSSdfMS
Regression—1—
Residual———
Total———
Scatter Plot
#XYŶ (Predicted)ResidualStd. Residual

Predict for a New X Value

⚠️ Extrapolation: this X value is outside your data range. Predictions may be unreliable.
ŷ = —
95% Confidence Interval
—
Range for the mean Y at this X
95% Prediction Interval
—
Range for a new individual observation
STATISTICS · CALCULATOR GUIDE

Linear Regression: What the Output Means

Use the free calculator above to fit a regression line to any (x, y) dataset. This guide covers every output the tool produces — from slope and R² to p-values and prediction intervals — plus worked business examples and a plain-English explanation of what each number tells you.

What is Linear Regression?

Linear regression finds the straight line that best describes the relationship between two variables. One variable — the predictor, or independent variable — goes on the x-axis. The other — the response, or dependent variable — goes on the y-axis. The goal is to find the specific line that minimizes the total squared distance between every observed y value and the y value the line would predict for the same x. That criterion is called least squares, and it's the reason you sometimes see this called ordinary least squares (OLS) regression.

The result is an equation of the form ŷ = b₀ + b₁x, where b₁ is the slope and b₀ is the y-intercept. That equation gives you a compact summary of the relationship and a tool for predicting y at any x value.

Excel users: You can run simple linear regression in Excel using a scatter chart trendline, the =LINEST() array function, or the Analysis ToolPak add-in (Data → Data Analysis → Regression). This calculator gives you the same full output — including p-values and confidence intervals — without any Excel setup or add-in installation.

How to Use This Calculator

  1. Enter your data. Paste two columns directly from Excel — select the x column and y column together, copy with Ctrl+C, click the data box, and paste with Ctrl+V. The calculator reads Excel's tab-separated format automatically. You can also type values separated by commas, spaces, or line breaks.
  2. Label your variables (optional). Type descriptive names for X and Y (for example, "Ad Spend" and "Revenue"). These labels appear in the equation output and on the chart axes.
  3. Load a preset example if you want to explore first. The four business example buttons load real-world-style datasets covering ad spend vs. revenue, experience vs. salary, price vs. units sold, and temperature vs. heating cost.
  4. Set a confidence level under Advanced options (default is 95%). This affects the width of your confidence and prediction intervals.
  5. Click Calculate regression. The equation, scatter plot, fit statistics, and inference table all appear immediately.
  6. Use the prediction tool to enter any X value and get the predicted Y, plus a confidence interval for the mean and a prediction interval for an individual observation.
  7. Inspect the residual plot to check whether the linear model is appropriate — randomly scattered residuals confirm it, while a curved or funnel pattern suggests a problem.
Data format tip: This calculator accepts an unlimited number of rows. Enter numbers only — no currency symbols, no thousands separators (enter 12500 not 12,500). Rows with missing values are flagged rather than silently dropped.

Understanding Your Results

The Regression Equation

The equation ŷ = b₀ + b₁x is the fitted line. Plug any X value in and get the predicted Y. For example, if the equation is ŷ = 1.25 + 3.84x, then at x = 10 the predicted y = 1.25 + 3.84(10) = 39.65.

In Excel, you can reproduce this as: =INTERCEPT(y_range, x_range) + SLOPE(y_range, x_range) * A1

Slope (b₁)

The slope tells you: for every 1-unit increase in X, Y changes by b₁ units on average. A positive slope means they move in the same direction; a negative slope means they move in opposite directions. A slope of 3.84 in a model predicting monthly revenue ($K) from ad spend ($K) means that each additional $1,000 in advertising is associated with $3,840 more in revenue.

Excel equivalent: =SLOPE(y_range, x_range)

Y-Intercept (b₀)

The intercept is the predicted Y when X = 0. Whether that has a meaningful interpretation depends entirely on your data. If X = 0 is realistic — say, zero hours of practice predicting a performance score — the intercept is meaningful. If X = 0 is impossible in context (you can't have negative years of experience), the intercept is simply a mathematical constant needed to fit the line.

Excel equivalent: =INTERCEPT(y_range, x_range)

Correlation Coefficient (r)

The correlation r ranges from −1 to +1. Values near +1 indicate a strong positive linear relationship; near −1, a strong negative one; near 0, little or no linear relationship. Note that r measures only linear relationships — a U-shaped or S-shaped curve could have an r close to 0 even if the two variables are strongly related in a nonlinear way.

As a rough guide: |r| ≥ 0.9 is very strong; 0.7–0.9 is strong; 0.5–0.7 is moderate; below 0.5 is weak. These thresholds are conventions, not laws — context matters.

Excel equivalent: =CORREL(x_range, y_range)

R² (Coefficient of Determination)

R² = r², and it ranges from 0 to 1 (or 0% to 100%). An R² of 0.72 means 72% of the variation in Y is explained by X in this linear model. The remaining 28% comes from other factors not captured by X, measurement noise, or natural randomness.

What counts as a "good" R² depends entirely on your field. In engineering or physics, R² above 0.95 is often expected because physical laws are precise. In marketing or economics, R² of 0.60–0.80 is often considered a strong model. In social science research, 0.30–0.50 can be meaningful. Never judge a model by R² alone — a large dataset can produce a low but statistically significant R², and a small dataset can produce a high R² by chance.

Excel equivalent: =RSQ(y_range, x_range)

Standard Error of Estimate (s)

This is the average distance between observed Y values and the regression line, measured in the same units as Y. Smaller means a tighter fit. It's the foundation for the confidence and prediction intervals the tool calculates.

p-value for the Slope

The p-value tests the null hypothesis that the true slope equals zero — meaning X has no linear effect on Y. If p < 0.05, there's strong statistical evidence that the relationship is real and not just a fluke of the particular sample you drew. If p ≥ 0.05, the data don't give you enough evidence to rule out chance.

Important: a low p-value doesn't tell you the relationship is strong or practically important. With a large enough dataset, even a tiny slope — one that's economically meaningless — can be statistically significant. Always look at the slope size and R² alongside the p-value.

Confidence Interval vs. Prediction Interval

Both apply when you're predicting Y at a specific X value, but they answer different questions:

  • Confidence interval (CI): Where does the true mean Y fall at this X, with 95% confidence? This is narrower — it estimates a population parameter.
  • Prediction interval (PI): Where will a new individual observation fall at this X, with 95% probability? This is always wider because it accounts for both the uncertainty in the mean and the natural scatter of individual observations around the mean.

Use CI when estimating the average response; use PI when predicting a specific new data point. Both widen as X moves further from x̄ — that's why the bands on the scatter plot have a characteristic bowtie shape, narrowest at the center of the data.

The Linear Regression Formula

Here's the full derivation, using the same calculations the tool's step-by-step panel applies to your data.

Goal: minimize RSS = Σ(yᵢ − ŷᵢ)²
ŷ = b₀ + b₁x

Find b₀ and b₁ so the sum of squared residuals is as small as possible.

Step 1 — Compute means

x̄ = Σxᵢ / n     ȳ = Σyᵢ / n

Step 2 — Compute sums of squares

Sxx = Σ(xᵢ − x̄)² = Σxᵢ² − n·x̄²

Syy = Σ(yᵢ − ȳ)² = Σyᵢ² − n·ȳ²

Sxy = Σ(xᵢ − x̄)(yᵢ − ȳ) = Σxᵢyᵢ − n·x̄·ȳ

Step 3 — Slope and intercept

b₁ = Sxy / Sxx     b₀ = ȳ − b₁ · x̄

Step 4 — Correlation and R²

r = Sxy / √(Sxx · Syy)     R² = r²

Step 5 — Residual standard error

Residuals: eᵢ = yᵢ − ŷᵢ     RSS = Σeᵢ²     s = √(RSS / (n − 2))

The denominator n − 2 reflects two degrees of freedom used to estimate b₀ and b₁.

Step 6 — Hypothesis test for slope

SE(b₁) = s / √Sxx     t = b₁ / SE(b₁)  (df = n − 2)

The p-value is the two-tailed probability from the t-distribution. The F-statistic equals t² for simple linear regression, so both tests give the same p-value.

The "Show step-by-step" toggle in Advanced options applies these formulas to your actual data, showing all intermediate sums and each calculation in sequence.

Worked Example — Ad Spend vs. Revenue

A marketing analyst wants to understand how monthly advertising spend drives revenue. She has 12 months of data. Click "Ad Spend ↔ Revenue" in the calculator to load it.

MonthAd Spend (X, $K)Revenue (Y, $K)
Jan5.222.1
Feb7.831.4
Mar6.126.8
Apr9.338.2
May8.434.9
Jun11.044.3
Jul10.542.8
Aug12.249.1
Sep13.854.6
Oct15.060.2
Nov14.257.3
Dec16.565.9

Reading the output

The regression equation comes out to approximately Revenue = 1.25 + 3.84 × Ad Spend.

Slope: Each additional $1,000 in ad spend is associated with roughly $3,840 more in monthly revenue. That's the implied return on ad spend from the linear model.

R²: With R² near 0.998, ad spend explains almost all the month-to-month variation in revenue in this dataset. That's unusually tight — real-world relationships rarely fit this cleanly, but it makes the example easy to interpret.

Prediction: Planning to spend $14,000 next month? Plug in x = 14: ŷ = 1.25 + 3.84(14) ≈ $55K predicted revenue. The 95% prediction interval is wider than the confidence interval — it accounts for the natural month-to-month variability that the model doesn't capture.

Excel cross-check: =SLOPE(B2:B13, A2:A13) and =INTERCEPT(B2:B13, A2:A13) will match the calculator's b₁ and b₀. For the full inference table including p-values, use =LINEST(B2:B13, A2:A13, TRUE, TRUE) as a Ctrl+Shift+Enter array formula.

When to Use Linear Regression (and When Not To)

Good situations for linear regression

  • You have one continuous X and one continuous Y, and you expect or want to test a straight-line relationship between them.
  • Your goal is prediction — you want to estimate Y for new X values.
  • Your goal is quantification — you want to know how much Y changes per unit change in X.
  • You have at least 20–30 data points. Fewer than 10 gives unreliable inference; the p-values and intervals are mathematically valid but practically meaningless with tiny samples.

When to use something else

  • Curved relationship: If the scatter plot shows a clear curve, polynomial or exponential regression fits better.
  • Binary outcome: If Y is yes/no or 0/1, use logistic regression.
  • Multiple predictors: If several X variables drive Y (revenue depends on ad spend, number of salespeople, and season), use multiple linear regression.
  • Severe outliers you haven't examined: One extreme point can pull the slope significantly. Use this tool's Outlier Calculator first to identify candidates worth investigating.

Five assumption checks before you trust the results

  • 🔵
    Linearity: The scatter plot should show a roughly linear cloud, not a curve. If the scatter follows a clear curve, the linear model will give a systematically biased equation.
  • 🔵
    Independence: Each observation should be independent of the others. Time series data where one month's sales affects next month's often violates this.
  • 🔵
    Constant variance (homoscedasticity): The residual plot should show a horizontal band of roughly equal scatter. A funnel shape — residuals getting larger as X increases — means the standard errors, p-values, and intervals are unreliable.
  • 🔵
    Near-normality of residuals: The residuals should be roughly symmetric around zero. This matters most for small samples; with n > 30 the central limit theorem makes inference relatively robust to mild non-normality.
  • 🔵
    No dominating outliers: Look for points that sit far from the regression line in the residual plot (standardized residuals beyond ±3 are highlighted in red). One outlier doesn't ruin a large dataset, but it can define the slope of a small one.

These aren't pass/fail tests — they're judgment calls. The residual plot is your most useful diagnostic: open it after every regression run, before interpreting any other output.

Frequently Asked Questions

What is the formula for linear regression?

The simple linear regression formula is ŷ = b₀ + b₁x, where b₁ is the slope and b₀ is the y-intercept. The slope is b₁ = Sxy / Sxx — the ratio of the cross-product sum to the variance of X. The intercept is b₀ = ȳ − b₁ · x̄. The calculator computes all of this automatically; expand the step-by-step panel under Advanced options to see every intermediate sum applied to your data.

How do I calculate linear regression step by step?

Compute the means of x and y. Then calculate Sxx = Σ(xᵢ − x̄)², Syy = Σ(yᵢ − ȳ)², and Sxy = Σ(xᵢ − x̄)(yᵢ − ȳ). Divide to get the slope b₁ = Sxy / Sxx, then the intercept b₀ = ȳ − b₁x̄. Correlation r = Sxy / √(Sxx · Syy), and R² = r². This calculator's step-by-step panel walks through each step with the actual values from your data.

What does R² mean in linear regression?

R² measures how much of the variation in Y is explained by X in the linear model. An R² of 0.75 means 75% of Y's variation is explained by X — the other 25% is due to factors the model doesn't capture. It ranges from 0 to 1. What counts as "good" depends on your field: 0.95+ is often expected in engineering; 0.60–0.80 is frequently acceptable in marketing or economics. Never use R² alone — a high R² can come from a small sample, and a low R² model can still have a highly significant, practically useful slope.

How do I interpret the slope in linear regression?

The slope b₁ tells you: for every 1-unit increase in X, Y changes by b₁ units on average. If the slope is positive, X and Y move in the same direction; if negative, they move in opposite directions. For example, a slope of 3.84 in a model predicting monthly revenue ($K) from ad spend ($K) means each additional $1,000 in ad spend corresponds to roughly $3,840 more in revenue, holding the linear relationship fixed.

What is a good R² value for linear regression?

There's no universal benchmark. In physics and controlled experiments, R² above 0.95 is common because the relationships are precise. In business analytics, R² of 0.60–0.80 is often strong. In social science research, 0.30–0.50 can be meaningful. R² also increases mechanically with the number of predictors in multiple regression, which is why adjusted R² exists. For simple linear regression, check R², the p-value, and the residual plot together rather than any single number in isolation.

How do I do linear regression in Excel?

Three options in Excel: (1) Insert a scatter chart, right-click the data series, choose Add Trendline → Linear, and check Display equation and Display R² value. (2) Enter =LINEST(y_range, x_range, TRUE, TRUE) as a Ctrl+Shift+Enter array formula to get slope, intercept, standard errors, R², and F-statistic in a grid. (3) Go to Data → Data Analysis → Regression (requires the Analysis ToolPak add-in). This calculator produces the same full output as LINEST without any setup — and adds the scatter plot with confidence and prediction bands that Excel doesn't show automatically.

What is the difference between correlation and regression?

Correlation gives you a single number between −1 and +1 that describes how closely X and Y track each other linearly. Regression goes further: it gives you the actual equation of the best-fit line, so you can predict Y for specific X values and test whether the relationship is statistically significant. For more on the correlation side, the Correlation Calculator focuses specifically on r and R² without the full regression framework.

What does the p-value mean in linear regression?

The p-value for the slope tests whether the true slope is significantly different from zero — i.e., whether X genuinely predicts Y or whether the observed relationship is a statistical accident of this particular sample. If p < 0.05, the evidence for a real relationship is strong. If p ≥ 0.05, the data don't rule out chance. A small p-value doesn't mean the relationship is strong or important in practice; a very large dataset can make a trivially small slope statistically significant.

How many data points do you need for linear regression?

The absolute minimum is 3 — you need at least n − 2 = 1 degree of freedom. In practice, fewer than 10 points give very unstable results. For reliable inference, 20–30 observations is a reasonable floor; 50 or more gives you narrow confidence intervals and p-values you can trust. This calculator has no upper limit on data points — paste whatever you have.

What is the difference between simple and multiple linear regression?

Simple linear regression has one predictor X and one response Y. Multiple linear regression uses two or more predictors. For example, predicting revenue from ad spend alone is simple; predicting it from ad spend, number of sales reps, and time of year is multiple regression. This calculator handles simple linear regression. For multiple predictors, use dedicated software — R's lm() function, Python's scikit-learn, Excel's LINEST with multiple columns, or statistical packages like SPSS.

What is the y-intercept in linear regression?

The y-intercept b₀ is the predicted value of Y when X = 0, and it's where the regression line crosses the Y axis. Whether that has real-world meaning depends on the context. In a model predicting sales from advertising spend, X = 0 means zero advertising — the intercept predicts what sales would be with no ad spend at all. In a model predicting salary from years of experience, X = 0 means zero experience, which might be a reasonable entry-level baseline. When X = 0 is completely outside the range of realistic values, the intercept is a mathematical necessity with no direct interpretation.

How do you use a linear regression equation to make predictions?

Substitute the X value into ŷ = b₀ + b₁x. If the equation is ŷ = 1.25 + 3.84x and X = 12, then ŷ = 1.25 + 3.84(12) = 47.33. Use this calculator's prediction tool to get not just the point estimate but also the confidence interval (uncertainty in the mean Y) and the wider prediction interval (range for an individual new observation). Note the extrapolation warning if your X is outside the range of your original data — the relationship may not hold outside where you observed it.

When this tool is useful

From a quick answer to a full analysis.

The free calculator handles simple (one predictor) linear regression with the complete statistical output that most online tools leave out — p-values, confidence intervals, residual diagnostics, and an unlimited number of data points. It doesn't require an account, an Excel add-in, or statistical software.

Checking Excel SLOPE, INTERCEPT and RSQ resultsSimple forecasting from one predictorStatistics courseworkRegression without the Analysis ToolPak
FAQ

Linear Regression Calculator questions

Common questions about how the calculator works.

Can I paste data from Excel?+

Yes. Copy two columns, X then Y, and paste them. Tab, comma and space separators are detected.

How many data points can I enter?+

Up to 50,000 (x, y) pairs.

Does it handle multiple regression?+

No. It fits simple linear regression with one predictor. Use R, Python or Excel LINEST with several columns for multiple predictors.

Is my data uploaded to a server?+

No. Parsing, calculation and charts run in your browser, and refreshing the page clears everything.