Simple Power Calculation for Two-Sample Z Test


Description: Let μ1 and μ2 be the population means of a variable x in two groups. They are not known but can be estimated by the sample means x1 and x2. Assume the population variances σ12 and σ22 of the two groups are known. The following two hypotheses about μ2-μ1 will be tested. Calculate the power of the test as a function of the sample size for group 1 (n1), sample size for group 2 (n2), and the null cutoff α.

Hypothesis Difference in Population Means Population SDs
Null Hypothesis H0 μ2 - μ1 = 0

σ1 =

σ2 =

Alternative Hypothesis HA μ2 - μ1 =


Calculate Power from α, n1 and n2


CANVAS NOT SUPPORTED IN THIS BROWSER!
Option Sample Size Type I error Type II error Power

lock n1 = n2

unlock n1 = n2


n1 =
β = power = 1-β =

n2 =
α =

one-sided test

two-sided test

SE = Zα = Zβ = Effect size D =
Dz =


Assumption and Variable Definition

Assumption

The random variable x2-x1 follows a normal distribution.
In particular, x2-x1 ~ N(μ2-μ1, SE2), where SE2 = σ12/n1 + σ22/n2 is the square of the standard error.

The assumption is valid if x follows a normal distribution in the two groups. If x does not follow a normal distribution, x2-x1 can still be approximated by a normal distribution if n1 and n2 are sufficiently large because of the central limit theorem. Note that we assume the population variances σ12 and σ22 are known. If not, they will have to be estimated from the sample variances and the calculation will be more complicated.

Variable Definition

Standard error SE: SE2 = σ12/n1 + σ22/n2

Z score: z = (x2 - x1)/SE

Effect size D = hypothesized value of |μ2 - μ1| assuming HA

α: probability of Type I error = area of the shaded red region in the graph.

Zα = Z score of the null cutoff point. For a two-sided test, Zα is the Z score of the null cutoff point closest to the hypothesized value of μ2 - μ1 assuming HA.

ZA = hypothesized value of (μ2 - μ1)/SE assuming HA = Z score of the hypothesized μ2 - μ1 assuming HA

Zβ = Zα - ZA = Z score of the null cutoff point measured from z = ZA

β = probability of Type II error = area of the shaded skyblue region in the graph

Dz = |ZA| = scaled effect size