Plan the study before you collect the data.
Your browser does not support embedded video. Download the video (MP4).
:::
Everything in the video, ready to copy:
# Sample size & power for a two-group t-test # n per group for 80% power (delta = 5, sd = 10) power.t.test(delta = 5, sd = 10, power = 0.80, sig.level = 0.05) # Power for a fixed n = 30 per group power.t.test(n = 30, delta = 5, sd = 10, sig.level = 0.05) # With the pwr package: effect size d = 0.5 library(pwr) pwr.t.test(d = 0.5, power = 0.80, sig.level = 0.05) # Two proportions: 40% vs 60% pwr.2p.test(h = ES.h(0.6, 0.4), power = 0.80)
Download this R script · ▶ Practice in the playground
When to use it. Compute the sample size you need for a target power, or the power you’d have at a given n. Do it at the design stage, not after the results are in.
Try the sample size & power calculator · read power analysis before you have data.