MH: Run a Metropolis-Hastings chain

Description Usage Arguments Value See Also

Description

This function implements a Metropolis-Hastings MCMC algorithm.

Usage

1
2
3
4
  MH(initial.state, target.logpdf, n.mcmc,
    kernel.rnd = random.walk,
    kernel.logpdf = function(from, to) 0,
    .progress = progress_text)

Arguments

initial.state

Vector of starting point

target.logpdf

Evaluate the log-pdf of the target distribution

n.mcmc

Number of MCMC iterations

kernel.rnd

Sampling from proposal kernel on the parameter space, default to random.walk

.progress

Progress bar to use, from plyr package, default to progress_text

Value

A list with the following components:

trace

Matrix (n.mcmc, length(initial.state)) of accepted states

logpdf

Matrix (n.mcmc, 1) of the log-pdf of the accepted states

proposed

Matrix (n.mcmc, length(initial.state)) of the proposed states

proposedpdf

Matrix (n.mcmc, 1) of the log-pdf of the proposed states

logmhratio

Matrix (n.mcmc, 1) of the logarithm of Metropolish acceptance ratio

See Also

MH, progress_text, random_walk


nickpoison/nltsa documentation built on May 23, 2019, 4:48 p.m.