Mcmc

object Mcmc

Functions for constucting generic Metropolis-Hastings MCMC algorithms, and associated utilities. Can be used in conjunction with an unbiased estimate of marginal model likelihood for constructing pseudo-marginal MCMC algorithms, such as PMMH pMCMC.

class Object
trait Matchable
class Any

Value members

Concrete methods

def acf(x: Seq[Double], lm: Int): DenseVector[Double]

Autocorrelation function

Autocorrelation function

Value Params
lm

Maximum lag required

x

Input data

Returns

A vector of autocorrelations

def mhStream[P](init: P, logLik: P => LogLik, rprop: P => P, dprop: (P, P) => LogLik, dprior: P => LogLik, verb: Boolean): LazyList[P]

Function to construct a generic Metropolis-Hastings MCMC algorithm for Bayesian inference. Note that this algorithm avoids re-computation of the log-likelihood associated with the current state, and is therefore suitable for use with the log of an unbiased estimate of likelihood for the constuction of pseudo-marginal "exact approximate" MCMC algorithms.

Function to construct a generic Metropolis-Hastings MCMC algorithm for Bayesian inference. Note that this algorithm avoids re-computation of the log-likelihood associated with the current state, and is therefore suitable for use with the log of an unbiased estimate of likelihood for the constuction of pseudo-marginal "exact approximate" MCMC algorithms.

Value Params
dprior

A function to evaluate the log of the prior density

dprop

A function to evaluate the log-likelihood of the proposal transition kernel

init

The initial state of the MCMC algorithm

logLik

The log-likelihood of the model

rprop

A function to sample from a proposal distribution

verb

Should the function print diagnostic information to the console at each iteration?

Returns

An infinite Stream corresponding to the MCMC chain. Note that this can be processed with typical Scala combinators such as drop (for burn-in) and take (for run-length). If Types are imported, there is also a thin method (which can be used for thinning the chain).

def nextValue[P](logLik: P => LogLik, rprop: P => P, dprop: (P, P) => LogLik, dprior: P => LogLik, verb: Boolean)(current: (P, LogLik)): (P, LogLik)

Function for executing one step of a MH algorithm. Called by mhStream.

Function for executing one step of a MH algorithm. Called by mhStream.

def summary(m: DenseMatrix[Double], plt: Boolean, lm: Int): Unit

Generate some basic diagnostics associated with an MCMC run. Called purely for the side-effect of generating output on the console.

Generate some basic diagnostics associated with an MCMC run. Called purely for the side-effect of generating output on the console.

Value Params
lm

Max lag for ACF plot

m

A matrix, such as generated by toDMD containing MCMC output

plt

Generate plots?

def summary[P](s: Seq[P], plot: Boolean)(implicit evidence$2: CsvRow[P]): Unit

Wrapper around the other summary function which takes a Stream

Wrapper around the other summary function which takes a Stream

Value Params
plot

Generate plots?

s

A finite stream of MCMC iterations.

def toDMD[P](s: Seq[P])(implicit evidence$1: CsvRow[P]): DenseMatrix[Double]

Utility function to convert a finite Stream (or other collection) to a Breeze DenseMatrix[Double].

Utility function to convert a finite Stream (or other collection) to a Breeze DenseMatrix[Double].

Value Params
s

Input stream/collection, which must be finite.

Returns

A matrix with rows corresponding to iterations and columns corresponding to variables.