Computes statistical power for a one-sided hypothesis test of H0: pi <= pi0 versus H1: pi > pi0 at a given fixed sample size. This is useful when researchers already know their sample size and want to assess the power they can expect from their study.
sim_power(
N.sim,
sample,
pi.null,
pi.alt,
p,
p.prime,
gamma,
direct,
verbose = TRUE
)
sim.power(...)Integer. Number of Monte Carlo simulations. Larger values provide more stable power estimates but increase computation time.
Integer. The fixed sample size (number of respondents) to evaluate.
Numeric. Prevalence rate under the null hypothesis (pi0). Can be 0 or a value from direct questioning.
Numeric. True prevalence rate under the alternative hypothesis (pi1). Must be greater than pi.null.
Numeric. Probability for the randomization item in the sensitive question. Values between 0.1 and 0.3 are typical.
Numeric. Probability for the anchor question (non-sensitive).
Numeric. Proportion of attentive respondents (between 0 and 1). For example, 0.8 means 80% of respondents are attentive.
Numeric. Direct questioning estimate for comparison purposes.
Logical. If TRUE (the default), report progress messages
and show progress bars for the two underlying simulations.
Arguments passed to sim_power().
A numeric scalar representing the estimated statistical power (probability of correctly rejecting H0 when H1 is true) at the given sample size.
The function implements the power calculation based on the Wald test: $$Power = \Phi\left(\frac{\pi_1 - \pi_0 + z_\alpha \tilde{\sigma}_0}{\tilde{\sigma}_1}\right)$$ where:
\(\Phi\) is the cumulative distribution function of the standard normal
\(z_\alpha\) is derived from the simulated null distribution
\(\tilde{\sigma}_0\) and \(\tilde{\sigma}_1\) are simulated standard errors under H0 and H1 respectively
The function runs sim_cwdata() twice: once under H0 using pi.null
and once under H1 using pi.alt, to estimate the sampling distributions
at the specified sample size.
This function can take considerable time to run depending on N.sim and sample size. For quick exploration, use smaller N.sim values (for example, 100 to 500). For publication-quality results, use N.sim >= 2000.
Atsusaka and Stevenson (2023). Appendix C5: Sample Size Determination and Parameter Selection. doi:10.1017/pan.2021.43 .
sim_cwdata for the underlying simulation function