Learn R Programming

⚠️There's a newer version (1.0.1) of this package.Take me there.

Bayesian inference for state-space models with R

[RBi] (https://github.com/libbi/RBi) is an R interface to [libbi] (http://libbi.org), 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_model class, to manipulate libbi models
  • a libbi wrapper class, to perform Bayesian using libbi inference from within R,

Installation

RBi requires R (>= 2.12.1) as well as the packages:

  • reshape2
  • ncdf4
  • data.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("libbi/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 or Unix, the easiest way is via the homebrew-science tap: Install Homebrew (on OS X) or Linuxbrew (on linux), then issue the following commands (using a command shell, i.e. Terminal or similar):

brew tap homebrew/science
brew install 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)        ## filtering

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.

Copy Link

Version

Install

install.packages('rbi')

Monthly Downloads

458

Version

0.6.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Sebastian Funk

Last Published

December 23rd, 2016

Functions in rbi (0.6.0)

bi_contents

Bi contents
bi_model_replace_all

replace all instances of one string with another
bi_model_remove_lines

Remove line(s) in a libbi model
bi_model_write

Writes a bi model to a file.
bi_model_propose_prior

Propose from the prior in a libbi model
bi_model

Bi Model
bi_read

Bi Read
bi_open

Bi open
bi_model_insert_lines

Insert lines in a libbi model
bi_model_set_name

Set the name of a bi model
get_traces

Get the parameter traces
libbi_clone

Clone a libbi object
generate_seed

Generate a random seed
bi_dim_values

NetCDF dimension values
option_string

Convert Options
bi_write

Create (init or observation) files for LibBi
bi_model_update_lines

Update line(s) in a libbi model
bi_file_summary

NetCDF File Summary
`[<-`

Subset assignment to mode lines
rbi-package

RBi - R interface for libbi
bi_generate_dataset

Bi Generate Dataset
log2normw

Normalize log weights
merge_by_name

Merge lists by name
libbi

LibBi Wrapper
libbi_run

Using the LibBi wrapper to launch LibBi
absolute_path

Absolute Path
bi_dim_len

NetCDF dimension length
bi_model_clone

Clones a model (returning a new object with the same properties)
bi_init_file

Create init files for LibBi, retained for backwards compatibility
bi_model_fix

Fix noise term, state or parameter of a libbi model
bi_model_get_lines

Get lines in a libbi model
option_list

Convert string to option list
netcdf_create_from_list

Create NetCDF File from R list
read_var_input

Read variable from NetCDF file.
`[`

Subset of model lines