Midterm Test coverage

For each lecture topic, this page lists what is examinable on the term test and what is not. The test is open handout: the test reference sheet is distributed in advance and gives R syntax for the verbs used in the course, so you are not expected to memorize syntax. You are still expected to know what each function does and when to use it. Test 1 covers everything through Week 3. The list will be extended for Test 2 in August.

Legend: on the test  |  not on the test (or syntax given on the handout, so not testable from memory).

R basics, functions, vectors, data frames

On the test
  • Defining a function and calling it; the print-vs-return distinction.
  • Conditionals: if (cond) { ... } else { ... }.
  • Building a vector with c(); indexing and boolean masks.
  • Combining masks with &, |, !.
  • Subsetting a data frame by mask: df[df$x > 0, ].
  • Applying a function to every element of a vector with sapply.
  • Reading short pieces of code and saying what they compute.
Not on the test
  • Memorizing function-definition or indexing syntax (it is on the reference sheet).
  • Writing an algorithm in the sense of, e.g., sorting a vector by hand — you will only be asked to write "algebra in order."

Tidyverse / dplyr

On the test
  • Knowing what each dplyr verb does and when to use it: filter, select, arrange, rename, mutate, group_by, summarize, distinct, n_distinct.
  • Reading a pipeline written with %>% and saying what data comes out.
  • Expect at least one question that uses these verbs.
Not on the test
  • Memorizing the exact argument order of each verb — signatures are on the reference sheet.
  • ggplot syntax. You will not be asked to write ggplot code.

Probability review

On the test
  • Conditional probability and independence.
  • Bayes' rule and the law of total probability.
  • Boy-and-girl-style conditional-probability puzzles.
Not on the test
  • Anything beyond what was covered in the probability-review notes.

Maximum likelihood

On the test
  • Deriving the MLE for Bernoulli on paper.
  • Finding the MLE numerically by grid search (writing the loop / sapply over a grid of parameters; which.max).
  • Recognizing that linear regression is MLE under Gaussian noise (conceptually).
Not on the test

Nothing specifically excluded.

Bayesian inference

On the test
  • Prior, likelihood, posterior; computing a posterior on a grid (prior × likelihood, then normalize).
  • The coin example in code.
  • The Bayesian comparison of two means (the finches setup).
Not on the test

Nothing specifically excluded.

Hypothesis testing

On the test
  • Stating a null hypothesis and a test statistic.
  • Computing a p-value by simulation: build a null distribution with replicate(...); compute mean(sim_stat >= observed) for one-sided, the absolute-value version for two-sided.
  • One-sided vs two-sided tests; what the 5% threshold means.
  • The ASA statement on p-values, at the level we discussed.
  • Type I / II / S / M errors — what they are, when to worry about each.
  • Publication bias, p-hacking, the garden of forking paths, the dead-salmon study as worked examples.
Not on the test

Nothing specifically excluded.

Linear regression

On the test
  • Writing an lm formula and saying what it fits.
  • Interpreting coefficients, including the sign and magnitude.
  • Indicator variables for categorical predictors and what it means to leave one category out as the baseline.
  • When a continuous variable should be encoded as categorical (the gnarly question from the 2019 test).
  • Reading summary(lm(...)): coefficients, standard errors, p-values, R-squared.
  • Computing SSE for the model and for the baseline.
Not on the test
  • Memorizing lm or predict syntax (on the reference sheet).

Logistic regression

On the test
  • Writing a glm(y ~ x, family = binomial, data = df) formula and interpreting its output (as in the sample test from the 2019 SML201 term test).
  • Going from the linear predictor to a probability with plogis.
  • Classification accuracy, the base-rate problem, FPR / FNR / PPV / NPV.
  • Reading an ROC curve and picking a sensible operating point given a cost story (as in MP2's "doctor with 25 charts").
  • Identifying assumptions in a model (e.g. the made-up failure-probability formula in MP2) and explaining in English why an assumption may not hold.
Not on the test
  • Memorizing glm syntax — it is on the reference sheet.
  • Plotting an ROC from scratch in ggplot.

Confidence intervals

On the test
  • What a 95% CI actually means (and what it does not).
  • Reading a CI off a summary(glm(...)) table using Estimate +/- 1.96 * Std. Error.
  • The CI ↔ p-value duality.
Not on the test
  • Looking up critical values for other confidence levels (use the 1.96 approximation).

Regression diagnostics

On the test
  • The assumptions (linearity, normality of residuals, independence).
  • Reading the four plot(model) diagnostic plots and saying what each tells you.
  • Identifying outliers and high-leverage points.
  • Multiple comparisons and what the F-test is for.
Not on the test
  • Producing the plots from scratch — you only need to read them.

Correlation, R-squared, and causation

On the test
  • R-squared as a comparison to the constant-prediction baseline; what "close to 0" and "close to 1" mean.
  • Reading R-squared off the Multiple R-squared line of summary(model).
  • Correlation as the signed square root of R-squared (single-predictor case).
  • The four alternatives to causation: reverse causation, common cause, indirect causation, coincidence.
  • Anscombe's quartet: why visualization matters and how a single high-leverage point can dominate R-squared.
Not on the test
  • Deriving the R-squared formula from first principles.

Training, validation, and test sets

On the test
  • Identifying which set is which and what each is for.
  • Why training accuracy is misleading.
  • Why one-hot / categorical encoding cannot hurt training fit.
  • The index-sampling pattern for splitting a data frame — this is the one piece of code worth memorizing, because everything else falls out from the concept.
  • Using replicate(...) to estimate validation-accuracy variability (and the variability of estimates more generally).
Not on the test
  • k-fold cross-validation library functions (we did not cover them).

“The truth about linear regression”

On the test
  • Collinearity and what it does to coefficient estimates and their standard errors.
  • Omitted-variable bias (Fisher and smoking; ice cream and drownings).
  • Interpreting "the gender wage gap controlling for X" — what the control changes about the claim.
  • The Harvard admissions lawsuit as a controls example.
  • Errors in variables: what bias they create.
  • Interactions (avocado / bacon) — what the interaction term is doing.
Not on the test
  • Algebraic derivations of bias terms.

Mini-project 2 (ICU adverse outcomes)

On the test
  • The glm formula used in MP2; what each predictor means.
  • Interpreting the fitted coefficients.
  • Identifying training, validation, and test sets.
  • Reading the ROC and reasoning about a threshold for the "doctor with 25 charts" cost model.
  • Explaining in English why one of the model assumptions might not hold.
Not on the test
  • The file-loading boilerplate from MP2 part 1 — not testable.
  • Producing the cost-vs-threshold curve in ggplot.

Workflow topics (agentic scraping etc.)

On the test
  • Nothing testable on the term tests — these support the course project.
Not on the test
  • Arctic Shift API details, VS Code agent UI, scraping-library specifics.

If you think something is on the wrong side of a line, ask on Piazza and this page will be updated.