Skip to content

Linear Regression

Ordinary least squares for y = β₀ + β₁x, fitted live. Pick a real-world scenario (house prices, study hours, ice-cream sales) or stay with abstract x and y. Every quantity is the exact closed-form answer, recomputed on every drag. Start in Beginner mode for the essentials; switch to Advanced for the full inference table, formulas, and diagnostics.

How to use
  1. Choose a scenario from the dropdown to give the axes real-world meaning, or keep the abstract x-y view.
  2. Click anywhere on the plot to add a point. Drag points to move them; double-click one (or press Delete) to remove it.
  3. Set β₀, β₁, σ, and n, then click "Generate data" to sample from a known true line and compare it to the fit.
  4. Toggle the residuals to see the vertical misses that least squares is minimizing.
  5. Drag one point far from the others and watch the leverage: a single outlier can pivot the whole line.
  6. Toggle the 95% CI band: it pinches at the mean of x, where the line is known best.
Linear regression scatter plot and fitted line

Data generator (y = β₀ + β₁x + noise)
Formula

General form

With your values

Diagnostics

The four diagnostic plots from R's plot(lm(...)). Apricot markers in the leverage plot have Cook's distance above 4/n (influential).