Squared loss sums the squared residuals between observed response values and fitted values: SSE = Σ(y − ŷ)². Linear regression chooses coefficients that minimize this quantity, so smaller SSE indicates a closer fit to the observed data. section 4.1.2 section 4.2.3
For a fitted regression, squared loss is the unexplained portion of total variation. With SST as total variation, SSR as explained variation, and SSE as error, SST = SSR + SSE; R² = SSR / SST therefore reports the explained proportion. section 4.2.3
Computing SSE from a fitted model
For the marathon stage1-to-stage2 regression, calculate total variation and explained variation, then obtain squared loss either by subtraction or directly from residuals: SSE = SST − SSR SSE = 49,636.95 − 28,537.79 = 21,099.16 In Python: SSE = np.sum(lm.resid ** 2) The direct calculation returns approximately 21,099.16, matching the decomposition. The same model gives R² ≈ 0.575, meaning the regression explains about 57.5% of the response variation. section 4.2.3
Table 4.2 The sum of squares summary for the fitted linear regression. The stage1 and stage2 columns represent, respectively, the observed values from the two mds variables. SST equals the sum of squares total, or the total variability in the dependent variable without the consideration of any predictors. The yhat column contains the predictions for the response variable from the fitted regression. SSE equals the sum of squares error, or the portion of the SST that can’t be explained by the regression; and SSR equals the sum of squares regression, or the percentage of the variance in the dependent variable explained by the model.
|
x
stage1
|
y
stage2
|
(
y −
ȳ)
2
SST
|
y
yhat
|
(
y −
ŷ)
2
SSE
|
(
ŷ −
ȳ)
2
SSR
|
|---|---|---|---|---|---|
|
152
|
191
|
3,654.20
|
195.78
|
22.88
|
3098.73
|
|
162
|
184
|
4,549.50
|
208.87
|
618.36
|
1813.33
|
|
165
|
193
|
3,416.40
|
212.79
|
391.71
|
1494.46
|
|
163
|
191
|
3,654.20
|
210.18
|
367.68
|
1,703.62
|
|
166
|
193
|
3,416.40
|
214.10
|
445.21
|
1,395.02
|
|
187
|
292
|
1,644.30
|
241.57
|
2,542.75
|
97.53
|
|
175
|
235
|
270.60
|
225.87
|
83.27
|
654.10
|
|
202
|
226
|
647.70
|
261.20
|
1,238.96
|
95.04
|
|
179
|
214
|
1,402.50
|
231.11
|
292.68
|
413.80
|
|
222
|
274
|
508.50
|
287.36
|
178.62
|
1,289.87
|
|
184
|
300
|
2,357.10
|
237.65
|
3,887.60
|
190.46
|
|
193
|
242
|
89.30
|
249.42
|
55.12
|
4.10
|
|
255
|
279
|
759.00
|
330.54
|
2,656.24
|
6,255.02
|
|
202
|
288
|
1,335.90
|
261.20
|
718.30
|
95.04
|
|
221
|
269
|
308.00
|
286.06
|
290.92
|
1,197.61
|
|
207
|
329
|
6,014.00
|
267.74
|
3,752.75
|
265.37
|
|
227
|
268
|
273.90
|
293.91
|
671.14
|
1,802.54
|
|
239
|
315
|
4,038.60
|
309.61
|
29.10
|
3,382.11
|
|
164
|
201
|
2,545.20
|
211.48
|
109.90
|
1,597.33
|
|
226
|
345
|
8,751.60
|
292.60
|
2,745.97
|
1,693.16
|
|
49,636.95
|
21,099.16
|
28,538.24
|
Inspect the sum-of-squares table to compare observed responses, fitted values, residual squares, SST, SSE, and SSR row by row. section 4.2.3




