📉 Linear Regression Calculator

Paste x, y data — get the line of best fit, r and r², a slope test, predictions and residuals, with a scatterplot.

Google Classroom Save to Pinterest Email me

Regression formulas

  • Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)², Sxy = Σ(x − x̄)(y − ȳ)
  • Slope b₁ = Sxy ÷ Sxx · intercept b₀ = ȳ − b₁x̄ · line ŷ = b₀ + b₁x
  • Correlation r = Sxy ÷ √(Sxx · Syy) · coefficient of determination r²
  • Slope test: s = √(SSE ÷ (n − 2)), SE(b₁) = s ÷ √Sxx, t = b₁ ÷ SE(b₁), df = n − 2

Worked example

Hours studied (x) and exam score (y) for 7 students: (2, 65), (3, 68), (4, 70), (5, 74), (6, 75), (7, 81), (8, 85).

QuantityWorkValue
Meansx̄ = 35 ÷ 7, ȳ = 518 ÷ 75 and 74
Sxx, Sxy, Syysums of products of deviations28, 91, 304
Slope91 ÷ 283.25 points per hour
Intercept74 − 3.25 × 557.75
r and r²91 ÷ √(28 × 304)r = 0.986, r² = 0.973
Prediction at 6 hours57.75 + 3.25 × 677.25

The slope’s standard error is 0.243, so t = 13.39 with 5 df and p < 0.0001. Press “Try an example” above to see the scatterplot. Concepts: Correlation and regression.

Commands: Excel / Sheets =SLOPE(y, x), =INTERCEPT(y, x), =CORREL(x, y), =RSQ(y, x), =LINEST(y, x, TRUE, TRUE); TI-84 STAT → CALC → 8:LinReg(a+bx) (turn on DiagnosticOn for r).

Questions and answers

How is the line of best fit calculated?

Least squares: the slope is b₁ = Sxy ÷ Sxx = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², and the intercept is b₀ = ȳ − b₁x̄. This line makes the sum of squared residuals as small as possible, and it always passes through the point (x̄, ȳ).

What is the difference between r and r²?

r (from −1 to 1) is the correlation: its sign gives the direction and its size the strength of the linear relationship. r² (from 0 to 1) is the share of the variation in y explained by the line — r = 0.8 means r² = 0.64, so 64% is explained.

What is a residual?

Observed y minus predicted ŷ. Positive residuals are above the line, negative ones below. A residual plot with no pattern means a straight line fits; a curve in the residuals means it does not.

Is the slope significant?

The calculator tests H₀: slope = 0 with t = b₁ ÷ SE(b₁) and df = n − 2. A small p-value (below 0.05) means the data give evidence of a linear relationship. It still does not show cause and effect.

Can I predict for any x?

Only inside the range of your x data. Predicting outside it (extrapolation) assumes the straight-line pattern continues, which is often false — the calculator warns you when you do this.

Does correlation mean causation?

No. Two variables can move together because of a third variable (a lurking or confounding variable) or by chance. Only a randomized experiment can show cause. See the lesson on correlation and regression.

More free tools for college students

📏 Standard deviation calculatorSample and population SD, variance, mean, median, quartiles — with every step.🔔 Z-score calculatorValue to z-score and percentile, z to probability, percentile to z — with the curve shaded.⚗️ t-test calculatorOne-sample, two-sample (Welch or pooled) and paired t-tests: t, df, p-value, CI and effect size.🎯 Confidence interval calculatorIntervals for a mean or a proportion, margin of error, and the sample size you need.🎓 GPA calculatorSemester and cumulative GPA on a 4.0 or 4.3 scale, with credit hours and a target-GPA planner.📝 Final grade calculatorWhat you need on the final to get an A, B or C — and what each final score would leave you with.⚖️ Weighted grade calculatorYour course grade from syllabus weights, in percent or points, plus what you need on the rest.📊 Statistics calculatorsStandard deviation, z-score, t-test, confidence interval and regression — with the steps shown.🃏 Flashcard makerMake a deck, learn it with spaced repetition, quiz yourself, print it, share it by link.🍅 Pomodoro study roomOne link, one shared focus timer for your whole study group — everyone sees the same countdown.📅 Class schedule makerYour weekly classes as a printable timetable and a phone lock-screen wallpaper.🔢 Word & character counterWords, characters, sentences, reading and speaking time, page estimate and a word-limit bar.🗂️ Essay outline builderIntro, body paragraphs, counterargument and conclusion with a word budget — copy, print or share.🎯 Thesis statement generator & checkerTurn your topic and reasons into thesis statements, then check yours for weak spots.🗓️ Exam study plannerYour exams in, a day-by-day study plan for finals out.📊 Live class pollStudents answer from their phones with a code or QR; the results fill the projector live.📋 Rubric generatorCriteria × performance levels with weights and points, ready to print, share or save as PDF.📑 Syllabus template builderFill in your course and get a clean one-to-three-page syllabus with schedule, grading and policies.🪑 Exam seating chart makerSpread students across the room with spacing and alternating exam versions. Print one chart and a seat list.🔖 APA, MLA & Chicago citation generatorBooks, articles and websites, plus a works-cited list.