proportionZTestMinimumEffect

fun proportionZTestMinimumEffect(n: Int, power: Double = 0.8, alpha: Double = 0.05, alternative: Alternative = Alternative.TWO_SIDED, twoSample: Boolean = true): Double(source)

Computes the minimum detectable effect size (MDE) for a proportion z-test at the given sample size.

Returns the smallest Cohen's h that a proportion z-test with n observations can detect at the specified power and alpha. This is useful for assessing whether an existing dataset or planned study is large enough to detect practically meaningful differences between proportions.

Example:

// Smallest effect detectable with 100 subjects per group (two-sample)
proportionZTestMinimumEffect(n = 100, power = 0.8) // ~0.398
proportionZTestMinimumEffect(n = 100, power = 0.8, twoSample = false) // ~0.281

Return

the minimum detectable Cohen's h effect size. Always positive.

Parameters

n

the sample size. For two-sample tests (twoSample = true), this is the per-group size. For one-sample tests, this is the total sample size. Must be at least 2.

power

the target statistical power. Defaults to 0.8 (80%). Must be in (0, 1).

alpha

the significance level (Type I error rate). Defaults to 0.05 (5%). Must be in (0, 1).

alternative

the direction of the alternative hypothesis. Defaults to Alternative.TWO_SIDED.

twoSample

whether this is a two-sample test. Defaults to true.

See also

to compute power at a given effect size.

to find the sample size needed for a target power.

to compute Cohen's h from two proportions.