Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


R Bridge for MultiNest

Author: Johannes Buchner (C) 2012-2013


This code allows likelihood functions written in R ( to be used by MultiNest.

How does it work

The main program will connect to R using Rserve. It will run MultiNest, and for each point evaluation call the user-defined R callback function.


  1. You need MultiNest.


    If you do not do this, you will see this error:

    ./rbridge: error while loading shared libraries: cannot open shared object file: No such file or directory
  2. Download this package (latest at, and extract it into the MultiNest directory.


    Quick installation:

    $ R --no-save
    > install.packages("Rserve")
    > quit()
    $ make rbridge test

    If that doesn't go through smoothly, follow the manual steps 2-6.

Please report issues at

Building Rserve C++ client

Otherwise, follow these manual steps.

  1. Download Rserve (the tar file, Rserve_xxxx.tar.gz) from and extract it into this directory. You should now have:

    $ ls
  2. Configure Rserve:

    $ ./Rserve/configure
  3. Configure and build the Rserve C++ client (in Rserve/clients/cxx/):

    $ cd Rserve/clients/cxx/
    $ ./configure && make Rconnection.o
    $ cd ../../../

Building Rbridge

  1. Run make to compile Rbridge:

    $ make

Installing Rserve in R

  1. In R, install RServe using the instructions on the website. In short:

    $ R
    > install.packages("Rserve")


The "" script runs the steps below for testing whether the installation worked. But you probably want to understand how to run your own code, so follow these steps.

  1. Write log likelihood function in a R file (has to be called "log_likelihood"), and a prior transformation (has to be called "prior")


    prior <- function(cube) cube
    log_likelihood <- function(params) {
    print (params);

    This is an example flat log_likelihood, and a flat prior.

  2. Write a config file that tells which file to load

    source test.r
  3. Run Rserve

    $ R
    > library(Rserve) # you installed this package before using install.packages
    > Rserve(args=c("--RS-conf", "", "--no-save"))
  4. run ./rbridge in shell

    $ ./rbridge

    This will connect to R using Rserve, and call R through that for each point evaluation.

  5. Finally, terminate Rserve

    $ killall

What now?

Well, you should now have the MultiNest output files lying there. You can learn to understand them by reading the MultiNest README (

You can either use pymultinest to plot and analyse them, or write your own routines in R.

You can’t perform that action at this time.