
A Compendium of Bayesian Statistical Routines Written in C++
This is a compendium of C++ routines useful for Bayesian statistics. We steal other people’s C++ code, repurpose it, and export it so developers of R packages can use it in their C++ code. We actually don’t steal anything, or claim that Thomas Bayes did, but copy code that is compatible with our GPL 3 licence, fully acknowledging the authorship of the original code.
You are welcome to contribute to StealLikeBayes! How does this work?
src/*.cppsrc/*.hR/*.R with full
documentation and acknowledgement of the original code authorship,inst/tinytest/test_*.R,DESCRIPTION,DESCRIPTION and
R/StealLikeBayes-package.R.Rcpp::compileAttributes()
devtools::document()
devtools::check()
Please, feel free to use it whatever way you feel like, ofc! We create it with two intended uses:
In order to use our C++ code in your R package you need to ensure you include all the dependencies to both: our package, and packages on which our functions rely on such as RcppArmadillo. The latter is on you!
To use C++ code from StealLikeBayes follow the steps:
DESCRIPTION file, e.g.:
LinkingTo: StealLikeBayes and
Imports: StealLikeBayes.R/*-package.R file, e.g.:
@import: StealLikeBayessrc/*.cpp files, e.g.:
#include "StealLikeBayes.h".arma::vec out = StealLikeBayes::rnorm1_precision_sampler(zeros<vec>(10), ones<vec>(10), -0.5);
That’s simple!
DESCRIPTION file, e.g.:
Imports: StealLikeBayes.R/*-package.R file,
e.g. @importFrom StealLikeBayes rnorm1_precision_sampler.out = StealLikeBayes::rnorm1_precision_sampler(rep(0, 10), rep(1, 10), -0.5)
You must have a cpp compiler. Follow the instructions from Section 1.3. by Eddelbuettel & François (2023). In short, for Windows: install RTools, for macOS: install Xcode Command Line Tools, and for Linux: install the standard development packages.
You can install the StealLikeBayes package by running:
install_packages("StealLikeBayes")You can install the developer’s version of StealLikeBayes from its GitHub repository by running:
devtools::install_github("bsvars/StealLikeBayes")