Estimate, Multiple R-squared, Residual standard error
◈ 10 cardsfit <- lm(sales ~ adspend, data = stores); summary(fit). Read the Coefficients table in the Estimate column: (Intercept) 13.28571, adspend 3.45238 — not the t value two columns right. Residual standard error 0.5926 on 4 degrees of freedom is the typical size of a residual, √(SSE / (n − 2)). Multiple R-squared 0.9972 is r². Std. Error, t value, Pr(>|t|) and the F-statistic are recognised here and interpreted in AFM 113. summary(fit)$r.squared pulls the number out.
Fit once, then read
lm() — linear model — fits the least-squares line and keeps everything about it in one object. Save it, then ask it questions:
> fit <- lm(sales ~ adspend, data = stores)
> summary(fit)
Call:
lm(formula = sales ~ adspend, data = stores)
Residuals:
1 2 3 4 5 6
-0.19048 -0.09524 0.45238 0.54762 -0.90476 0.19048
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 13.28571 0.59963 22.16 2.46e-05 ***
adspend 3.45238 0.09144 37.76 2.94e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5926 on 4 degrees of freedom
Multiple R-squared: 0.9972, Adjusted R-squared: 0.9965
F-statistic: 1425 on 1 and 4 DF, p-value: 2.939e-06
This block is the final's hardest reading item. Walk it top to bottom, and know which lines are yours.
Worked example — the block, line by line
Call — the formula, so a printout can be matched to the model that made it. sales ~ adspend reads sales explained by adspend: response left, explanatory right, the same tilde as aggregate().
Residuals — the six values from Lesson 13.3, one per store. (With more than a few rows R prints their five-number summary instead.)
Coefficients — the table. Two rows, one per term; four columns. The Estimate column is the line: in the (Intercept) row, in the adspend row — the same two numbers as coef(fit), SLOPE and INTERCEPT. The three columns to the right — Std. Error, t value, Pr(>|t|) — and the stars are inference: how precisely each coefficient is estimated and whether it could plausibly be zero. Recognise them, do not read them, until AFM 113.
Residual standard error: 0.5926 on 4 degrees of freedom — the typical size of a residual, in the units of y: where SSE is the sum of squared residuals and because two coefficients were estimated from six stores. Sales predictions from this line are typically off by about $0.6k. It is a standard deviation of the residuals, not a variance — some textbooks misname it.
Multiple R-squared: 0.9972 — , the share of the variation in sales the line accounts for: 99.7 %. For one predictor it is exactly , and exactly RSQ. Adjusted R-squared and the F-statistic line are AFM 113.
Pulling numbers out
> summary(fit)$r.squared
[1] 0.9972017
> summary(fit)$sigma
[1] 0.5926133
> sqrt(sum(residuals(fit)^2) / 4)
[1] 0.5926133
summary(fit) is a list; $r.squared and $sigma (the residual standard error) are its parts, and the third line rebuilds sigma from the residuals to prove what it is. abline(fit) draws the fitted line onto the scatter that is currently open — plot() first, then abline(fit).
Type the two calls, then fill the read-off worksheet
The worksheet asks for three numbers from the block above at the precision R printed them — and the callout says which column the slope is not in.
CRISP-DM: summary() is modelling → assess model.