Because the standardized alpha depends on the sample size (N), and the power depends on the sample size, deciding upon the sample size to achieve a desired power requires an iterative procedure. Increasing the sample size reduces the standardized alpha, which requires an increase in the sample size for the power analysis, which reduces the standardized alpha. This function takes a power analysis function that outputs the power as a function of the desired power, the alpha level, as a function of N(x).

power_standardized_alpha(
  power_function,
  alpha = 0.05,
  power = 0.8,
  standardize_N = 100,
  verbose = Superpower_options("verbose")
)

Arguments

power_function

Function that outputs the power, calculated with an analytic function.

alpha

The unstandardized alpha level (e.g., 0.05), independent of the sample size.

power

The desired power, i.e., the outcome of the power calculation you would like to achieve.

standardize_N

The sample size you want to use to standardize the alpha level for. Defaults to 100 (based on Good, 1982).

verbose

Set to FALSE to not print results (default = TRUE)

Value

List of 3 objects: a_stan = standardized alpha, N = sample size, and objective = for the weighted combined error rate.

References

Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. <https://doi.org/10.1080/00949658208810607>

Examples

# \donttest{
res <- power_standardized_alpha(power_function = "pwr::pwr.t.test(d = 0.3,
n = x, sig.level = a_stan, type = 'two.sample',
alternative = 'two.sided')$power", power = 0.9, alpha = 0.05)
#> [1] "The standardized alpha is0.0307147558416976"
res$N
#> [1] 265
# }