Skip to contents

Empirical Monte-Carlo power

Usage

mrm_mc_power(simulator, n_sims = 1000L, alpha = 0.05, seed = 42L)

Arguments

simulator

A function(seed) returning a p-value.

n_sims

Number of simulated datasets.

alpha

Type-I error level.

seed

Seed for outer RNG.

Value

Named list with empirical_power, se, ci95 bounds.

Examples

# Empirical power of a one-sample t-test against H0: mu = 0
# with true mu = 0.4 and n = 30.
my_sim <- function(seed) {
  set.seed(seed)
  x <- rnorm(30, mean = 0.4, sd = 1)
  stats::t.test(x, mu = 0)$p.value
}
res <- mrm_mc_power(my_sim, n_sims = 500L, alpha = 0.05)
res$empirical_power
#> [1] 0.532
res$ci95_lower
#> [1] 0.4883
res$ci95_upper
#> [1] 0.5757