Skip to main content

Module power

Module power 

Source
Expand description

Power analysis & sample-size (Practical Statistics ch 3) — how many observations an experiment needs to detect an effect, and the power it achieves at a given size. Honest experiment planning: state the effect you care about and the confidence you need, get the sample size you must collect. Reuses the Normal quantile/CDF from statistics::distributions.

Functions§

power_two_sample
Achieved power of a two-sample mean test with n per group, effect size d, two-sided alpha. None on bad inputs.
required_sample_size_two_proportion
Required sample size per group to detect a difference between two proportions p1 vs p2 at two-sided alpha and power. None on bad inputs / equal props.
required_sample_size_two_sample
Required sample size per group for a two-sample comparison of means, given a standardized effect size d (Cohen’s d = mean difference / pooled SD), two-sided significance alpha, and desired power (e.g. 0.8). None if the inputs are out of range. Uses the standard normal approximation n = 2·(z_{1−α/2} + z_power)² / d².