
Stata's power performs various power and sample-size analysis.
You can compute power, sample size, and effect size. Enter any two and get the third. You can specify single values or, to compare multiple scenarios, ranges of values of study parameters. You can obtain results either in tabular form or as a graph.
And, you can easily add your own new methods to power.
Say we are planning an experiment to determine whether students who prepare for the SAT exam obtain higher math scores by (1) taking classes rather than (2) studying independently. The national average math score is 520 with a standard deviation of 135. We want to see the power obtained for sample sizes of 100 through 500 when scores increase by 20, 40, 60, and 80 points or, equivalently, when average scores increase to 540, 560, 580, and 600.
We type
. power twomeans 520 (540 560 580 600), n(100 200 300 400 500) sd(135) graph
We assumed above that those studying independently would obtain the national average of 520 and that the standard deviations would be 135 for both groups. We could relax either assumption using the power command.
We might be more interested in the sample size necessary to detect the increased scores at power levels of 0.8 and 0.9. In that case, we type
. power twomeans 520 (540 560 580 600), power(0.8 0.9) sd(135) graph
We can even estimate the detectable increased scores over the range of sample sizes and powers:
. power twomeans 520, power(0.8 0.9) n(100 200 300 400 500) sd(135) graph
If we prefer to see the detectable limits as effect sizes (difference between the experimental group mean and the control group mean) rather than experimental-group test scores, we add option y(delta) to the command:
. power twomeans 520, power(0.8 0.9) n(100 200 300 400 500) sd(135) graph(y(delta))
In this graph, the effect size is calculated as (experimental group mean - 520).
See the Power, Precision, and Sample-Size Reference Manual, especially the introduction.
Watch Power and sample size tutorials.
And see the worked examples:
One-sample comparison of means
One-sample comparison of means, cluster randomized design
One-sample comparison of proportions
One-sample comparison of proportions, cluster randomized design
One-sample comparison of variances
One-sample comparison of correlations
Comparison of two independent means
Comparison of two independent means, cluster randomized design
Comparison of two independent proportions
Comparison of two independent proprotions, cluster randomized design
Comparison of two independent variances
Comparison of two independent correlations
Comparison of two paired means
Comparison of two paired proportions
One-way ANOVA
Two-way ANOVA
Repeated measures ANOVA
Slope test in a simple linear regression
R2 test in a multiple linear regression
Partial-correlation test in a multiple linear regression
Cochran–Mantel–Haenszel test
Matched case–control studies
Cochran–Armitage trend test
Cox proportional hazards model
Two-sample exponential test
Log-rank test
Log-rank test, cluster randomized design
Also see precision and sample-size analysis for confidence intervals.