powerbrmsINLA provides tools for Bayesian
power analysis and assurance calculations
using the statistical frameworks of brms and
INLA.
It includes simulation-based and analytical approaches, support for
multiple decision rules (direction, threshold,
rope), sequential and two-stage designs, and visualisation
helpers for power curves, precision, Bayes factors, and robustness.
You can install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("https://github.com/Tony-Myers/powerbrmsINLA")Here is a minimal example to get started. For speed in a README, the code is not evaluated on knit.
library(brmsINLApower)
set.seed(1)
# Simple dataset generator using .auto_data_generator()
gen_fun <- brmsINLApower:::.auto_data_generator(
formula = y ~ x,
effect_name = "x",
family = gaussian()
)
# Run Bayesian power analysis with reduced settings for speed
res <- brms_inla_power(
formula = y ~ x,
effect_name = "x",
effect_grid = 0.5,
sample_sizes = c(20, 40),
nsims = 5,
data_generator = gen_fun
)
# Inspect summary results
res$summary
# Plot a power heatmap
plot_power_heatmap(res)For optimal performance:
(1 + time | subject)): Recommend n ≥ 50 subjectsThe package handles the vast majority of Bayesian power analysis scenarios. For computationally demanding models, standard Bayesian modeling best practices apply (adequate sample sizes, model complexity appropriate to data).
If you use pkgdown you can build
a website:
usethis::use_pkgdown() # once, to set up pkgdown
pkgdown::build_site() # build the site locally
# usethis::use_pkgdown_github_pages() # set up GitHub PagesThis package is released under the MIT License.
See the LICENSE file for details.