Skip to contents

Creates a power analysis configuration object that specifies all parameters needed to conduct Bayesian power analysis for randomized controlled trials. This function creates an S7 object that serves as the main interface for configuring and executing power analysis simulations.

Usage

power_analysis(run = TRUE, ...)

Arguments

run

Logical indicating whether to immediately execute the analysis after creating the configuration object (default TRUE)

...

Arguments passed to the rctbp_power_analysis constructor, including:

  • conditions: An rctbp_conditions object containing the experimental conditions and design parameters for the power analysis

  • n_sims: Number of simulations to run per condition (default 100)

  • n_cores: Number of CPU cores to use for parallel execution (default 1). Must not exceed the number of available cores

  • verbose: Logical indicating whether to display progress information and analysis details (default TRUE)

  • brms_args: List of additional arguments to pass to brms::brm() function (default empty list)

  • design_prior: Prior specification for design parameters. Can be NULL (no prior), a string with brms syntax, or a function for custom priors

Value

An S7 object of class "rctbp_power_analysis" containing:

  • All input parameters for simulation control

  • Access to design and model specifications via properties

  • Placeholder slots for results (filled after running analysis)

Details

This function validates input parameters and creates a configuration object that can be executed using run(). The resulting object provides access to design and model information through S7 properties:

Key Properties:

  • design: Access to the experimental design configuration

  • model: Access to the underlying Bayesian model specification

  • conditions: The condition grid for analysis

Parallel Processing: When n_cores > 1, simulations are distributed across multiple cores for improved performance. The function validates that n_cores does not exceed available system cores.

Examples

if (FALSE) { # \dontrun{
# Create conditions for power analysis
conditions <- build_conditions(design, n_total = c(100, 200))

# Basic power analysis configuration
power_config <- build_power_analysis(conditions, n_sims = 100)

# Parallel execution with custom BRMS arguments
power_config <- build_power_analysis(
  conditions = conditions,
  n_sims = 1000,
  n_cores = 4,
  brms_args = list(chains = 4, iter = 2000)
)

# Execute the analysis
results <- run(power_config)
} # }