Learn R Programming

powerbrmsINLA (version 1.1.1)

brms_inla_power_sequential: Sequential Bayesian Assurance Simulation Engine (Modern, Multi-Effect Ready)

Description

Simulates assurance sequentially in batches, stopping early per cell based on Wilson confidence intervals.

Usage

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 = 1,
  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
)

Value

List containing summary per cell and simulation settings.

Arguments

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.

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 assurance value for stopping.

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.

Details

Sequential Bayesian Assurance Simulation Engine (Modern, Multi-Effect Ready)

Simulates assurance sequentially in batches, stopping early per cell based on Wilson confidence intervals.

Examples

Run this code
if (FALSE) {
# 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)
}

Run the code above in your browser using DataLab