Every chapter of this book embeds interactive simulations at the exact point where the argument needs one. Each is a small self-contained page: a canvas, a few sliders or draggable points, and readouts that recompute as you move things. They run in any browser, on a phone or a laptop, need no login, and keep working offline once loaded. Nothing is sent anywhere and no plot is a picture; every number on screen is computed live from the data you are looking at.
The list below is the whole set, grouped by chapter, so you can come back to one without hunting through the text for it. Each simulation also carries a caption and a Try this instruction of its own, and the chapter page it belongs to links back to the section it argues for.
How to use these for self-study¶
Read the surrounding paragraph first, then predict what the simulation will do before you touch it. Say the prediction out loud or write it down: “if I drag that point up, the slope should swing and SSE should grow.” Then move the control and see whether you were right. The value is in the gap between what you expected and what happened, and that gap closes fastest when you commit to a prediction first.
Three habits pay off. Break it on purpose. Push a slider to the end of its range, drag a point somewhere absurd, set a sample size to its minimum. The identities that hold no matter what you do are the theorems; the quantities that fall apart are the assumptions. Watch two readouts at once. Most of these simulations are built around a relationship, not a single number, so the lesson is usually in how one readout moves while the other stays put. Repeat the random ones. Any simulation with a Draw or Shuffle button tells you very little in one press and quite a lot in a thousand, because the point is the shape of the pile, not the value of one draw.
For exam review, work down a chapter’s list and, for each simulation, write one sentence naming the result it demonstrates. If you cannot write the sentence, that is the section to reread.
Chapter 1: Regression as a way of thinking¶
Description and prediction from one line. Drag any of the 25 Toluca runs and watch one fitted line do description, prediction, and the extrapolation it cannot support.
Galton’s shallow line. Why the fitted line is flatter than the equal-heights line, and what regression to the mean really claims about tall parents.
Signal and noise in 20 coin tosses. A fixed systematic part plus random variation, the decomposition every model in the book uses.
Chapter 2: Simple linear regression¶
Hunting the smallest SSE by hand. Set your own intercept and slope and fail to beat the least-squares pair, which is what “least squares” means.
The residual identities never break. Drag the data anywhere and the sum of residuals, the weighted sum, and the fitted mean stay exactly where the theorem puts them.
Why the divisor is n minus 2. Repeated samples from a known variance show the n-2 divisor landing on it while the n divisor stays low.
The sampling distribution of b1. Fresh errors, same lot sizes, one fitted slope per sample, piling up into the distribution the standard error describes.
Least squares: drag a point. The same idea on eight generic points, with residual sticks drawn in, showing how a far-out point pulls harder on the fit.
Chapter 3: Inference for simple linear regression¶
What 95 percent confidence actually buys. Build intervals sample after sample and count how many catch the true slope, which is the only thing the confidence level promises.
Confidence band against prediction band. More data collapses one band and barely touches the other, because they answer different questions.
F is the slope t statistic, squared. Two tables of the same printout agreeing to every digit, in simple regression only.
Sampling distribution of the slope. A clean version on generic data: no single estimate equals the truth, but the pile of them centers on it and turns normal.
Chapter 4: Correlation¶
Set the correlation and look at the cloud. Attach a number to a picture, and see how far the sample r wanders from the value that generated it.
Pearson and Spearman under one moving point. One point drags Pearson’s r down by half while the rank correlation does not move.
Restriction of range. Narrowing which subjects you look at cuts r sharply while every individual observation stays exactly where it was.
Anscombe’s quartet, one slider. Four datasets with the same r, slope, intercept, and mean, and four completely different stories.
Chapter 5: Randomization and bootstrap inference¶
Permutation test for the punting slope. Shuffle the response against fixed predictors to build a no-association null distribution with no formula at all.
Case bootstrap for the punting slope. Resample with replacement to get a distribution centered on the estimate rather than on zero, and read a standard error off it.
Percentile and basic bootstrap intervals. Skew the bootstrap distribution and watch the two interval recipes come apart, which is why the choice matters.
Permutation test for a slope. The same argument on ten generic points, with the p-value counted directly off the shuffles.
Chapter 6: Matrix algebra for regression¶
Building X’X one entry at a time. Tap any entry of the product and see the row and column that produced it, with the arithmetic written out.
When a matrix loses its inverse. Flatten two columns toward each other and watch the determinant go to zero while the inverse blows up.
Least squares as a projection. Move the response vector in space; the fit stays in the column space and the residual stays perpendicular to it.
Chapter 7: The general linear model¶
The residual stays perpendicular. Drag the data anywhere and both entries of X’e, plus the Pythagoras gap between SST, SSR, and SSE, hold at zero.
The hat matrix is built from X alone. Moving a case vertically leaves every leverage value untouched; moving it sideways changes them at once.
The sampling distribution of b1. Repeated refits whose spread matches the standard error the matrix formula predicted in advance.
Chapter 8: Multiple regression in practice¶
Holding target population fixed. Slice the fitted plane and see why the partial slope differs from the marginal one, which is what “controlling for” buys.
Extra sums of squares and the general linear test. Enter the predictors in any of six orders; each extra sum of squares changes, the total does not.
Building an added-variable plot. Remove one predictor’s explanation from both axes step by step and watch the slope travel to the partial coefficient.
Chapter 9: Model diagnostics¶
Leverage values are a fixed budget. Slide one case along the predictor axis and watch the whole parabola of hat values redraw while their total stays put.
High leverage values, or actually influential?. Leverage values, raw residuals, studentized deleted residuals, and Cook’s distance responding together to one dragged case.
Pure error against lack of fit. Replicated observations split SSE into the part a better model could remove and the part nothing can.
Chapter 10: Remedial measures and transformations¶
A log-log slope is a percentage. Set an elasticity and compare the exact percent change against the approximation, and see where the approximation stops being safe.
Box-Cox: turn the lambda dial. The whole model refits at every lambda, so the residual funnel reshapes live alongside the log-likelihood.
Weighted least squares. Slide the weighting from equal votes toward the inverse-variance weights and watch which observations start to matter.
Curve and band overlays. A straight line and a back-transformed log model on the same curved, fanning data, with the interval band carried back to the original scale.
Chapter 11: Categorical predictors and interactions¶
Indicator coefficients are differences of group means. Set three group means by hand and read off the intercept and dummy coefficients a regression would report.
The interaction coefficient fans the lines apart. Move the interaction term and see why the gap you report depends on where you read it.
Centering moves the coefficients, not the curve. The fitted quadratic and its predictions stay put while the standard error and the column correlation change.
Raising the polynomial degree. SSE falls at every step, the test against a straight line does not keep up, and the extrapolation gets worse.
Chapter 12: Multicollinearity, selection, and validation¶
The valley the data leave for b1. Standard errors and VIF explode together while SSE does not move, because the data pin down the sum and not the split.
Four criteria climbing the same ladder. R-squared always picks the full model; adjusted R-squared, Cp, and BIC turn over at different places.
One split, one number. A single held-out sample can score the same model almost two points apart, which is the argument for repeated validation.
Chapter 13: Logistic regression¶
Walking the O-ring curve into the cold. Slide the launch temperature past the observed range and watch a fitted probability turn into a warning nobody heard.
Shaping the logistic curve. Set the coefficients by hand and score them with the log-likelihood, the quantity the fitting algorithm is climbing.
The same step, a different jump. A fixed change in the predictor multiplies the odds by the same factor everywhere but changes the probability by different amounts.
Move the threshold, move the errors. Sensitivity, specificity, and the classification table trading against each other along the ROC curve.
Chapter 14: Poisson and the GLM¶
One number sets the whole count distribution. Move the mean and the spread moves with it, because for a Poisson the variance is the mean.
Fitting the log link by hand. The fitted curve cannot dip below zero, and the coefficient reads as a multiplier rather than an addition.
What an offset pins down. Turn the exposure term off and the model predicts the same count for wildly different exposures.
What overdispersion costs a p-value. Raise the dispersion until the fit finally covers the data and watch conclusions that looked solid slide away.
Chapter 15: Regression with time¶
Autocorrelation and the standard error that lies. Residuals fall into runs, Durbin-Watson drops toward zero, and the reported standard error drifts further from the truth.
What Durbin-Watson looks like when nothing is wrong. The null pile gathers around 2, so you can see how far out a real diagnostic value sits.
Choosing the rho that quasi-differencing needs. Too little leaves the runs, too much makes the residuals zigzag, and the right value settles Durbin-Watson beside 2.
Train on the past, score on the future. In-sample error and out-of-sample error, and the prediction band that covers far less than it advertises.
Chapter 16: Path analysis¶
Raw slope and path coefficient. The standardized path and the correlation stay locked together for a single predictor, no matter how you move the data.
Direct, indirect, and total effects. Read the indirect effect straight off the vertical gap between the direct and total lines.
An omitted common cause. The wedge between the true path and the reported one is bias, so more data does not close it.