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")
::install_github("https://github.com/Tony-Myers/powerbrmsINLA") remotes
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()
<- brmsINLApower:::.auto_data_generator(
gen_fun formula = y ~ x,
effect_name = "x",
family = gaussian()
)
# Run Bayesian power analysis with reduced settings for speed
<- brms_inla_power(
res formula = y ~ x,
effect_name = "x",
effect_grid = 0.5,
sample_sizes = c(20, 40),
nsims = 5,
data_generator = gen_fun
)
# Inspect summary results
$summary
res
# 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:
::use_pkgdown() # once, to set up pkgdown
usethis::build_site() # build the site locally
pkgdown# usethis::use_pkgdown_github_pages() # set up GitHub Pages
This package is released under the MIT License.
See the LICENSE file for details.