View source: R/calculate_power_curves.R
| calculate_power_curves | R Documentation |
Calculate and optionally plot power curves for different effect sizes and trial counts. This function takes a
calculate_power_curves(
trials,
effectsize = 1,
candidateset = NULL,
model = NULL,
alpha = 0.05,
gen_args = list(),
eval_function = "eval_design",
eval_args = list(),
random_seed = 123,
iterate_seed = FALSE,
plot_results = TRUE,
auto_scale = TRUE,
x_breaks = NULL,
y_breaks = seq(0, 1, by = 0.1),
ggplot_elements = list()
)
trials |
A numeric vector indicating the trial(s) used when computing the power curve. If a single
value, this will be fixed and only |
effectsize |
Default |
candidateset |
Default |
model |
Default |
alpha |
Default |
gen_args |
Default |
eval_function |
Default |
eval_args |
Default |
random_seed |
Default |
iterate_seed |
Default |
plot_results |
Default |
auto_scale |
Default |
x_breaks |
Default |
y_breaks |
Default |
ggplot_elements |
Default |
A data.frame of power values with design generation information.
if(skpr:::run_documentation()) {
cand_set = expand.grid(brew_temp = c(80, 85, 90),
altitude = c(0, 2000, 4000),
bean_sun = c("low", "partial", "high"))
#Plot power for a linear model with all interactions
calculate_power_curves(trials=seq(10,60,by=5),
candidateset = cand_set,
model = ~.*.,
alpha = 0.05,
effectsize = 1,
eval_function = "eval_design") |>
head(30)
}
if(skpr:::run_documentation()) {
#Add multiple effect sizes
calculate_power_curves(trials=seq(10,60,by=1),
candidateset = cand_set,
model = ~.*.,
alpha = 0.05,
effectsize = c(1,2),
eval_function = "eval_design") |>
head(30)
}
if(skpr:::run_documentation()) {
#Generate power curve for a binomial model
calculate_power_curves(trials=seq(50,150,by=10),
candidateset = cand_set,
model = ~.,
effectsize = c(0.6,0.9),
eval_function = "eval_design_mc",
eval_args = list(nsim = 100, glmfamily = "binomial")) |>
head(30)
}
if(skpr:::run_documentation()) {
#Generate power curve for a binomial model and multiple effect sizes
calculate_power_curves(trials=seq(50,150,by=10),
candidateset = cand_set,
model = ~.,
effectsize = list(c(0.5,0.9),c(0.6,0.9)),
eval_function = "eval_design_mc",
eval_args = list(nsim = 100, glmfamily = "binomial")) |>
head(30)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.