Description Usage Arguments Value Examples
Same idea as purrr::pmap, but with some different
functionality. It can runs all combinations of vector-valued arguments in
...
or the 1st set, 2nd set, and so forth, and multiple trials can be
run for each scenario, which can be useful for simulations.
1 2 |
f |
A function. |
... |
Arguments to |
all_combinations |
Logical value for whether to iterate over all
combinations of arguments in |
fix |
List of arguments to |
trials |
Numeric value. |
varnames |
Character vector of names for values that |
Data frame.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Define function to generate data from N(mu, sigsq) and perform t-test.
f <- function(n = 100, mu = 0, sigsq = 1, alpha = 0.05) {
x <- rnorm(n = n, mean = mu, sd = sqrt(sigsq))
fit <- t.test(x = x, alpha = alpha)
return(list(t = fit$statistic, p = fit$p.value))
}
# Call f once for various sample sizes and means
f %>% iterate(n = c(100, 500), mu = c(0.1, 0.25))
# Run 100 trials for each scenario and calculate empirical power
f %>% iterate(n = c(100, 500), mu = c(0.1, 0.25), trials = 100) %>%
group_by(n, mu) %>%
summarise(mean(p < 0.05))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.