-
Midterm scope (test Tuesday, October 20, 2026): chapters 2, 3, and 5 — but not everything in them. Dummy variables and ANCOVA (today’s material, second half of this note) are excluded from this midterm; they’re included here for completeness, not exam prep.
-
Sections explicitly covered: 2.7; 3.1 and 3.2 (expect R output with a bad/problematic result to identify — regression diagnostics, see Regression Diagnostics and Leverage); 3.3, transformations.
-
Transformation example for non-constant variance: suppose we fit instead of , then check whether the residual plot shows the non-constant-variance (funnel) problem resolved. This is the same square-root-transformation fix described in Regression Diagnostics and Leverage.
-
Chapter 5 (MLR): covered up through 5.1, 5.2, 5.3 — where the class stopped, so that’s the chapter 5 cutoff for the midterm.
-
-
Midterm format: 50% R output, 20% multiple choice, 30% theoretical.
-
50% output: R output is given, and we provide the interpretation (not run the computation from scratch); expect to calculate values similar to the homework. Topics named explicitly: confidence intervals, hypothesis testing, interpretation of , filling in the ANOVA table.
-
20% multiple choice: conceptual.
-
30% theoretical: two flavors — one similar to homework-style problems, the other covering results proved in class (e.g. the proof below).
-
Specifically flagged: if a model is wrong (misspecified), how does that affect the residuals? This is the same idea as the quadratic-omitted-term example in Regression Diagnostics and Leverage — fitting a straight line when the truth has an extra polynomial term leaves a systematic pattern in the residuals.
-
Study tip given: for a case like true-quadratic-but-fit-linear, create the R output yourself and then answer good textbook questions against that output, as practice.
-
A formula sheet is allowed on the exam — size doesn’t matter.
-
-
Memorize (explicitly flagged): the /adjusted relationships — , , and the rewrite .
-
Grading rule for interpreting any coefficient, e.g. in : saying ” increases/decreases by per one-unit increase in ” is not enough on its own. You must explicitly state that the other variables are held constant — otherwise it’s 50% credit on that question.
Model selection and adjusted
-
The goal of this section is model selection: building the best overall model, not just checking whether one predictor still matters.
-
Partial - and -tests (is significant given is already in the model?) only answer a narrow question, one variable at a time.
-
Including a weak predictor doesn’t just fail to help — it can actively hurt the model, so a variable that isn’t pulling its weight should be identified and removed, not just tolerated.
-
-
, by its original definition, is the proportion of total variation explained by the regression:
-
-
Since (where is the residual/error sum of squares, same thing as ), , which gives the more commonly used form:
-
-
Why adjusted exists. Plain can only increase, or at best stay flat, as more predictors are added — even a completely useless one — because adding any column can only reduce , never increase it.
-
That means plain rewards padding a model with junk variables, and on its own can’t tell a useful predictor apart from a useless one once models differ in size.
-
Adjusted fixes this by also adjusting for sample size and the number of predictors :
-
Each piece is divided by its own degrees of freedom: is the unbiased estimate of , and is the unbiased estimate of .
-
Adding a predictor costs a degree of freedom in the numerator ( shrinks) regardless of whether actually drops by much — which is exactly how an unhelpful predictor can drag adjusted down even while plain ticks up.
-
-
Rewriting adjusted directly in terms of plain . Since :
-
This makes the penalty explicit: is always and grows as increases, inflating ‘s contribution the more predictors are in the model.
-
If increases while the error (, hence plain ) stays exactly the same — the new predictor is genuinely useless — adjusted necessarily decreases, since the penalty factor grows while doesn’t shrink to compensate.
-
-
Proof that always (an aside worked through in class).
-
Want: .
-
Subtract from both sides and multiply by (flips the inequality): .
-
Since , this holds exactly when , i.e. , i.e. — always true.
-
So for any , with equality only when (no predictors) or (a perfect fit, ).
-
-
Adjusted and are equivalent criteria for comparing models of different sizes.
-
, and rewriting adjusted directly in terms of it: .
-
and depend only on the response data , not on which predictors are in a given model, so is a fixed constant across every model being compared on the same data.
-
So and differ only by that constant and a sign flip: whichever model minimizes also maximizes .
-
Worked example: model has , model has . Model is preferred — it has less error — and correspondingly , the two criteria always agree.
-
-
Rule of thumb: when comparing models with the same number of predictors, plain is a fine comparison. Once the two models being compared have different numbers of predictors, switch to adjusted (prefer higher) or (prefer lower) instead.
-
The “variables added last” procedure is one concrete way to put this to use:
- Enter the full pool of candidate predictors into the model.
- Assess each variable’s worthiness as if it were entered last, i.e. controlling for every other variable already present.
- Remove the weakest one, if it isn’t pulling its weight.
- Refit, and reassess every remaining variable as added-last again.
- Repeat until every remaining variable is important.
-
Worked example — single-predictor models. Predicting a city’s homicide rate (, ) from three candidate predictors: population (), income (), unemployment rate (). Fitting each alone:
-
: , adjusted — population alone explains almost nothing, and the penalty for using up even one predictor pushes adjusted negative.
-
: , adjusted .
-
: , adjusted — the strongest single predictor.
-
Ranking by adjusted : (unemployment) strongest, (income) close behind, (population) essentially useless alone.
-
-
Worked example — two-predictor models. Fitting gives , adjusted — up from alone’s .
-
The sequential sum-of-squares breakdown (
aov()): ‘s own contribution is just , while contributes , out of a regression total of — almost all the explained variation comes from . -
is still contributing almost nothing even with already in the model.
-
The same pattern shows up pairing with instead: ‘s sequential SS stays at , contributes .
-
is weak no matter which other predictor it’s paired with — this is exactly why plain alone can’t flag as unhelpful (it ticks up slightly either way), while adjusted ‘s penalty is what actually discriminates a useful predictor from a useless one.
-
Dummy variables and analysis of covariance (ANCOVA)
Not covered on Exam 1 — reference material only.
-
Framing: we already have a model with a continuous variable, and want to study whether we should add a categorical variable to it. In R-style formula notation: , one continuous variable and one categorical variable .
-
A dummy variable is a variable that takes a finite number of values, used to code the categories (“levels”) of a categorical variable for use in a regression model.
- An indicator variable is the simplest kind: for membership in one particular category, otherwise.
-
Example: gender. If starting salary and the predictor is gender (male/female), how do we express in terms of gender?
-
Text category labels (e.g. “female,” “male”) can’t go directly into a regression — gender has to be encoded as an indicator variable first.
-
With two levels, only one indicator is needed: for Female, for Male. Using a second indicator for the other level would be redundant, since knowing one tells you the other.
-
General rule: a categorical variable with levels gets dummy variables, with one level left out as the baseline.
-
This connects back to comparing two population means (the two-sample test): coding gender as a single indicator and regressing on it is exactly the regression version of a two-sample mean comparison. With three or more groups, the analogous classical tool is ANOVA — and that comparison can be done with regression too, using indicators instead.
-
-
Example: house price with a 3-level location variable. price of house, area footage, location, coded in town, inner suburb, outer suburb.
-
Wrong approach #1: treat as an ordinary numeric predictor, . Wrong, because it forces a constant per-unit effect as goes , treating category labels as if they were an ordered numeric scale.
-
Convert into 3 indicators instead: if in town, if inner suburb, if outer suburb (each otherwise).
-
Wrong approach #2: use all 3 indicators together with the intercept, . Also wrong — exactly one of the three indicators is always (the other two are ), so always, making the intercept and all three indicators redundant together.
-
The fix: drop one indicator (here, , so in-town becomes the baseline) and use only .
-
-
Model assuming parallelism (same slope across groups, different intercepts):
-
Substituting each group’s indicator values collapses the formula into that group’s own line:
- in town ():
- inner suburb ():
- outer suburb ():
-
“Parallelism” means all three groups share the same slope — three parallel lines, just shifted up or down.
-
’s interpretation: the shift in mean price between inner-suburb and in-town homes, holding area fixed. ( is the analogous shift for outer suburb.)
-
Key takeaway: the three lines being parallel but shifted means location matters. If location didn’t matter at all, and all three lines would collapse onto one single line.
-
-
Model with interaction terms (allowing different slopes too, not just different intercepts):
-
The terms and (indicator multiplied by the continuous variable) are called interaction terms — they let the effect of on depend on, interact with, which group a point belongs to.
-
Substituting each group’s indicator values the same way as before:
- in town:
- inner suburb:
- outer suburb:
-
‘s interpretation: the difference in slope between inner-suburb and in-town homes.
-
Unlike the parallelism model, the three lines are no longer forced to share a slope — so they can intersect, which is the geometric picture behind calling these “interaction” terms.
-
Visual intuition: plotting versus alone, without separating by location, can look like a meaningless scatter or several disconnected clusters — fitting one line to all of it doesn’t make sense, because there are really several populations hiding inside the data, one per location.
-
-
Four geometric cases worth recognizing on a scatterplot of vs. , split by group:
-
Parallel lines (equal slopes, unequal intercepts) — location shifts the intercept only.
-
Equal intercepts, unequal slopes — all groups start from the same point but fan out at different angles.
-
Unequal slopes, unequal intercepts — the general interaction-model picture; lines can cross anywhere.
-
Coincident lines (equal slopes, equal intercepts) — all groups share one single line; location doesn’t matter at all.
-
-
A staged decision procedure for testing which case you’re in, starting from the full interaction model:
- Test (no interaction) against : at least one nonzero.
- Reject → the slopes genuinely differ; stop here and keep the full interaction model.
- Fail to reject → drop the interaction terms, move to the parallelism model, and continue.
- Within the parallelism model, test (same intercept) against : at least one nonzero.
-
Reject → the lines are parallel but have different intercepts: location matters, shifting the intercept only.
-
Fail to reject → the lines are coincident: one single line fits all groups, location doesn’t matter at all.
-
-
Which test to run next depends on the outcome of the previous one — a nested, sequential procedure, not three independent tests run all at once.
-
Equivalently, testing all four coefficients together, against : at least one nonzero, is the single broadest test of whether the categorical variable belongs in the model at all.
- Test (no interaction) against : at least one nonzero.