Going-Further Boxes

Design mockup for the December pass · not part of the site

The reading-time chips here are placeholders. In December a small filter would count each box’s words and fill them in. Click any box to open or close it.

1 · The legend, in a Module’s “How to use this page” box

How to use this page

This Module is both a guided introduction and a reference you’ll come back to all semester. On a first pass, read the main text and work the check questions at the end of each section.

Going-further boxes are extras. They start folded, and the labs, exams, and projects don’t depend on them. Each one is labeled with its kind:

Why it worksthe math or a simulation behind a result
More Rother code for the same job, or a nicer output
Other methodswhat to use when the standard analysis doesn't fit

The sentence “the labs, exams, and projects don’t depend on them” goes live only after the December audit. Today one box breaks that promise: the M09 pre-study’s Tukey box, which Exam 2 tests.

2 · Folded, as students first see them

The pooled standard deviation combines the spread of both groups into one number, weighting each group by its degrees of freedom. You’ll use it every time you compute Cohen’s d for two independent groups, so it’s worth knowing what goes into it.

Each group’s variance estimates the same population variance, if the two groups share one. Pooling averages the two estimates, giving more weight to the group with more information, that is, more degrees of freedom:

\[ s_p = \sqrt{\frac{(n_1 - 1)\,s_1^2 + (n_2 - 1)\,s_2^2}{n_1 + n_2 - 2}} \]

The numerator adds up each group’s sum of squared deviations, and the denominator is the total degrees of freedom. With equal group sizes, \(s_p^2\) is simply the average of the two variances.

Before fitting a multiple regression, look at every pair of variables at once. A scatterplot for each pair shows the shape of each relationship, and any outliers, before a model summarizes them.

The GGally package draws every pairwise scatterplot, each variable’s distribution, and each correlation in one figure:

bread_peace |>
  select(vote, growth, fatalities) |>
  GGally::ggpairs()

The two-sample t-test compares means, and it works well when each group’s distribution is reasonably symmetric or the groups are large. When neither holds, a rank-based test is one alternative.

The Mann–Whitney U test ranks all the observations together, then asks whether one group’s ranks tend to be higher than the other’s. It doesn’t assume normal distributions within groups. In R it is wilcox.test(), with the same formula as t_test().

3 · Opened

TipGoing further · Why it works With two groups, ANOVA is the t-test 3 min

With two groups, the one-way ANOVA’s F is exactly the square of the pooled two-sample t: \(F = t^2\). The p-values match, because the two tests are the same comparison written two ways.

lm(score ~ group, data = d) |> anova()

4 · Variant B: a color for each kind

Same layout. “More R” takes the dark Nord color of the site’s code blocks, and “Other methods” takes spruce. Spruce is also the guiding-question box’s color, so the two would share a color.

Body text.

Body text.

Body text.

5 · For comparison: today’s box

Body text.

6 · How a box would be written in December

A short filter would build the label, icon, and reading time from one attribute, so the source gets simpler than today’s:

::: {.going-further kind="why"}
## Where does the pooled SD come from?

…the box's content…
:::

kind takes why, code, or methods. The box always starts folded.