Bayesian inference for state-space models with R
RBi is an R interface to libbi, a library for Bayesian inference.
It mainly contains:
- various functions to retrieve and process the results from libbi (which are in NetCDF format)
- a
bi_modelclass, to manipulate libbi models - a
libbiwrapper class, to perform Bayesian using libbi inference from within R,
Installation
RBi requires R (>= 2.12.1) as well as the packages:
reshape2ncdf4data.table
The easiest way to install the latest stable version of RBi is via CRAN. The package is called rbi (all lower case):
install.packages('rbi')Alternatively, the current development version can be installed using the devtools package
# install.packages("devtools")
library('devtools')
install_github("sbfnk/RBi")The RBi package has only been tested on GNU/Linux and OS X, but it should mostly work everywhere R works.
If you want to use RBi as a wrapper to LibBi then you need a working version of LibBi. To install LibBi on a Mac, the easiest way is to install Homebrew, followed by (using a command shell, i.e. Terminal or similar):
brew install libbiOn linux, follow the instructions provided with LibBi.
The path to libbi script can be passed as an argument to RBi, otherwise the package tries to find it automatically using the which linux/unix command.
If you just want to process the output from LibBi, then you do not need to have LibBi installed.
Getting started
A good starting point is to look at the included demos:
demo(PZ_generate_dataset) ## generating a data set from a model
demo(PZ_PMMH) ## particle Markov-chain Metropolis-Hastings
demo(PZ_SMC2) ## SMC^2
demo(PZ_filtering) ## filteringFor further information, have a look at the introductory vignette from the link from the rbi CRAN package.
Using coda
LibBi contains the get_traces method which provides an interface to coda.
Other packages
For higher-level methods to interact with LibBi, have a look at RBi.helpers.