Biostatistics Study NotesFrom concepts and derivations to interpretation

CHAPTER 04 · TOPIC 01

Z Tests

Develop one- and two-sample Z tests, confidence intervals, Type I and II errors, power, and sample-size calculations from the same standardized framework.

On this page
  1. Distinguishing an Individual Z Score from a Z Statistic for a Mean
  2. Why the Z Test Is Valid
  3. Z-test conditions
  4. Hypotheses and Decision for a One-Sample Mean
  5. Z-test for independent two-sample means
  6. Confidence Interval: Solve the Same Standardized Equation for μ
  7. Overlapping the H₀ and H₁ Distributions
  8. Determine the Right-Tailed Critical Point from α under H₀
  9. β for a Right-Tailed Test: View the Same Critical Point under H₁
  10. Sample Size: Control α While Maintaining Power
  11. How the Formula Determines Sample Size
  12. Deriving Power from the Same Framework

The Z-test compares the sample statistic to the population specified by the null hypothesis and measures how many standard errors the difference is. Since standardized statistics follow or approximate a standard normal distribution under H₀, critical values ​​and p-values ​​can be determined.

Distinguishing an Individual Z Score from a Z Statistic for a Mean#

An individual Z score indicates how many population standard deviations X is away from the population mean. In testing the mean, we treat X̄ and use its standard deviation, the standard error σ/√n, as the denominator.

individual z-scoreZ=XμσZ=\frac{X-\mu}{\sigma}
Standardization of sample meanZ=Xˉμσ/nZ=\frac{\bar X-\mu}{\sigma/\sqrt n}
SymbolMeaning
Xindividual observations
sample mean of n observations
μpopulation mean
μ₀The population mean specified by H₀
σknown population standard deviation
nsample size
σ/√nstandard error of the sample mean

Why the Z Test Is Valid#

If the population is normally distributed, the sample mean is also normally distributed. Even if it is non-normal, it can be approximated by the central limit theorem with appropriate conditions and sufficient n.

Expected value of sample meanE(Xˉ)=μE(\bar X)=\mu
variance of sample meanVar(Xˉ)=σ2n\operatorname{Var}(\bar X)=\frac{\sigma^2}{n}
standard errorSE(Xˉ)=σn\operatorname{SE}(\bar X)=\frac{\sigma}{\sqrt n}
Z statistic under H₀Z=Xˉμ0σ/nN(0,1)Z=\frac{\bar X-\mu_0}{\sigma/\sqrt n}\sim N(0,1)

Z-test conditions#

  • The sampling distribution of the statistic is normal or can be reasonably approximated by a normal distribution.
  • Random sampling and independence of observations. Paired or clustered data require methods appropriate to that dependence structure
  • In the Z test of the mean, the population standard deviation σ is known. When σ is unknown and replaced by s, use a t test as a general rule.
  • Even with a large sample, unknown σ does not become known.

Hypotheses and Decision for a One-Sample Mean#

two-sidedH0:μ=μ0,H1:μμ0H_0:\mu=\mu_0,\qquad H_1:\mu\ne\mu_0
right-tailedH0:μμ0,H1:μ>μ0H_0:\mu\leq\mu_0,\qquad H_1:\mu>\mu_0
left-tailedH0:μμ0,H1:μ<μ0H_0:\mu\geq\mu_0,\qquad H_1:\mu<\mu_0
DirectionRejection conditionp-value
two-sided|Zobs| ≥ z₁₋α⁄₂2P(Z≥|Zobs|)
right-tailedZobs ≥ z₁₋αP(Z≥Zobs)
left-tailedZobs ≤ zαP(Z≤Zobs)

Z-test for independent two-sample means#

For two independent groups, we treat the mean difference X̄₁−X̄₂. If the population variance is known, due to independence, the variance of the mean difference is the sum of the variances of the two groups.

variance of mean differenceVar(Xˉ1Xˉ2)=σ12n1+σ22n2\operatorname{Var}(\bar X_1-\bar X_2)=\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}
Independent two-sample Z statisticZ=(Xˉ1Xˉ2)Δ0σ12/n1+σ22/n2Z=\frac{(\bar X_1-\bar X_2)-\Delta_0}{\sqrt{\sigma_1^2/n_1+\sigma_2^2/n_2}}

For a test of no difference, Δ₀=0. Since covariance cannot be ignored in matched data, we analyze the differences between each pair.

Confidence Interval: Solve the Same Standardized Equation for μ#

A two-tailed (1−α) confidence interval is obtained by solving for the unknown μ from the median area 1−α of a standard normal distribution.

median probabilityP ⁣(z1α/2Xˉμσ/nz1α/2)=1αP\!\left(-z_{1-\alpha/2}\leq\frac{\bar X-\mu}{\sigma/\sqrt n}\leq z_{1-\alpha/2}\right)=1-\alpha
Solve μP ⁣(Xˉz1α/2σnμXˉ+z1α/2σn)=1αP\!\left(\bar X-z_{1-\alpha/2}\frac{\sigma}{\sqrt n}\leq\mu\leq\bar X+z_{1-\alpha/2}\frac{\sigma}{\sqrt n}\right)=1-\alpha
confidence intervalXˉ±z1α/2σn\bar X\pm z_{1-\alpha/2}\frac{\sigma}{\sqrt n}

