STAT5002 Chap.10 Unknown Means: T-statistic, T-test and Bootstrap
Unknown Means: T-statistic, T-test and Bootstrap
Once the question is about an average rather than a proportion, a new problem appears: the SD of the box is usually unknown as well. This chapter walks through three ways to test a hypothesis about an unknown mean μ and to build an interval for it.
It begins with the case where the box SD σ₀ is known, so the standard error σ₀/√n is fixed under the null hypothesis and the familiar Z-test and normal-based confidence interval apply directly. You will see why a two-sided test at level α and a (1 − α) confidence interval always give the same verdict. Next comes the realistic case. Replacing σ₀ with the sample SD from sd(), which divides by n − 1, produces the T-statistic.
Because its denominator changes from sample to sample, the T-statistic has fatter tails than the standard normal, so pnorm understates the P-value. For a nearly normal box, Student's t curve on n − 1 degrees of freedom fixes this, and dt, pt and qt replace dnorm, pnorm and qnorm.
You then run a complete one-sample T-test using HATPC, including the assumption check with a boxplot, qqnorm and qqline, and learn to read every line of the t.test() output, including the alternative argument and the 95% confidence interval. The last part covers the bootstrap.
When the data look clearly skewed, the sample itself is used as a surrogate box: resampling it many times gives simulated T-statistics whose quantiles provide a P-value and an equal-tailed interval that need not be symmetric about the sample mean.
What this chapter covers
- 01
Z-test for a mean when the box SD is known
- 02
Confidence intervals for a mean at 95%, 98% and 99%
- 03
Population SD versus sample SD in R
- 04
The T-statistic and its fatter tails
- 05
Student's t distribution and n − 1 degrees of freedom
- 06
The R functions dt, pt and qt as analogues of dnorm, pnorm and qnorm
- 07
One-sample T-test with HATPC
- 08
Checking normality with boxplots and QQ plots
- 09
Reading t.test() output and the alternative argument
- 10
Bootstrap principle and the surrogate box
- 11
Simulation-based P-values and equal-tailed intervals
Worked example · free
Has the average commute grown beyond 25 minutes?
- +1H: H₀: μ = 25 against H₁: μ > 25, since only an increase is of interest.
- +1A: The commuters are a random sample, and the roughly straight QQ plot supports a nearly normal box, so Student's t with 15 degrees of freedom is appropriate.
- +1T: The estimated SE is 4.4/√16 = 1.1, so t = (27.9 − 25)/1.1 = 2.636 on 15 df. Large values of t argue against H₀.
- +1P: One-sided upper tail, so the P-value is pt(2.636, df = 15, lower.tail = F) = 0.0093.
- +1C: 0.0093 < 0.05, so reject H₀. The data are evidence that the mean commute is longer than 25 minutes.
- +1Interval: qt(0.975, 15) = 2.131, so the 95% interval is 27.9 ± 2.131 × 1.1 = (25.56, 30.24) minutes.
Key terms
- Sample SD
- The spread measure that divides the sum of squared deviations by n − 1; it is what R's sd() returns and it estimates the box SD σ.
- T-statistic
- The standardised sample mean (x̄ − μ₀)/(σ̂/√n), in which the unknown box SD is replaced by the sample SD.
- Degrees of freedom
- The parameter of Student's t distribution, equal to n − 1 for a one-sample test because the deviations from the sample mean always sum to zero.
- Student's t distribution
- The distribution of the T-statistic under H₀ when sampling from a normal box; it has fatter tails than the standard normal, shrinking as n grows.
- QQ plot
- A plot of sample quantiles against normal quantiles, made with qqnorm() and qqline(); points near the line suggest a nearly normal box.
- Bootstrap principle
- The idea of approximating a statistic's behaviour by simulating from a best guess of the population, usually the observed sample used as a surrogate box.
- Equal-tailed interval
- A confidence interval [x̄ − u·SE, x̄ − ℓ·SE] built from lower and upper quantiles ℓ and u that each cut off α/2 of the statistic's distribution.
Unknown Means: T-statistic, T-test and Bootstrap FAQ
When should I use a T-test instead of a Z-test for a mean?
Use the Z-test only when the box SD is genuinely known before the data are collected. If you estimate the SD from the same sample with sd(), the extra randomness in the denominator means you need Student's t with n − 1 degrees of freedom.
Why are the degrees of freedom n − 1 and not n?
The deviations of the observations from the sample mean always add to zero, so once n − 1 of them are known the last is fixed. Only n − 1 pieces of spread information are free, which is the count Student's t uses.
How do I get a one-sided P-value from t.test in R?
Add alternative = "greater" or alternative = "less" to the t.test call. The default output is two-sided, so halving or doubling by hand is unnecessary if you set the argument to match the hypothesis written before seeing the data.
Why can a bootstrap confidence interval be lopsided?
The bootstrap quantiles ℓ and u come from simulated T-statistics, which inherit any skewness in the data. When they are not mirror images, x̄ − u·SE and x̄ − ℓ·SE sit at unequal distances from the sample mean.
Exam move
Build a one-page comparison of the three procedures for a mean: the Z-test with known σ₀, the T-test with Student's t, and the bootstrap T-test. For each, write the statistic, where its reference distribution comes from, the R call for the P-value, and the multipliers ℓ and u for the interval.
Then take one small data set of your own, compute the mean, sd() and the T-statistic by hand, and confirm every printed number in t.test(x, mu = ...) including the confidence interval. Repeat with alternative = "greater" and note which line changes. Practise reading qt values for a few degrees of freedom so you can see the multiplier fall towards 1.96 as n grows.
Finally, write a short bootstrap loop that resamples your data, stores the T-statistics, and uses quantile() to build an equal-tailed interval; check that you subtract u for the lower end.
Working through Unknown Means: T-statistic, T-test and Bootstrap in STAT5002? Sia is AskSia’s AI Statistics tutor — ask any STAT5002 Unknown Means: T-statistic, T-test and Bootstrap question and get a clear, step-by-step explanation grounded in how STAT5002 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.
STAT5003 Computational Statistical Methods · DATA2002 Data Analytics: Learning from Data · QBUS5001 Foundation in Data Analytics for Business