A function for computing power of two-sided tests corresponding to z-scores for a given significance level. alpha (or corresponding cut-off z-score a)

z_to_power(
  z,
  alpha = 0.05,
  a = stats::qnorm(alpha/2, lower.tail = FALSE),
  two.sided = TRUE
)

Arguments

z

A vector of z-scores

alpha

Level of significance alpha

a

Or, alternatively a z-score corresponding to alpha

two.sided

Whether directionality of the effect size should be taken into account.

Examples

# mean powers corresponding to the mean components of KD2
z_to_power(0:6, alpha = .05)
#> [1] 0.0500000 0.1700750 0.5160053 0.8508388 0.9793266 0.9988173 0.9999733