Mcmc

smfsb.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.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Mcmc.type

Members list

Value members

Concrete methods

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

Autocorrelation function

Autocorrelation function

Value parameters

lm

Maximum lag required

x

Input data

Attributes

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 parameters

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?

Attributes

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.

Attributes

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 parameters

lm

Max lag for ACF plot

m

A matrix, such as generated by toDMD containing MCMC output

plt

Generate plots?

Attributes

def summary[P : CsvRow](s: Seq[P], plot: Boolean): Unit

Wrapper around the other summary function which takes a Stream

Wrapper around the other summary function which takes a Stream

Value parameters

plot

Generate plots?

s

A finite stream of MCMC iterations.

Attributes

def toDMD[P : CsvRow](s: Seq[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 parameters

s

Input stream/collection, which must be finite.

Attributes

Returns

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