View source: R/engine-two-stage.R
| brms_inla_power_two_stage | R Documentation |
Runs a two-stage Bayesian assurance simulation with formula-based multi-effect grids and adaptive refinement.
brms_inla_power_two_stage(
formula,
effect_name,
effect_grid,
n_range,
stage1_k_n = 8,
stage1_nsims = 100,
stage2_nsims = 400,
refine_metric = c("direction", "threshold", "rope"),
refine_target = 0.8,
prob_threshold = 0.95,
effect_threshold = 0,
obs_per_group = 10,
error_sd = 1,
group_sd = 0.5,
band = 0.06,
expand = 1L,
inla_num_threads = NULL,
...
)
formula |
Model formula. |
effect_name |
Character vector of fixed effect names; must match formula terms. |
effect_grid |
Data frame with columns named by effect_name specifying effect values. |
n_range |
Numeric length-2 vector specifying sample size range. |
stage1_k_n |
Number of grid points in stage 1. |
stage1_nsims |
Number of simulations per cell in stage 1. |
stage2_nsims |
Number of simulations per cell in stage 2. |
refine_metric |
Metric used for refinement; one of "direction", "threshold", or "rope". |
refine_target |
Target assurance for refined cells. |
prob_threshold |
Posterior probability threshold for decision. |
effect_threshold |
Effect-size threshold for decision metric. |
obs_per_group |
Number of observations per group for grouping factors. |
error_sd |
Residual standard deviation. |
group_sd |
Standard deviation of random effects. |
band |
Numeric width of the target refinement band. |
expand |
Integer; how much to expand the refinement grid around candidates. |
inla_num_threads |
Character string specifying INLA threading (e.g., "4:1"). If NULL (default), automatically detects optimal setting based on CPU cores. |
... |
Additional arguments passed to internal functions. |
A list with combined simulation results, summary, and stage parameters.
## Not run:
# Two-stage design with threading
effect_grid <- expand.grid(
treatment = c(0.2, 0.5, 0.8),
covariate = c(0.1, 0.3)
)
results <- brms_inla_power_two_stage(
formula = outcome ~ treatment + covariate,
effect_name = c("treatment", "covariate"),
effect_grid = effect_grid,
n_range = c(50, 200),
stage1_nsims = 3,
stage2_nsims = 3,
error_sd = 1
)
print(results$summary)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.