📈

Linear Regression Calculator

Fit a least-squares line to two columns and get slope, intercept, R squared, residual standard error and a prediction for a chosen X, with fitted valu
Local only 📂 Study 👤 ToolWorld 🏷️ v1.3.0
Inputs
Column X
Column Y
Predict at X

Results
Slope
-
Intercept
-
R squared
-
Predicted Y
-
Residual standard error
-

How to Use

About this tool

Ad spend changes month by month and sales move with it. Eyeballing a line chart only gives a hunch about how much one extra unit of spend returns. A simple linear regression writes that trend as y = a + bx, giving a slope and an intercept you can actually use.

With X from 1 to 7 and Y at 2.1, 3.9, 6.2, 7.8, 10.1, 12.2 and 13.9, the fit gives a slope near 1.99, an intercept near 0.13 and R squared about 0.996. Enter 8 as the prediction X and Y comes out near 16.1. Drop one pair and both the slope and the residual error move.

What it does

  • SolutionClosed-form least squares Every number shown here maps to a field on the form, so changing one value recomputes the rest. The units are printed next to each input, which saves most of the usual mistakes.
  • Per pointFitted value and residual per point The main figures sit at the top of the result panel and the breakdown sits below it, so you can read the conclusion first and audit the steps afterwards. Nothing you type leaves the browser.
  • PredictionPrediction at a chosen X All arithmetic runs locally in the page. There is no request to a server, no account, and no saved history once the tab is closed. Use the example button if you want a set of values that is known to work.
  • ErrorR squared and residual error Intermediate quantities are kept in the detail table. When a total looks wrong, tracing back through those rows is much quicker than staring at the headline number alone.
  • OptionalPrediction field can be left blank The formula is written out in the notes rather than hidden behind a label, so you can check it against a spreadsheet or a textbook. Values are rounded only for display.
  • TableFirst ten rows tabulated Inputs are validated before any calculation starts. Empty or impossible values produce a short explanation instead of a zero, a NaN, or a made-up answer.

How to use it

  1. Start by filling inpaste the X column The main figures sit at the top of the result panel and the breakdown sits below it, so you can read the conclusion first and audit the steps afterwards. Nothing you type leaves the browser.
  2. Next, setpaste the Y column All arithmetic runs locally in the page. There is no request to a server, no account, and no saved history once the tab is closed. Use the example button if you want a set of values that is known to work.
  3. Then pressenter an X to predict Intermediate quantities are kept in the detail table. When a total looks wrong, tracing back through those rows is much quicker than staring at the headline number alone.
  4. Read thepress Calculate The formula is written out in the notes rather than hidden behind a label, so you can check it against a spreadsheet or a textbook. Values are rounded only for display.
  5. Finally, usejudge the fit from the residual table Inputs are validated before any calculation starts. Empty or impossible values produce a short explanation instead of a zero, a NaN, or a made-up answer.

Things to keep in mind

  • Row countat least three equal-length rows All arithmetic runs locally in the page. There is no request to a server, no account, and no saved history once the tab is closed. Use the example button if you want a set of values that is known to work.
  • ConstantX cannot be constant Intermediate quantities are kept in the detail table. When a total looks wrong, tracing back through those rows is much quicker than staring at the headline number alone.
  • Extrapolationextrapolation is risky The formula is written out in the notes rather than hidden behind a label, so you can check it against a spreadsheet or a textbook. Values are rounded only for display.
  • Curvaturea line cannot fit a curve Inputs are validated before any calculation starts. Empty or impossible values produce a short explanation instead of a zero, a NaN, or a made-up answer.
  • Outliersoutliers pull the slope Every number shown here maps to a field on the form, so changing one value recomputes the rest. The units are printed next to each input, which saves most of the usual mistakes.

Related

⏫︎
💬