MyNixOS website logo
Description

Bayesian Power Analysis Using 'brms' and 'INLA'.

Provides tools for Bayesian power analysis and assurance calculations using the statistical frameworks of 'brms' and 'INLA'. Includes simulation-based approaches, support for multiple decision rules (direction, threshold, ROPE), sequential designs, and visualisation helpers. Methods are based on Kruschke (2014, ISBN:9780124058880) "Doing Bayesian Data Analysis: A Tutorial with R, JAGS, and Stan", O'Hagan & Stevens (2001) <doi:10.1177/0272989X0102100307> "Bayesian Assessment of Sample Size for Clinical Trials of Cost-Effectiveness", Kruschke (2018) <doi:10.1177/2515245918771304> "Rejecting or Accepting Parameter Values in Bayesian Estimation", Rue et al. (2009) <doi:10.1111/j.1467-9868.2008.00700.x> "Approximate Bayesian inference for latent Gaussian models by using integrated nested Laplace approximations", and Bürkner (2017) <doi:10.18637/jss.v080.i01> "brms: An R Package for Bayesian Multilevel Models using Stan".

powerbrmsINLA

Overview

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.

Installation

You can install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("https://github.com/Tony-Myers/powerbrmsINLA")

Example

Here is a minimal example to get started. For speed in a README, the code is not evaluated on knit.

library(powerbrmsINLA)

# Run Bayesian power analysis
results <- brms_inla_power(
  formula = outcome ~ treatment,
  effect_name = "treatment", 
  effect_grid = c(0.2, 0.5, 0.8),
  sample_sizes = c(50, 100),
  nsims = 5  # Reduced for speed
)

# Inspect summary results
results$summary

# Plot power heatmap  
plot_power_heatmap(results)

Model Complexity Considerations

For optimal performance:

  • Simple to moderate models: All sample sizes supported
  • Complex random effects (e.g., (1 + time | subject)): Recommend n ≥ 50 subjects
  • Large effect grids: Consider starting with fewer simulations (nsims = 50-100) for initial exploration

The 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).

Package documentation

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 Pages

License

This package is released under the MIT License.
See the LICENSE file for details.

Metadata

Version

1.1.1

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows