STAT 200 · Statistics for Economics

t Tests for One and Two Means

When you must estimate the spread from a small sample, the t test compares one average to a target or two averages to each other.

Key takeaways

  • A t test is a hypothesis test for averages when you must estimate the spread from your own sample.
  • The t statistic is the gap between the sample average and the claimed value, divided by the standard error built from the sample's own standard deviation.
  • The t curve has fatter tails than the normal curve, and it fattens most when the sample is small.
  • The degrees of freedom, usually n − 1 for one sample, tell you which t curve to use.
  • A two-sample t test asks whether two group averages differ by more than luck would explain.

Picture Ana, who runs a pizza delivery shop. Her sign promises "30 minutes or less, on average." A customer grumbles that it never feels that fast. So Ana times 16 deliveries. The average comes out at 33 minutes. Is her promise broken, or did she just time a few unlucky nights?

In the last lesson we tested a claim by measuring how many standard errors a sample sat from the claimed value. That recipe had a hidden cheat. We pretended we knew the true standard deviation of the whole population. Ana does not. She has only 16 timings. This lesson fixes the cheat, and the fix is one of the most used tools in all of economics: the t test.

The problem with guessing the spread

The test statistic from last time was z = (sample average − null value) ÷ (σ ÷ √n). It needs σ, the true standard deviation of the population. In real life you almost never know σ.

The natural move is to swap in s, the standard deviation you computed from your own sample. (You met it in the lesson on spread.) But s is itself a guess, and it bounces around from sample to sample. With a small sample it can come out too low or too high by a lot. Using it as if it were the truth would make us overconfident.

In 1908 a brewery chemist named William Gosset worked out the right fix. He published under the pen name "Student," so the result is called Student's t distribution. The new statistic is:

t = (sample average − null value) ÷ (s ÷ √n)

Same shape as z. The only change is that the noise in the denominator comes from the sample.

The one-sample t statistic
t = x̄ − μ₀ ÷ s ÷ √n t = Test statistic Standard errors between the sample average and the claim x̄ − μ₀ = The gap Sample average minus the null value s ÷ √n = Standard error Sample standard deviation over the square root of n t = x̄ − μ₀ ÷ s ÷ √n t = Test statistic Standard errors between the sample average and the claim x̄ − μ₀ = The gap Sample average minus the null value s ÷ √n = Standard error Sample standard deviation over the square root of n

Exactly like z, except the spread is estimated from the sample itself.

Fatter tails, and degrees of freedom

Because s is uncertain, a t score is more likely than a z score to land far from zero. So the t curve has the same bell shape as the normal curve but with fatter tails. To call a result surprising, you need to go farther out.

How much fatter depends on degrees of freedom, written df. For a one-sample test, df = n − 1. Roughly, df counts how many independent pieces of information went into estimating s. A sample of 16 gives df = 15. More data means a better estimate of s, so the t curve slims down toward the normal curve.

The t curve has fatter tails than the normal curve
Relative likelihood Normal curve t curve, df = 4 fatter tail Standard errors from the null (center = 5) Relative likelihood Normal curve t curve, df = 4 fatter tail Standard errors from the null (center = 5)

Here is how the 5% two-sided cutoff changes with df. These are standard table values.

Degrees of freedom Cutoff for a two-sided test at 5%
5 2.571
10 2.228
15 2.131
30 2.042
120 1.980
Very large 1.960 (the normal cutoff)

Spreadsheets and statistics software find these for you. Still, it helps to see the pattern: the smaller the sample, the higher the bar.

Worked example: Ana's delivery times

Ana's claim is that the average delivery takes 30 minutes. Follow the steps.

  1. Hypotheses. H₀: the true average is 30 minutes. H₁: the true average is not 30. (If she only cared about being too slow, she could use a one-sided test.)
  2. Level. α = 5%.
  3. Data. She timed n = 16 deliveries. The sample average was 33 minutes, and the sample standard deviation was s = 6 minutes.
  4. Standard error. s ÷ √n = 6 ÷ 4 = 1.5 minutes.
  5. Test statistic. t = (33 − 30) ÷ 1.5 = 2.
  6. Cutoff. df = 16 − 1 = 15. The two-sided 5% cutoff from the table is 2.131.
  7. Conclusion. Since 2 is smaller than 2.131, Ana fails to reject H₀.

Compare this with the z version. If those same numbers had come with a known σ, the cutoff would be 1.96 and she would have rejected. The t test is more cautious, because with only 16 timings her estimate of the spread is shaky. That is the whole point of Student's fix.

Note the careful wording. Ana has not proved her delivery promise is true. She has only found that 16 deliveries are not enough to call it false. Time 60 deliveries and the verdict could change.

Comparing two means

Often the question is not "does this match a target?" but "do these two groups differ?" Two food trucks, Taco Tide and Noodle Nook, park on the same street. Taco Tide's owner wonders whether her daily tips beat the other truck's. She collects 25 days from each.

  • Taco Tide: average tips 84 dollars, standard deviation 10.
  • Noodle Nook: average tips 78 dollars, standard deviation 10.

The null says the two true averages are equal, so their difference is 0. The standard error of a difference adds the noise from both groups:

SE = √( s₁² ÷ n₁ + s₂² ÷ n₂ )
   = √( 100 ÷ 25 + 100 ÷ 25 )
   = √( 4 + 4 )
   = √8
   ≈ 2.83

t = (84 − 78) ÷ 2.83 = 6 ÷ 2.83 ≈ 2.12

With 25 days in each group and equal spreads, the degrees of freedom come to about 48, and the 5% two-sided cutoff is about 2.01. Since 2.12 beats 2.01, we reject the null. A gap of 6 dollars is bigger than luck alone would usually produce. (If the spreads or sample sizes differ, software uses a slightly adjusted df. This version is often called Welch's t test.)

Which t test fits the question?
One-sample t test Compare its average to a target value Two-sample t test Differences between group averages Paired t test Test the average of the differences Separate Matched pairs Are the groups separate? Different people or firms in each One group Two groups What are you comparing? Averages of a numeric measure What are you comparing? Averages of a numeric measure One group: One-sample t test Compare its average to a target value Two groups: Are the groups separate? Different people or firms in each Separate: Two-sample t test Differences between group averages Matched pairs: Paired t test Test the average of the differences

Ask first how many groups there are, and whether the data come in matched pairs.

Why n − 1?

The "minus 1" puzzles many students. Here is the idea with tiny numbers. Suppose you know that three delivery times average exactly 30 minutes. If I tell you the first two are 25 and 36, the third is no longer free to vary. It must be 29, because the three must add to 90. Once the average is pinned down, only two of the three values can move freely. So the spread carries n − 1 pieces of free information, not n.

This also explains why s uses n − 1 in its own formula. Dividing by n − 1 corrects for the fact that the sample average sits closer to the sample's own data than the true average would. You will see the same idea again in the lesson on estimators.

Reading a software report

You will rarely do these steps by hand. A spreadsheet or statistics package gives you a table with the sample average, the standard error, t, the degrees of freedom, and a p-value. The p-value is the chance of a gap at least as big as yours if the null were true. Reading it correctly takes some care, so the next-but-one lesson is devoted to it.

For now, check that you can find three things in any report: the gap (sample average minus null value), the standard error under it, and t, which is the first divided by the second. If t is small, the gap is within the usual wobble. If t is large, the gap stands out.

A good habit is to also write the gap in plain units. "Taco Tide earns 6 dollars more per day" tells a reader far more than "t = 2.12." The t score says whether a gap is believable. The dollars say whether it matters. A gap can be real and still too small to change anyone's decision.

The paired version

Sometimes the two sets of numbers belong together. You measure the same ten stores before and after a minimum wage change. Or twins, or the same shop in two seasons. Then each row is a matched pair. The trick is simple: subtract within each pair to get one list of differences, then run a one-sample t test on those differences against a null value of 0. Pairing removes a lot of noise, because each unit is compared with itself.

A common mistake: ignoring the assumptions

The t test works well when the data are roughly bell shaped, or when the sample is large enough that the central limit theorem steps in. It also assumes the observations are independent, and that your sample is random. Two traps follow.

First, a handful of wild outliers in a small sample can distort the average and the spread alike. Look at a histogram first, as in the lesson on pictures of data.

Second, a t test cannot rescue a biased sample. If Ana timed only deliveries to the nearest block, no formula would fix her answer. The math checks luck. It does not check how the data were gathered.

Words to know

t statistic the gap between a sample average and the null value, measured in standard errors that use the sample's own standard deviation.

Student's t distribution a bell-shaped curve with fatter tails than the normal curve, used when the spread is estimated.

Degrees of freedom (df) a count of independent pieces of information, equal to n − 1 in a one-sample test.

Standard error the typical distance between a sample average and the true average.

Two-sample t test a test of whether the averages of two separate groups differ.

Paired t test a test on the differences within matched pairs, compared against zero.

Welch's t test a two-sample test that allows unequal spreads and sample sizes.

Check yourself

  1. Why can we not use the plain z test in most real situations?
  2. A sample of 25 workers has an average commute of 28 minutes and a standard deviation of 10. Test H₀: the true average is 25, using a cutoff of 2.064 (df = 24, two-sided, 5%). Compute t and decide.
  3. How many degrees of freedom does a one-sample t test with n = 40 have?
  4. Why is the t cutoff larger than 1.96 when the sample is small?
  5. Two shops each have 36 days of data. Shop A averages 120 sales with s = 18. Shop B averages 111 with s = 18. Find the standard error of the difference and t.
  6. Explain when you would use a paired t test instead of a two-sample test.
Show the answers
  1. The z test needs the true population standard deviation σ, which we almost never know, so we estimate it with s and use the t curve to pay for that uncertainty.
  2. SE = 10 ÷ √25 = 10 ÷ 5 = 2, so t = (28 − 25) ÷ 2 = 1.5; since 1.5 is below 2.064, we fail to reject.
  3. Degrees of freedom are n − 1 = 40 − 1 = 39.
  4. With few observations, s is a shaky estimate, so extreme t scores happen more often, and the bar for "surprising" must be set farther out.
  5. SE = √(324 ÷ 36 + 324 ÷ 36) = √(9 + 9) = √18 ≈ 4.24, and t = (120 − 111) ÷ 4.24 ≈ 2.12.
  6. Use it when each value in one group matches a value in the other, such as the same stores before and after a change, so you test the differences against zero.

A free self-study program written for 4Economics with AI writing tools and not reviewed line by line by a person. It is not an accredited degree and awards no credit. Check anything you rely on against a textbook or primary source. Report an error.

In this unit: Inference

  1. Populations, Samples and Sampling BiasLearn how a small sample can speak for a large group, which sampling methods work, and how bias quietly ruins big surveys.10 min
  2. Sampling Distributions and the Central Limit TheoremSee how sample averages vary from draw to draw, why they form a bell shape, and how the standard error measures their wobble.11 min
  3. Estimators: Bias and PrecisionJudge the recipes that turn samples into guesses by their bias, their spread and their total error, with worked examples.10 min
  4. Confidence Intervals for Means and ProportionsBuild a range around an estimate, read what 95% confidence really means, and work out how large a sample you need.10 min
  5. The Logic of Hypothesis TestingHypothesis testing asks whether a result is too surprising to blame on luck alone, and this lesson shows the steps.11 min
  6. t Tests for One and Two MeansWhen you must estimate the spread from a small sample, the t test compares one average to a target or two averages to each other.10 min
  7. p-Values, Significance and Common MistakesA p-value measures how surprising your data are if the null is true, and it is misread more often than almost any number in science.11 min
  8. Errors, Power and Sample SizeEvery test can be wrong in two ways, and power tells you how likely a study is to catch a real effect, which decides how much data to gather.10 min
  9. Chi-Square Tests for CategoriesChi-square tests compare counts in categories with what you would expect, to check a pattern or whether two traits are linked.10 min
  10. Analysis of Variance in Plain EnglishANOVA compares three or more group averages at once by asking whether groups differ more than the usual wobble inside each group.11 min

In the news