Formulas as shortcuts
The t test is a shortcut for the pile of shuffles. See when the shortcut works, what it costs, and how to read a disagreement.
What runs in CodeSplash
- STAT011Welch t test Runs in CodeSplash
- Two-sample t-test (Welch / Student, or z test) Verified in Python and R
- Permutation test (two independent groups) Verified in Python and R
You will be able to
- Explain a reference distribution as a stand-in for a simulated null
- Compare a simulated p-value with a formula p-value
- Say what a disagreement between them tells you
Read first
Two routes to one answer
ReadYou've built a p-value by shuffling. Before computers were cheap, nobody could shuffle 2,000 times. So statisticians worked out what the pile looks like: for a difference in means, it follows a t distributiont distributionA bell curve with heavier tails, for a statistic divided by a noise estimated from the data..
For tooth growth, the two routes give:
- Shuffling: p = .066
- Welch's t test: p = .061
They agree closely. The curve really is a good stand-in for the pile.
What does an outlier do?
PredictPredict first
Add one extreme value to the second group. The shuffle and the t test both compare means. What happens to their p-values?
Reveal
They stay close, and both change. Shuffling doesn't protect you here, because the outlier moves the mean, and the mean is what's being compared. To resist the outlier, change the statistic rather than the method.
See it
ExploreTurn on Add an outlier and compare Permutation p with Welch t p. Then switch Statistic to the median and see which number barely moves.
BExplorable · Permutation shuffler
Could a difference this large come from shuffling the labels alone?
Shuffle the labels a thousand times. How often will the shuffled difference be as large as the real one?
Data
Statistic
+30 on the last value of the second group.
Commit your prediction above to see the result
Make your prediction to see the result.
Where the shortcut comes from
ReadDivide the signal by its estimated noise, and you get a statistic whose distribution doesn't depend on the unknown spread:
Because the noise is estimated, varies more than a normal variable does, especially with little data. So small samples need a wider cut-off than 1.96.
Feel the small-sample penalty
ExploreChange Degrees of freedom and watch t critical (5%) approach the normal value.
BExplorable · t against z
Why do small samples need the t distribution instead of the normal?
Guess the two-sided 5% critical value of t for these degrees of freedom.
Commit your prediction above to see the result
Make your prediction to see the result.
Try a shortcut that breaks
ExploreShortcuts rely on large-sample theory, so they struggle where data are few. For counts, the normal curve can be badly off.
Find a count where the normal approximation says p < .05 and the exact test doesn't. Then turn on the break-it setting.
EExplorable · Exact test or normal approximation?
When can you trust the normal approximation to a binomial test?
What is the exact two-sided p-value here?
Colored bars count toward the exact two-sided p: every outcome no more likely than the one you saw. The curve is the normal approximation.
Commit your prediction above to see the result
Make your prediction to see the result.
Check your reading
CheckpointCheck yourself
A shuffle and a t test on the same data give p-values of 0.041 and 0.044. What should you conclude?
Show the answer
Answer: a
Small differences are normal: the shuffle has simulation noise, and the curve is an approximation. Choose your method before you see the results, and report that one.
Check yourself
A shuffle and a t test disagree badly in a small, skewed sample. What does that suggest?
Show the answer
Answer: b
A disagreement is information. Look at the shape of the data and which statistic answers your question.
Run both on your data
In the appRun a t test and a permutation test on the same outcome and groups. If they agree, the shortcut is safe for these data.
Recap
Recap- A formula's reference distribution is a stand-in for a simulated pile.
- When the two agree, the shortcut is working.
- An outlier affects any method comparing means. To resist it, change the statistic.
- Shortcuts fail most often with little data, especially with counts.
Concepts in this lesson