In the 95% interval, z₀.₉₇₅=1.96. The confidence level is the long-term proportion of intervals containing the true μ when the same procedure is repeated, not the probability that μ falls within the completed fixed interval.

Overlapping the H₀ and H₁ Distributions#

α is the area that exceeds the critical point and is falsely rejected when H₀ is true, and β is the area that cannot cross the same critical point when a certain H₁ (μ=μ₁) is true.

Overlapping sampling distributions under H₀ and H₁; the area to the right of the common critical value is Type I error α under H₀, while the area to its left is Type II error β under H₁
α and β use the same critical boundary but are calculated under the H₀ distribution and a specified H₁ distribution, respectively.Source: Recreated for this site from the original notes

Determine the Right-Tailed Critical Point from α under H₀#

Right tail of the H₀ sampling distribution, with the area beyond the critical value representing Type I error α
For a right-tailed test, choose the critical value under H₀ so that the area to its right equals α.Source: Recreated for this site from the original notes
Z value of critical pointz1α=cμ0σ/nz_{1-\alpha}=\frac{c-\mu_0}{\sigma/\sqrt n}
critical sample meanc=μ0+z1ασnc=\mu_0+z_{1-\alpha}\frac{\sigma}{\sqrt n}

β for a Right-Tailed Test: View the Same Critical Point under H₁#

H₁ sampling distribution with the area to the left of the same critical value representing Type II error β
Place the same critical value on the H₁ distribution; the area to its left, where H₀ is not rejected, is β.Source: Recreated for this site from the original notes
Standardized critical point under H₁zβ=cμ1σ/nz_\beta=\frac{c-\mu_1}{\sigma/\sqrt n}
Type 2 errorβ=Pμ1(Xˉc)=Φ(zβ)\beta=P_{\mu_1}(\bar X\leq c)=\Phi(z_\beta)
statistical power1β=1Φ(zβ)=Φ(zβ)1-\beta=1-\Phi(z_\beta)=\Phi(-z_\beta)

Sample Size: Control α While Maintaining Power#

By subtracting two equations that use the same critical point c for H₀ and H₁, c disappears and the required sample size can be found.

Eliminate critical pointsz1αzβ=μ1μ0σ/nz_{1-\alpha}-z_\beta=\frac{\mu_1-\mu_0}{\sigma/\sqrt n}
Symmetry of normal distributionzβ=z1βz_\beta=-z_{1-\beta}
1 sample side sample sizen=[(z1α+z1β)σμ1μ0]2n=\left[\frac{(z_{1-\alpha}+z_{1-\beta})\sigma}{\mu_1-\mu_0}\right]^2

Round up n. This formula is for a one-sample, one-tailed, mean Z test with known σ, with z₁₋α⁄₂ for two-sided.

Supplementary example: sample size and detectable difference

In a study comparing hip ultrasound alpha angle between preterm and term infants, we planned a sample size for each group to detect a mean difference of 3° or 2°, with σ = 4.9°, two-sided α = 0.05, and a power of 80%.

Standard error of the mean difference between two independent groupsSE(Xˉ1Xˉ2)=σ2n\operatorname{SE}(\bar X_1-\bar X_2)=\sigma\sqrt{\frac{2}{n}}
Sample size for each groupn=2[(z1α/2+z1β)σδ]2n=2\left[\frac{(z_{1-\alpha/2}+z_{1-\beta})\sigma}{\delta}\right]^2
Detectable difference δEffect size d=δ/σNormal approximationPublished study
Approximately 0.61Approximately 42 hips in each group43 hips
Approximately 0.41Approximately 95 hips in each group96 hips

Reference: Hockett C, et al. J Pediatr Orthop. 2024;44(1):e25–e29. doi:10.1097/BPO.0000000000002540.

How the Formula Determines Sample Size#

changenecessary nreason
α↓increaseType 1 errors are suppressed and boundaries become stricter.
β↓(power↑)increaseWe need information so we don't miss the real difference.
σ↑increaseloud noise
|μ₁−μ₀|↑decreaseBig differences are easy to spot

Deriving Power from the Same Framework#

One-sided statistical power1β=Φ ⁣(nμ1μ0σz1α)1-\beta=\Phi\!\left(\frac{\sqrt n\,|\mu_1-\mu_0|}{\sigma}-z_{1-\alpha}\right)
two-sided approximation1βΦ ⁣(nμ1μ0σz1α/2)1-\beta\approx\Phi\!\left(\frac{\sqrt n\,|\mu_1-\mu_0|}{\sigma}-z_{1-\alpha/2}\right)

For strict two-sided power, we add the probability that the H₁ distribution falls into both the left and right rejection regions. An increase in n or effect increases the power, and an increase in σ or a decrease in α decreases the power if other conditions are held constant.

Overlapping H₀ and H₁ distributions showing Type I error α, Type II error β, and statistical power 1−β
With other conditions fixed, moving the critical value changes α and β in opposite directions; reducing overlap between the distributions increases power.Source: Recreated for this site from the original notes