Constructing a Z-Test Statistic
A hypothesis test requires a statistic that measures how strongly the observed data disagree with the null hypothesis. A common standardized measure is the z-statistic:\[ \boxed{ z = \frac{ \text{observed statistic} – \text{expected statistic under }H_0 }{ \text{standard error under }H_0 } }. \]
The z-statistic expresses the observed discrepancy in standard-error units.
The Three Components
A z-statistic contains three pieces:
- An observed statistic
- Its expected value under the null hypothesis
- Its standard error under the null hypothesis
Each component must be defined using the same statistic and the same null model.
Observed Statistic
The observed statistic summarizes the sample in a way that is relevant to the null hypothesis.
Examples include:
- Number of successes
- Sample proportion
- Sample mean
- Difference between two proportions
- Difference between two means
- Estimated regression coefficient
For 10 coin tosses, possible statistics include:\[ X=\text{number of tails} \]
or\[ \hat{p} = \frac{\text{number of tails}}{10}. \]
These contain the same information and produce the same standardized z-statistic when used consistently.
Expected Statistic Under the Null
The expected value must be calculated assuming that \(H_0\) is true.
Suppose the null hypothesis is\[ H_0:p=0.5, \]
where \(p\) is the probability of tails.
If\[ X=\text{number of tails in 10 tosses}, \]
then under \(H_0\),\[ E_0(X)=np_0. \]
Here,\[ n=10 \]
and\[ p_0=0.5. \]
Therefore,\[ E_0(X)=10(0.5)=5. \]
The subscript zero emphasizes that the expectation is calculated under \(H_0\).
Standard Error Under the Null
For a binomial count,\[ X\sim\operatorname{Binomial}(n,p), \]
the variance is\[ \operatorname{Var}(X)=np(1-p). \]
The standard deviation is\[ SD(X)=\sqrt{np(1-p)}. \]
Under the null hypothesis, substitute \(p_0\):\[ SE_0(X) = \sqrt{ np_0(1-p_0) }. \]
For 10 fair-coin tosses,\[ SE_0(X) = \sqrt{ 10(0.5)(0.5) }. \]
Therefore,\[ SE_0(X) = \sqrt{2.5} \approx 1.581. \]
Thus, the null model predicts five tails, with a typical sampling variation of approximately 1.58 tails.
Calculating the z-Statistic
Suppose the observed result is seven tails:\[ X_{\text{obs}}=7. \]
The z-statistic is\[ z = \frac{ X_{\text{obs}}-E_0(X) }{ SE_0(X) }. \]
Substituting the values,\[ z = \frac{ 7-5 }{ 1.581 }. \]
Therefore,\[ \boxed{ z\approx1.265 } \]
or, rounded,\[ \boxed{ z\approx1.27 }. \]
Interpreting the Result
A z-statistic of 1.27 means:
The observed number of tails is approximately 1.27 null standard errors above the number expected from a fair coin.
The sign indicates direction:
- \(z>0\): more tails than expected
- \(z<0\): fewer tails than expected
- \(z=0\): exactly the expected number
For a two-sided test, the magnitude\[ |z| \]
measures the standardized discrepancy in either direction.
Using the Sample Proportion Instead
The observed proportion of tails is\[ \hat p=\frac{7}{10}=0.70. \]
Under the null hypothesis,\[ E_0(\hat p)=p_0=0.50. \]
The null standard error is\[ SE_0(\hat p) = \sqrt{ \frac{ p_0(1-p_0) }{ n } }. \]
Therefore,\[ SE_0(\hat p) = \sqrt{ \frac{ 0.5(0.5) }{ 10 } } = \sqrt{0.025} \approx 0.1581. \]
The z-statistic is\[ z = \frac{ 0.70-0.50 }{ 0.1581 } \approx 1.265. \]
Thus, the count and proportion forms give the same answer.
Why the Two Forms Agree
The count and proportion are related by\[ \hat p=\frac{X}{n}. \]
The expected value transforms in the same way:\[ E_0(\hat p) = \frac{E_0(X)}{n}. \]
The standard error also scales by \(1/n\):\[ SE_0(\hat p) = \frac{SE_0(X)}{n}. \]
Therefore,\[ \frac{ \hat p-p_0 }{ SE_0(\hat p) } = \frac{ X-np_0 }{ SE_0(X) }. \]
Standardization removes the difference in scale.
Why the Null Standard Error Is Used
For a one-proportion hypothesis test,\[ H_0:p=p_0, \]
the conventional z-statistic is\[ \boxed{ z = \frac{ \hat p-p_0 }{ \sqrt{ p_0(1-p_0)/n } } }. \]
The denominator uses \(p_0\), not \(\hat p\), because the test asks:
How unusual is the observed estimate if the null hypothesis is true?
All parts of the reference distribution must therefore be calculated under \(H_0\).
For a confidence interval, the goal is different. We estimate the unrestricted population proportion, so an interval commonly uses\[ \sqrt{ \frac{ \hat p(1-\hat p) }{ n } }. \]
Tests and confidence intervals can therefore use slightly different standard-error estimates.
When the z-Statistic Follows a Normal Distribution
A z-statistic can be interpreted using the standard normal distribution when its null sampling distribution is exactly or approximately\[ N(0,1). \]
For a one-proportion test, a common guideline is that the null expected counts satisfy\[ np_0\geq10 \]
and\[ n(1-p_0)\geq10. \]
Some introductory treatments use 5, but 10 is more conservative.
For 10 fair-coin tosses,\[ np_0=5 \]
and\[ n(1-p_0)=5. \]
The normal approximation is therefore questionable.
A z-Score Is Not Automatically a z-Test
The calculation\[ z = \frac{7-5}{1.581} \approx 1.27 \]
correctly expresses the observed discrepancy in standard-error units.
However, using a standard normal curve to calculate its p-value is a separate approximation.
The exact null distribution is\[ X\sim\operatorname{Binomial}(10,0.5), \]
not a continuous normal distribution.
Thus, we can calculate a standardized score while still using the exact binomial distribution for the p-value.
Exact One-Sided P-Value
For the alternative\[ H_A:p>0.5, \]
the exact p-value is\[ P(X\geq7\mid p=0.5). \]
Therefore,\[ p = \sum_{k=7}^{10} \binom{10}{k}(0.5)^{10}. \]
This gives\[ p = \frac{ 120+45+10+1 }{ 1024 } = 0.171875. \]
Thus,\[ \boxed{ p_{\text{one-sided}}\approx0.172 }. \]
Exact Two-Sided P-Value
For\[ H_A:p\neq0.5, \]
both tails are relevant:\[ X\geq7 \]
or\[ X\leq3. \]
By symmetry,\[ P(X\leq3)=P(X\geq7). \]
Therefore,\[ p_{\text{two-sided}} = 2(0.171875) = 0.34375. \]
Thus,\[ \boxed{ p_{\text{two-sided}}\approx0.344 }. \]
Seven tails in 10 tosses are not especially unusual under the fair-coin model.
Continuity Correction
If a normal approximation is used for the discrete count, a continuity correction improves it.
For the upper-tail event\[ X\geq7, \]
use the continuous boundary\[ 6.5. \]
The corrected statistic is\[ z_{\text{cc}} = \frac{ 6.5-5 }{ 1.581 } \approx 0.949. \]
The upper-tail normal probability is approximately\[ 0.171, \]
which is close to the exact binomial result of 0.171875.
The uncorrected z-value of 1.27 should not be used mechanically to obtain a normal p-value in this small sample.
One-Sided Versus Two-Sided Testing
The test statistic does not by itself determine the p-value. The alternative hypothesis determines which tail or tails are counted.
Upper-Tailed
\[ H_A:p>p_0 \]
uses\[ P(Z\geq z_{\text{obs}}). \]
Lower-Tailed
\[ H_A:p<p_0 \]
uses\[ P(Z\leq z_{\text{obs}}). \]
Two-Sided
\[ H_A:p\neq p_0 \]
uses both directions:\[ P(|Z|\geq|z_{\text{obs}}|). \]
The alternative should be selected before examining the data.
General One-Sample Mean z-Statistic
If a population standard deviation \(\sigma\) is known, a test of\[ H_0:\mu=\mu_0 \]
uses\[ \boxed{ z = \frac{ \bar X-\mu_0 }{ \sigma/\sqrt{n} } }. \]
When \(\sigma\) is unknown and estimated using \(s\), the corresponding statistic is\[ \boxed{ t = \frac{ \bar X-\mu_0 }{ s/\sqrt{n} } }, \]
which is evaluated using Student’s t-distribution under the standard normal-mean assumptions.
General Two-Proportion z-Statistic
For two independent proportions testing\[ H_0:p_1=p_2, \]
the statistic is\[ z = \frac{ \hat p_1-\hat p_2 }{ \sqrt{ \hat p_{\text{pool}} (1-\hat p_{\text{pool}}) \left( 1/n_1+1/n_2 \right) } }, \]
where\[ \hat p_{\text{pool}} = \frac{ x_1+x_2 }{ n_1+n_2 }. \]
Again, the denominator is computed according to the null hypothesis.
A General Testing Workflow
- Define the population parameter.
- State \(H_0\) and \(H_A\).
- Choose a statistic relevant to the hypotheses.
- Calculate its expected value under \(H_0\).
- Calculate its standard error under \(H_0\).
- Standardize the observed discrepancy.
- Determine the correct null distribution.
- Calculate the appropriate one- or two-sided p-value.
- Compare with the prespecified significance level.
- Report the effect estimate and confidence interval.
Key Takeaway
A z-statistic measures the difference between an observed statistic and its null expectation in standard-error units:\[ \boxed{ z = \frac{ \text{observed}-\text{expected under }H_0 }{ SE\text{ under }H_0 } }. \]
For seven tails in 10 fair-coin tosses,\[ E_0(X)=5, \qquad SE_0(X)=\sqrt{2.5}\approx1.581, \]
so\[ \boxed{ z\approx1.27 }. \]
This means the observed count is 1.27 null standard errors above expectation. However, the sample is too small for an uncorrected normal p-value to be reliable. The exact binomial p-values are approximately\[ \boxed{0.172} \]
for an upper-tailed test and\[ \boxed{0.344} \]
for a two-sided test. Constructing the standardized statistic and selecting its reference distribution are related but distinct steps.
