Learn R Programming

powerbrmsINLA (version 1.1.1)

brms_inla_power: Core Bayesian Assurance / Power Simulation (Modern, Multi-Effect Ready)

Description

Provides Bayesian power analysis and assurance calculation using INLA (Integrated Nested Laplace Approximation) for efficient computation. Implements simulation-based power analysis for generalized linear mixed models with automatic threading optimization.

Usage

brms_inla_power(
  formula,
  family = gaussian(),
  family_control = NULL,
  Ntrials = NULL,
  E = NULL,
  scale = NULL,
  priors = NULL,
  data_generator = NULL,
  effect_name,
  effect_grid = 0.5,
  sample_sizes = c(50, 100, 200, 400),
  nsims = 200,
  power_threshold = 0.8,
  precision_target = NULL,
  prob_threshold = 0.95,
  effect_threshold = 0,
  credible_level = 0.95,
  rope_bounds = NULL,
  error_sd = 1,
  group_sd = 0.5,
  obs_per_group = 10,
  predictor_means = NULL,
  predictor_sds = NULL,
  seed = 123,
  inla_hyper = NULL,
  compute_bayes_factor = FALSE,
  bf_method = c("sd", "marglik"),
  bf_cutoff = 10,
  inla_num_threads = NULL,
  progress = c("auto", "text", "none"),
  family_args = list()
)

Value

List with results, summary, and settings.

Arguments

formula

Model formula.

family

brms GLM family (e.g., gaussian(), binomial()).

family_control

Optional list for INLA's control.family.

Ntrials

Optional vector for binomial trials.

E

Optional vector for Poisson exposure.

scale

Optional vector scale parameter for INLA families.

priors

Optional brms::prior specification.

data_generator

Optional function(n, effect) returning a dataset.

effect_name

Character vector of fixed effect names.

effect_grid

Vector/data.frame of effect values (supports multi-effect). For single effects, use a numeric vector. For multiple effects, use a data.frame with column names matching effect_name.

sample_sizes

Vector of sample sizes.

nsims

Number of simulations per cell.

power_threshold

Decision probability threshold for summary.

precision_target

Optional credible interval width target.

prob_threshold

Posterior probability threshold for decision rules.

effect_threshold

Effect-size threshold.

credible_level

Credible interval level (default 0.95).

rope_bounds

Optional Region of Practical Equivalence bounds (length 2 vector).

error_sd

Gaussian residual standard deviation.

group_sd

Random effects standard deviation.

obs_per_group

Observations per group.

predictor_means

Optional named list of predictor means.

predictor_sds

Optional named list of predictor standard deviations.

seed

Random seed.

inla_hyper

Optional INLA-specific hyperparameters.

compute_bayes_factor

Logical, compute Bayes Factor if TRUE.

bf_method

Character. "sd" = Savage-Dickey at 0 (requires proper Normal prior on the tested coefficient); "marglik" = marginal-likelihood Bayes factor via INLA by comparing full vs reduced model (slower).

bf_cutoff

Numeric Bayes-factor threshold for declaring a "hit" (default 10).

inla_num_threads

Character string specifying INLA threading (e.g., "4:1" for 4 threads). If NULL (default), automatically detects optimal setting: "4:1" for 4+ cores, "2:1" for 2-3 cores, "1:1" otherwise.

progress

One of "auto", "text", or "none" for progress display.

family_args

List of arguments for family-specific data generators.