Finds the minimum per-group sample size \(n\) (balanced design) at which
power reaches or exceeds power_target. Uses bisection over
oda_power() with a fixed RNG seed for stable search.
Usage
oda_sample_size(
power_target = 0.8,
p1 = NULL,
p2 = NULL,
ess = NULL,
alpha = 0.05,
comp = 1L,
nsim = 10000L,
mc_seed = 42L,
n_min = 2L,
n_max = 2000L
)Arguments
- power_target
Target power. Default 0.80.
- p1
Probability of the event in class 0. Ignored when
essis supplied.- p2
Probability of the event in class 1. Ignored when
essis supplied.- ess
Effect Strength for Sensitivity (percent, \(0 < \text{ESS} < 100\)). Mutually exclusive with
p1/p2.- alpha
Nominal significance level. Default 0.05.
- comp
Number of comparisons for Sidak correction. Default 1.
- nsim
Number of Monte Carlo replications per candidate \(n\). Default 10000.
- mc_seed
Integer seed used for every
oda_power()call during the bisection. Using a fixed seed yields stable, reproducible results. Default 42L.- n_min
Minimum \(n\) to search. Default 2.
- n_max
Maximum \(n\) to search. If power at
n_maxis still belowpower_target, an error is raised. Default 2000.
Value
An object of class "oda_sample_size", a list with elements:
nMinimum per-group sample size achieving
power_target.power_achievedEstimated power at
n.power_targetInput target power.
p1,p2,ess_inputEffect-size inputs.
alpha,alpha_adj,compAlpha parameters.
nsim,mc_seedSimulation parameters.
Details
Scope: unit-weighted, binary class, binary (2-level) attribute only.
This is not a general CTA, LORT, SDA, weighted, or multiclass sample-size
method. For unbalanced designs, call oda_power() directly across a
candidate grid.
References
Rhodes, N. J. (2020). Statistical power analysis in ODA, CTA and Novometrics. Optimal Data Analysis, 9. https://odajournal.files.wordpress.com/2020/02/v9a5.pdf
Yarnold PR, Soltysik RC (2005). Optimal Data Analysis: A Guidebook with Software for Windows. Washington, DC: APA Books.
Examples
# Minimum n for ESS = 48%, 80% power (use nsim >= 500L for publication-quality estimates)
oda_sample_size(ess = 48, nsim = 200L, mc_seed = 42L)
#> ODA Sample Size Analysis
#> Effect: p1 = 0.2600, p2 = 0.7400 (ESS = 48.00%)
#> alpha = 0.0500
#> Target power: 0.800
#> Minimum n/group: 22
#> Power achieved: 0.850
#> nsim = 200
# \donttest{
# 90% power target (publication-quality nsim)
oda_sample_size(ess = 48, power_target = 0.90, nsim = 500L, mc_seed = 42L)
#> ODA Sample Size Analysis
#> Effect: p1 = 0.2600, p2 = 0.7400 (ESS = 48.00%)
#> alpha = 0.0500
#> Target power: 0.900
#> Minimum n/group: 23
#> Power achieved: 0.902
#> nsim = 500
# }