A line predicts 18 liters and the observed value is 15 liters. The residual is:
Correlation and the fitted line
Describe scatterplots, compute predictions and residuals, and interpret model fit.
Key ideas
- Correlation r
A unitless measure from −1 to 1 of linear direction and strength. It is sensitive to outliers; near-zero correlation can hide a curved relationship.
- Describing a scatterplot
Give the form (linear or not), strength (how tightly the points cluster), direction (positive or negative) and any unusual points, in context. Say "no apparent outliers" rather than declaring that a point is an outlier: the course gives no formal outlier test.
- OLS line
The ordinary least squares line , the line that makes the sum of squared residuals as small as possible. R computes it; read and from the Estimate column of the summary output.
- Residual
Observed response minus fitted response. A positive residual means the model underpredicted the observed outcome.
- R-squared
The proportion of sample response variation accounted for by the fitted model. In simple regression with an intercept it equals r squared.
- Leverage and influence
Leverage means an unusual predictor value. Influence means the fitted model changes appreciably when that observation is removed; high leverage need not imply influence.
Formulas
Which procedure?
Delivery distance and travel time
For 26 deliveries with distances from 1 to 8 km, predict time at 5 km and find the residual for an actual time of 25 minutes. This is an original example with composed R output.
summary(lm(minutes ~ km, data = deliveries))
# Coefficients table (Estimate column only)
Estimate
(Intercept) 12
km 2
Residual standard error: 3 on 24 degrees of freedom
Multiple R-squared: 0.64, Adjusted R-squared: 0.625
sd(deliveries$minutes)
[1] 4.898979Substitute 5 into the fitted equation: 12 + 2(5) = 22 minutes.
Slope: each additional kilometer is associated with about 2 more minutes of travel time, on average. Intercept: 0 km is outside the observed 1–8 km range, so the 12 minutes only anchors the equation; it is not a meaningful delivery time.
Residual = 25 − 22 = +3 minutes: this delivery took longer than predicted.
Use Multiple R-squared (ignore Adjusted in simple regression): about 64% of the variation in delivery time is explained by its linear relationship with distance; the other 36% is left to other factors.
r is not printed: r = +√0.64 = 0.8, positive because the slope is positive.
RSE = 3 minutes: actual times typically differ from predicted times by about 3 minutes. Ignoring distance and always guessing the mean time would typically miss by the SD, about 4.9 minutes, so distance improves the predictions.
Predicted time is 22 minutes, with a +3 minute residual. A prediction at 20 km would extrapolate beyond these data.
Three-question check
Changing distance from kilometers to meters leaves which quantity unchanged?
Which observation has high leverage?