View source: R/engine-sequential.R
| brms_inla_power_sequential | R Documentation |
Simulates assurance sequentially in batches, stopping early per cell based on Wilson confidence intervals.
brms_inla_power_sequential(
formula,
family = gaussian(),
family_control = NULL,
Ntrials = NULL,
E = NULL,
scale = NULL,
priors = NULL,
data_generator = NULL,
effect_name,
effect_grid,
sample_sizes,
metric = c("direction", "threshold", "rope", "bf"),
target = 0.8,
prob_threshold = 0.95,
effect_threshold = 0,
rope_bounds = NULL,
credible_level = 0.95,
compute_bayes_factor = FALSE,
error_sd = 1,
group_sd = 0.5,
obs_per_group = 10,
predictor_means = NULL,
predictor_sds = NULL,
seed = 123,
batch_size = 20,
min_sims = 40,
max_sims = 600,
ci_conf = 0.95,
margin = 0.02,
inla_num_threads = NULL,
family_args = list(),
progress = TRUE
)
formula |
brms-style model formula. |
family |
GLM family (e.g., gaussian(), binomial()). |
family_control |
Optional list for INLA's control.family. |
Ntrials |
Optional vector of binomial trial counts (for binomial families). |
E |
Optional vector of exposures (for Poisson families). |
scale |
Optional numeric vector for scale parameter in INLA. |
priors |
brms prior specification object. Supported priors are
translated to INLA controls where possible and audited in
|
data_generator |
Optional function(n, effect) to simulate data. |
effect_name |
Character vector of fixed effects to assess. |
effect_grid |
Data frame or vector of effect values. |
sample_sizes |
Vector of sample sizes. |
metric |
Character; one of "direction", "threshold", "rope", or "bf" for Bayesian decision metric. |
target |
Target conditional power for the stopping rule (0-1). |
prob_threshold |
Posterior probability threshold for decision metrics. |
effect_threshold |
Effect-size threshold. |
rope_bounds |
Numeric length-2 vector defining ROPE. |
credible_level |
Credible interval level for Bayesian inference. |
compute_bayes_factor |
Logical; TRUE if metric is "bf". |
error_sd |
Residual standard deviation. |
group_sd |
Standard deviation of random effects. |
obs_per_group |
Number of observations per group. |
predictor_means |
Optional named list of predictor means. |
predictor_sds |
Optional named list of predictor standard deviations. |
seed |
Random seed. |
batch_size |
Number of simulations per sequential look. |
min_sims |
Minimum simulations before early stopping. |
max_sims |
Maximum simulations per cell. |
ci_conf |
Confidence level for Wilson confidence intervals. |
margin |
Margin around target for early stopping decision. |
inla_num_threads |
Character string specifying INLA threading (e.g., "4:1"). If NULL (default), automatically detects optimal setting based on CPU cores. |
family_args |
List of family-specific args passed to data generator. |
progress |
Logical; if TRUE, show progress messages. |
Sequential Bayesian Assurance Simulation Engine (Modern, Multi-Effect Ready)
Simulates assurance sequentially in batches, stopping early per cell based on Wilson confidence intervals.
A list of class "brms_inla_power" with a per-cell summary (including
the conditional_power column, the Monte Carlo estimate at each fixed
effect value) and simulation settings. Note this is conditional power at
each grid value, not unconditional assurance; pass the result to
compute_assurance() for the latter.
## Not run:
# Sequential design with automatic threading
results <- brms_inla_power_sequential(
formula = outcome ~ treatment,
effect_name = "treatment",
effect_grid = c(0.2, 0.5, 0.8),
sample_sizes = c(50, 100, 200),
metric = "direction",
target = 0.80
)
print(results$summary)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.