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
nper group, effect sized, two-sidedalpha.Noneon bad inputs. - required_
sample_ size_ two_ proportion - Required sample size per group to detect a difference between two proportions
p1vsp2at two-sidedalphaandpower.Noneon 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 significancealpha, and desiredpower(e.g. 0.8).Noneif the inputs are out of range. Uses the standard normal approximationn = 2·(z_{1−α/2} + z_power)² / d².