Computes statistical power for a planned study given sample size, effect size, and design parameters. Supports t-tests (two-sample, one-sample, paired), ANOVA, proportion tests, correlation tests, and chi-square tests.
Arguments
- n
Integer. Sample size. Interpretation depends on test:
"t_two","anova": per group"t_paired": number of pairsall others: total
- effect_size
Numeric. Effect size appropriate for the chosen test (must be positive). Conventions:
Cohen's d for t-tests (small 0.2, medium 0.5, large 0.8)
Cohen's f for ANOVA (small 0.1, medium 0.25, large 0.4)
Cohen's h for proportion tests (small 0.2, medium 0.5, large 0.8)
Pearson r for correlation (small 0.1, medium 0.3, large 0.5)
Cohen's w for chi-square (small 0.1, medium 0.3, large 0.5)
- test
Character. Test type:
"t_two"(two-sample t-test, default),"t_one"(one-sample t-test),"t_paired"(paired t-test),"anova","proportion","correlation", or"chisq".- alternative
Character. Direction of the alternative hypothesis:
"two.sided"(default),"less", or"greater". Ignored for"anova"and"chisq".- alpha
Numeric. Significance level (Type I error rate). Default: 0.05.
- k
Integer \(\ge 2\). Number of groups. Required when
test = "anova".- df
Integer \(\ge 1\). Degrees of freedom. Required when
test = "chisq".- x
A
power_resultobject returned bystat_power()orstat_n().- y
Ignored.
- plot_range
Numeric vector of length 2. Custom axis range for the curve. For
stat_power()results: range over sample sizes. Forstat_n()results: range over effect sizes.NULLuses an automatic range.- ...
Additional arguments (currently unused).
Value
An object of class "power_result" (invisibly) containing:
paramsNamed list of all input parameters
powerComputed statistical power (numeric in
[0, 1])computed"power"— distinguishes fromstat_n()results wherecomputed = "n"interpretationPlain-text interpretation of the power value
recommendationActionable recommendation, or
NULLwhen power is between 0.8 and 0.95
Use print(result) for a brief summary, summary(result) for
full details, and plot(result) to display the power curve.
