Simulated Nulls · Two groups

Do Mosquitoes Prefer Beer Drinkers?

Shuffle the group labels to build a null world for a difference in means, then compare the result with Welch's \(t\)-test and the bootstrap.

Shuffle the Drink Labels

In an experiment, 43 volunteers were randomly assigned to drink beer (25 people) or water (18 people), and each one's attractiveness to mosquitoes was measured (Lefèvre et al. 2010). The data here are synthetic counts of mosquito bites for the same design, made after a talk by John Rauser: the beer drinkers averaged 23.60 bites and the water drinkers 19.22, a difference of 4.38.

If the drink made no difference, each volunteer would have received the same number of bites whichever drink they were given, and the gap between the groups would come only from which volunteers happened to be assigned to beer. Make datasets from that null world by shuffling the drink labels, and see how often they show a difference at least this large.

First, a guess: in a null world where the drink makes no difference, how often would shuffled labels give a difference of at least 4.38 bites?

Data
Null world
Alternative

Differences in mean bites from every simulated dataset

This Test's Choices

  • Test statistic: the difference in mean bites, beer minus water, 4.38.
  • Null model: the drink has no effect on anyone's bites, and either
    • shuffle labels: keep each volunteer's bites and assign 25 of the 43 volunteers to beer at random, as the experiment did; or
    • resample everyone: draw 43 volunteers with replacement from all 43, ignoring their drink, and call the first 25 beer drinkers and the other 18 water drinkers.
  • Alternative hypothesis: beer increases bites, so only large positive differences count against the null; or the drink makes any difference, so differences far from zero in either direction count.

Because the drinks were assigned at random, every split of the 43 volunteers into 25 beer drinkers and 18 water drinkers was equally likely to be the one chosen. If the drink made no difference to anyone's bites, each split would have shown the same bites, only labeled differently, so shuffling the labels draws from exactly the differences the experiment could have produced. It needs no assumption about how bites are distributed. Of 1,000,000 shuffles, a proportion of 0.0005 gave a difference of at least 4.38 bites, about 1 in 2,000.

Welch's \(t\)-Test

Welch's \(t\)-test asks only about the means: are the two groups' mean bites equal, whatever their standard deviations? It divides the difference by its standard error and compares the result with a \(t\) distribution, which approximates the null distribution of that ratio and is close when each group's bites are roughly Gaussian. For these data \(t = \) 3.66 with 39.1 degrees of freedom, and the one-sided p-value is 0.0004, close to the shuffled labels' answer.

With group means \(\bar y_b, \bar y_w\), standard deviations \(s_b, s_w\) and sizes \(n_b, n_w\): \[t = \frac{\bar y_b - \bar y_w}{\sqrt{s_b^2/n_b + s_w^2/n_w}}, \qquad \nu = \frac{\left(s_b^2/n_b + s_w^2/n_w\right)^2}{\dfrac{(s_b^2/n_b)^2}{n_b - 1} + \dfrac{(s_w^2/n_w)^2}{n_w - 1}},\] With \(T_\nu\) a variable with a \(t\) distribution on \(\nu\) degrees of freedom, the one-sided p-value is \(\mathbb{P}(T_\nu \geq t)\) and the two-sided p-value ("Any difference") is \(2\,\mathbb{P}(T_\nu \geq |t|)\).

Bootstrap Tests and Intervals

"Resample everyone" is a bootstrap test of a closely related null, that both groups' bites come from one distribution: it pools the two groups and resamples with replacement. Its p-value is approximate, while the shuffle's is exact for a randomized experiment, so the shuffle is the more accurate test here (Hesterberg 2015). The bootstrap's main use here is a bootstrap confidence interval for the difference, which resamples each group separately, without imposing the null. Each group keeps its own standard deviation, and the resampled differences are centered on the observed 4.38 instead of on zero.

Differences from the null world and from resampling each group

For the beer data, the middle 95% of the resampled differences runs from about 2.1 to 6.7 bites. This 95% bootstrap interval is a range of values for the difference in mean bites that fit these data. Its width comes from how much the difference varies between resampled datasets, which estimates how much it would vary between repeated experiments like this one. (With groups this small, an interval taken straight from the middle of the resampled differences runs a little narrow; Welch's \(t\) interval, 2.0 to 6.8 bites, is slightly wider.) The p-value answers a different question: how often a null world produces a difference at least this large.