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(...)

Arguments

N.sim

Integer. Number of Monte Carlo simulations. Larger values provide more stable power estimates but increase computation time.

sample

Integer. The fixed sample size (number of respondents) to evaluate.

pi.null

Numeric. Prevalence rate under the null hypothesis (pi0). Can be 0 or a value from direct questioning.

pi.alt

Numeric. True prevalence rate under the alternative hypothesis (pi1). Must be greater than pi.null.

p

Numeric. Probability for the randomization item in the sensitive question. Values between 0.1 and 0.3 are typical.

p.prime

Numeric. Probability for the anchor question (non-sensitive).

gamma

Numeric. Proportion of attentive respondents (between 0 and 1). For example, 0.8 means 80% of respondents are attentive.

direct

Numeric. Direct questioning estimate for comparison purposes.

verbose

Logical. If TRUE (the default), report progress messages and show progress bars for the two underlying simulations.

...

Arguments passed to sim_power().

Value

A numeric scalar representing the estimated statistical power (probability of correctly rejecting H0 when H1 is true) at the given sample size.

Details

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.

Note

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.

References

Atsusaka and Stevenson (2023). Appendix C5: Sample Size Determination and Parameter Selection. doi:10.1017/pan.2021.43 .

See also

sim_cwdata for the underlying simulation function

Examples

# Compute power at a fixed sample size of 1000
if (FALSE) { # \dontrun{
pwr <- sim_power(
  N.sim  = 500,
  sample = 1000,
  pi.null = 0,
  pi.alt  = 0.1,
  p       = 0.1,
  p.prime = 0.1,
  gamma   = 0.8,
  direct  = 0.02
)
cat(sprintf("Estimated power: %.3f\n", pwr))
} # }