Free calculator
Linear regression calculator (simple OLS)
Paste paired x and y values (from Google Sheets, Excel, or plain text) to fit ŷ = b₀ + b₁x by ordinary least squares. You get slope, intercept, Pearson r, R², and optional ŷ at a new x. The Google Sheets & Excel block highlights LINEST, SLOPE, INTERCEPT, RSQ, CORREL, and FORECAST.LINEAR—not multiple regression or survey software.
When to use this calculator
Quick line-of-best-fit checks before you mirror the same logic in a workbook—transparent OLS, not a statistics suite.
- Homework or self-study: verify slope, intercept, r, and R² against textbook or calculator steps.
- Match
LINEST/SLOPE/INTERCEPT/RSQcells in Sheets or Excel against this page for the same pasted pairs. - Sketch a forecast ŷ at a hypothetical x after fitting on historical pairs—remember extrapolation limits.
- Need t-tests on means or confidence intervals instead of a fitted line? Use the t-test or confidence interval tools linked below.
You start from n pairs (xᵢ, yᵢ). The means x and [[ybar]] describe the center of each variable. Sxx, Syy, and Sxy are the sums of squared and cross deviations around those means.
Means and sums of products
Compute x and [[ybar]], then Sxx = Σ(xᵢ − x)2, Syy = Σ(yᵢ − [[ybar]])2, Sxy = Σ(xᵢ − x)(yᵢ − [[ybar]]).
Slope and intercept (OLS)
b₁ = Sxy / Sxx when Sxx > 0 (not all x identical). b₀ = [[ybar]] − b₁x so the line passes through (x, [[ybar]]).
r, R², and optional diagnostics
r = Sxy / √(Sxx·Syy) when Syy > 0; otherwise r is undefined and R² is 0 here. With n ≥ 3, SSE, MSE, SE(b₁), t, and a two-sided p-value for H₀: β₁ = 0 follow the usual classical formulas.
We do not fit multiple predictors, weighted least squares, nonlinear curves, or robust regression on this page—use a full stats package when you need those models.
For t-tests on means (not a fitted line from raw pairs), open the t-test calculator.
For two-sided confidence intervals on a mean or proportion, open the confidence interval calculator.
For spread on a single pasted list (standard deviation / variance), open the standard deviation calculator.
FAQs on this page cover simple vs multiple regression, r vs R², extrapolation, and spreadsheet function names.
Google Sheets & Excel
In Google Sheets and Microsoft Excel with English (US/UK) function names, LINEST returns regression statistics (including slope and intercept) for y on x. SLOPE and INTERCEPT match the same OLS line; RSQ is R²; CORREL is r; FORECAST.LINEAR(x, known_y, known_x) predicts ŷ at x. Replace A2:A99 / B2:B99 with your y and x ranges. If your Excel is not in English, use Formulas → Insert function to find the same functions under your language pack’s own names.
=LINEST(B2:B99,A2:A99)B = y, A = x. In dynamic-array Excel, this may spill statistics; slope is the first cell.
=SLOPE(B2:B99,A2:A99)Same b₁ as LINEST for the same ranges.
=INTERCEPT(B2:B99,A2:A99)Same b₀ as LINEST for the same ranges.
=RSQ(B2:B99,A2:A99)Equals r² for simple linear regression with intercept.
=CORREL(A2:A99,B2:B99)Same r as the correlation between x and y columns.
=FORECAST.LINEAR(A101,B2:B99,A2:A99)A101 is the x where you want ŷ; known y and x are your sample columns.
More tools in Statistics
Browse all toolsSlide 1 of 14
Frequently asked questions
What is simple linear regression?
Simple linear regression fits one straight line ŷ = b₀ + b₁x to paired (x, y) data so the sum of squared vertical residuals is as small as possible (ordinary least squares, OLS). b₁ is the slope; b₀ is the intercept.
Is this multiple regression?
No. This tool fits one predictor x and one outcome y. Multiple regression adds more predictors (and different diagnostics). Export your data to a statistics package or workbook model when you need several x variables at once.
What is the difference between r and R²?
r is the Pearson correlation between x and y (sign shows direction). R² is the coefficient of determination; in simple linear regression with an intercept, R² = r² on this page. When y has no variation, r is undefined here and R² is 0.
Is this the same as y = mx + b?
Yes—algebra often writes y = mx + b where m is the slope and b is the intercept. We write ŷ = b₀ + b₁x to match common statistics notation (b₁ slope, b₀ intercept) and LINEST conventions in spreadsheets.
How do I match this page in Google Sheets or Excel?
Put y and x in two columns. SLOPE(y_range, x_range) and INTERCEPT(y_range, x_range) return b₁ and b₀; RSQ is R²; CORREL is r; FORECAST.LINEAR(x_new, y_range, x_range) matches ŷ at x_new for the same fit.
What are typical German Excel names for LINEST / SLOPE / INTERCEPT?
Many German installs still expose LINEST as LINEST or legacy RGP for the array form—SLOPE is often STEIGUNG, INTERCEPT is ACHSENABSCHNITT, RSQ is BESTIMMTHEITSMASS, CORREL is KORREL. Always confirm in Formulas → Insert function on your build.
What are typical French Excel names for these functions?
You may see DROITEREG/LINEST-style names depending on version; slope/intercept often map to PENTE and ORDONNEE/INTERCEPT. Use Formules → Insérer une fonction to match your language pack.
How is ŷ at a new x calculated?
After fitting, plug your chosen x into ŷ = b₀ + b₁x using the b₀ and b₁ on this page—the same result as FORECAST.LINEAR with your y and x column ranges.
Can I trust predictions far outside my x data?
Usually no. The line is estimated where your x values lie. Extrapolating far beyond that range assumes the linear pattern continues, which often fails in real data. Treat distant ŷ as a rough illustration, not a forecast guarantee.
Does a regression line prove x causes y?
No. OLS describes association in your sample. Confounding, reverse causation, selection, and measurement issues can make a fitted line misleading. Design, experiments, and domain judgment—not this page—establish causality.
What if the relationship is curved?
A straight line can be a poor model when the true pattern is nonlinear. Residual plots and domain knowledge matter. Use transformations, polynomial or nonlinear models, or a graphing tool when curvature is important—this page stays linear OLS only.
When should I use the t-test calculator instead?
Use the t-test tool when you already have summary statistics (n, mean, sample SD) for one-sample, paired, or two-sample mean comparisons. This regression page expects raw paired x and y to fit a line.
Does this replace a TI-84 or Casio regression mode?
It can check the same OLS slope, intercept, r, and R² you obtain from a calculator’s stats mode when you type the same pairs. It is not an emulator of every calculator menu—paste your stored pairs here.
Is this tool suitable for research or regulatory submissions?
No. It is a transparent classroom and spreadsheet companion. Published work, clinical trials, and regulated reporting need documented data handling, assumption checks, and version-controlled analysis—not a browser quick check alone.