Description Usage Arguments Details Value See Also Examples
This is a convenience function that allows the user to vary one parameter or design element and perform a simulated power analysis for each provided value. All other parameters/design elements will be held fixed for all simulations.
1 | vary_element(simfun = "lmm_f", tovary = "nrep", values, ...)
|
simfun |
Character. The name of the function you want to use for the simulations. Currently can only be |
tovary |
Character. The name of the argument for the study design element you'd like to allow to vary in the function you defined in |
values |
Numeric vector or list of vectors. The values you want to use for the |
... |
Other arguments to the function you defined in |
This function is a simple wrapper around a loop to run through the values from your chosen parameter/design element and repeat the power analysis for each one. This is not a particularly efficient function, and you may want to use a different approach if exploring the power for a large number of values.
A data.frame with a row for each simulation done containing the estimated power along with the study design information and true treatment means your defined.
lmm_f()
and lm_2f()
for the function arguments you'll need to define in ...
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Here's an example to explore the change in power
# for 5 vs 15 blocks in lmm_f()
vary_element(tovary = "nblock",
values = c(5, 15),
nsim = 10,
trtmeans = c(1, 2),
sd_block = 2,
sd_resid = 2)
# Allow for more reps per treatment group
# in each block
vary_element(tovary = "nrep",
values = c(6, 10),
nsim = 10,
trtmeans = c(1, 2),
sd_block = 2,
sd_resid = 2)
# Vary effect size by providing different treatment means
vary_element(tovary = "trtmeans",
values = list(c(5, 15), c(5, 5)),
nsim = 10,
nblock = 5,
sd_block = 2,
sd_resid = 2)
# Here is an example varying
# the overall residual standard deviations
vary_element(tovary = "sd_resid",
values = c(2, 10),
nsim = 20,
trtmeans = c(1, 2),
nblock = 15,
sd_block = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.