Labs

The course’s simulation strand

What the labs are for

Statistical inference is easier to trust once you have watched it happen many times over, not just once. The five labs in this course are the simulation strand: a thread of R-based exercises that runs alongside the week notes, giving you a place to see sampling variability, likelihood, resampling, randomization, and Bayesian updating play out computationally, over and over, rather than in a single static example.

The labs support the reasoning you build in the notes — they do not replace it. A note develops the concept, the notation, and the worked examples by hand; the matching lab lets you re-derive the same idea by simulation, so you can compare “what the formula says” against “what actually happens across many simulated samples.” Neither one stands alone. If a lab result and a note’s formula-based result disagree by more than simulation noise should allow, that mismatch is itself worth noticing and asking about.

The shared lab anatomy

Every lab in this course is built from the same five parts, in the same order, so once you know the pattern you can move through any lab efficiently:

  • Idea & goal. A short statement of the concept the lab illustrates and what you should be able to say or compute by the end of it.
  • Setup. What you need before starting — the relevant note, any background from the recurring MAC Study, and the base-R tools the lab will use.
  • Numbered steps. A sequence of ### Step sections, each with a short explanation and a shown base-R code chunk. The code is real, runnable base R (sample(), replicate(), mean(), and similar building blocks) — never a specialized inference package — so the mechanics stay visible line by line. Every simulation chunk carries set.seed(35103), so the same code produces the same result every time it is actually run.
  • Verify. A short check for whether your simulation behaved as expected — usually a comparison to a formula-based answer from the companion week note. Numbers here are drawn from the MAC Study exactly as locked in the companion note.
  • AI use note. A short table naming any AI tool a student might reasonably use while working through the lab (for example, an AI coding assistant), the purpose it can legitimately serve, and how you would verify its output yourself rather than trusting it directly.

The five labs

Lab Companion week What it simulates
Lab 2 — Simulating sampling distributions Week 2 Sampling distributions: repeatedly draw samples from a known world and watch the sample mean’s own distribution take shape.
Lab 6 — Likelihood curves Week 6 Likelihood curves: compute and plot the likelihood function across candidate parameter values to see the maximum emerge.
Lab 10 — Bootstrap intervals Week 10 Bootstrap intervals: resample the data in hand, with replacement, to build a confidence interval without assuming a known standard error.
Lab 11 — Randomization tests Week 11 Randomization tests: shuffle group labels to build a null distribution for a group difference from scratch.
Lab 12 — Simulating the posterior Week 12 Posterior distributions: simulate draws from a Beta posterior to see Bayesian updating as a distribution, not just a formula.

These five topics are named directly in the syllabus’s “Inference labs” line; the lab numbers match the week each one pairs with, and no other week has a companion lab.

A note on the code

Every R chunk you see in a lab on this site is shown for study, not executed on this site. The chunks are base R, each carries set.seed(35103) wherever randomness is involved, and each is written to be reproducible line-for-line if you copy it into your own R or RStudio/Posit Cloud session. Reading the code and predicting what it will do before you run it is itself part of the exercise.

Public vs. graded

The graded deliverable, its rubric, and due date live in Blackboard (the LMS) — this page is study and practice only.