~/ learn/ afm-113/ cards/ R² and the sums of squares
1 of 6

Compute SST from the mean, SSE from the eight residuals, SSR by subtraction, and R² two ways — SSR/SST and r² — for the fitted Northfield line.

Compute SST from the mean, SSE from the eight residuals, SSR by subtraction, and R² two ways — SSR/SST and r² — for the fitted Northfield line.

Answer

income = [35, 48, 52, 61, 70, 84, 95, 110] score = [610, 645, 640, 680, 700, 720, 745, 760] b0, b1 = 544.1766652875465, 2.0659219418011308 n = len(income) ybar = sum(score) / n sst = sum((y - ybar) ** 2 for y in score) sse = sum((y - (b0 + b1 * x)) ** 2 for x, y in zip(income, score)) ssr = sst - sse r = 0.9858851640985388 print(f"SST={sst:.1f} SSE={sse:.1f} SSR={ssr:.1f} R2={ssr / sst:.4f} r^2={r * r:.4f}")

IBS1 §13.4, BCc ch 8 (sums of squares), CC BY 4.0 — shape only; S21 W3 handout (r² sentence — shape only); original dataset

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/1b2fc7a8-53a5-4833-b11c-0e4e33bc2460/flashcard utf-8 LF