Sub topic 3
The test statistic: how far is the sample from the null?
This chapter assumes you can compute a sample mean and standard deviation, you know z-scores and the normal distribution, and you have read the previous two chapters on standard error and on stating the null and alternative hypotheses. Here you learn to turn a sample into one number that measures how far the data sit from the null hypothesis.
What a test statistic does
A hypothesis test asks whether a sample is consistent with the null hypothesis. Comparing a raw sample mean to the hypothesized mean is not enough, because a gap of 0.6 percentage points may be large for one dataset and trivial for another. The test statistic rescales the gap by the amount of noise you would expect from sampling alone.
Nearly every test statistic in the CFA Level I curriculum has the same form:
test statistic = (sample statistic − value under H0) / standard error of the sample statistic
The numerator is the observed gap. The denominator is the standard error, which is the standard deviation of the sample statistic across repeated samples. The result counts how many standard errors the sample lies from the null value. A statistic near 0 means the data agree with H0. A statistic far from 0 means the data would be unusual if H0 were true.
Choosing the standard error
The standard error depends on what you are estimating and on what you know about the population.
| Situation | Standard error | Statistic and distribution |
|---|---|---|
| Mean, population standard deviation σ known | σ / √n | z, standard normal |
| Mean, σ unknown, estimated by s | s / √n | t with n − 1 degrees of freedom |
| Difference in means | Depends on pooling or pairing | t, covered in a later chapter |
| Variance | Not a ratio of this form | Chi-square or F, covered later |
| Correlation | Depends on r and n | t with n − 2 degrees of freedom |
For the single mean, the two formulas look alike. The difference is in the reference distribution. Estimating σ with s adds uncertainty, so the t distribution has fatter tails than the normal. The tails get thinner as degrees of freedom grow, and the t distribution approaches the normal.
The standard error shrinks with √n. Quadrupling the sample size halves the standard error. With the same gap between the sample mean and the null value, a larger sample gives a larger test statistic.
A worked example
A fund reports ten monthly excess returns, in percent: 1.2, −0.4, 0.8, 2.1, −1.0, 0.5, 1.7, 0.3, −0.2, 1.1. The hypotheses are H0: mean = 0 and Ha: mean ≠ 0.
- The sample mean is 6.1 / 10 = 0.61.
- The sample standard deviation is s ≈ 0.967. It uses n − 1 = 9 in the denominator of the variance.
- The standard error is 0.967 / √10 ≈ 0.306.
- The test statistic is (0.61 − 0) / 0.306 ≈ 2.00.
The sample mean is about two standard errors above zero. Whether that is far enough to reject H0 is a separate question, and the next chapter answers it with critical values and p-values.
The code below repeats the calculation. It also computes the z version, which is valid only if σ is known, to show how the choice of distribution matters.
import numpy as np
from scipy import stats
returns = np.array([1.2, -0.4, 0.8, 2.1, -1.0, 0.5, 1.7, 0.3, -0.2, 1.1])
mu0 = 0.0
n = len(returns)
x_bar = returns.mean()
s = returns.std(ddof=1) # ddof=1 gives the sample standard deviation
se = s / np.sqrt(n)
t_manual = (x_bar - mu0) / se
t_scipy, p_t = stats.ttest_1samp(returns, popmean=mu0)
# Pretend s is the known population sigma, only to compare reference distributions
p_z = 2 * (1 - stats.norm.cdf(abs(t_manual)))
print(f"mean={x_bar:.3f} s={s:.3f} SE={se:.3f}")
print(f"t manual={t_manual:.3f} t scipy={t_scipy:.3f}")
print(f"two-tailed p with t (df={n - 1}): {p_t:.4f}")
print(f"two-tailed p with z (wrongly assuming sigma known): {p_z:.4f}")The two p-values differ because the t distribution has heavier tails. With n = 10, treating s as a known σ understates the probability of an extreme result, so the test looks more convincing than it is.
Sign and direction
The sign of the statistic carries information. A positive value means the sample statistic is above the null value, and a negative value means it is below.
- In a two-tailed test (Ha: mean ≠ μ0), only the size of the statistic matters, so you look at its absolute value.
- In a one-tailed test, the sign must match the direction of Ha. If Ha says the mean is greater than μ0 and the statistic is negative, the data point away from Ha. You fail to reject no matter how large the magnitude is.
Common errors
- Dividing by σ or s instead of the standard error. Dividing by s gives a z-score of one observation, not a test of the mean. You must divide by s / √n.
- Using the wrong degrees of freedom. A single-mean t statistic has n − 1 degrees of freedom. A regression slope has n − 2 because two parameters are estimated. Correlation tests also use n − 2.
- Reversing the numerator. Write sample statistic minus null value. Reversing it flips the sign, which matters for one-tailed tests.
- Reading the statistic as a probability. A t of 2.00 is a distance in standard errors. It is not a 2% chance of anything. Converting it to a probability is the job of the p-value.
- Confusing statistical and economic size. With a large n, the standard error is tiny, so a trivial gap can produce a large statistic. A significant result does not mean the effect is large enough to matter for a portfolio.
Summary
- A test statistic measures how many standard errors the sample statistic is from the value stated in H0.
- For a single mean, use z when σ is known and t with n − 1 degrees of freedom when you estimate σ with s.
- A larger n shrinks the standard error and raises the statistic for the same gap.
- The sign matters for one-tailed tests. The statistic alone does not decide the test, because it must be compared with a reference distribution.
Exercise
An analyst tests H0: mean annual return = 8% against Ha: mean ≠ 8%. A sample of 25 years gives a mean of 10.5% and a sample standard deviation of 15%. Compute the test statistic, name its distribution, and give the degrees of freedom.
Show answer
The standard error is 15 / √25 = 3%. The test statistic is (10.5 − 8) / 3 = 0.833. Because the standard deviation is estimated from the sample, the statistic follows a t distribution with n − 1 = 24 degrees of freedom. The statistic of 0.83 is less than one standard error from the null value, so it gives little evidence against H0.
Exercise
A test of H0: mean ≤ 0 versus Ha: mean > 0 produces a test statistic of −2.4. Does this result support rejecting H0? Why or why not?
Show answer
No. The alternative is that the mean is greater than zero, so only large positive statistics support it. A statistic of −2.4 means the sample mean is below zero, which points away from Ha. You fail to reject H0 regardless of the magnitude.
Exercise
Two studies find the same gap between sample mean and null value and the same sample standard deviation. Study A has n = 16 and Study B has n = 64. How do their test statistics compare?
Show answer
The standard error is s / √n, so Study B's standard error is half of Study A's (√64 = 8 versus √16 = 4). Study B's test statistic is therefore twice as large as Study A's.