Metropolis: Metropolis Markov chain sample

Description Usage Arguments Details Value Author(s)

Description

Calculates a Markov Chain of a probability distribution of a vector of continuous random variables, using the Metropolis algorithm with a normal jump distribution with given standard deviations and correlation structure.

Usage

1
2
Markovchain.Metropolis(log.pdf,z.ini,prop.sd,prop.cor=0,
                       sampsize,thin=1,...)

Arguments

log.pdf

function log.pdf(z,...) that calculates the log of the probability density function of the vector of random variables that are to be sampled. log.pdf must be given a single vector z at which the density is to be evaluated. Additional arguments from the call to markovchain.metropolis will be passed on. If the probability density is zero, NA must be returned.

z.ini

vector of values at which the chain is to be started

prop.sd

vector of standard deviations of the proposal distribution

prop.cor

correlation matrix of proposal distribution, or NA if all correlations are zero

sampsize

sample size (length of the chain)

thin

factor with which to thin storage of results (thin=n: only each nth result is returned; this saves memory)

...

additional parameters passed to log.pdf

Details

The log of the probability density of the distribution must be specified as a function log.pdf(z,...), where z is the vector of values for which the density should be evaluated.

Value

Returns a list containing:

z

sample as a matrix, with sample points in rows

log.pdf

vector with log pdf values of the sample

reject.freq

rejection frequency of the jumps

error

error message (empty string if no error occurred)

Author(s)

Peter Reichert <peter.reichert@eawag.ch>


baccione-eawag/EawagSchoolTools documentation built on Dec. 19, 2021, 6:38 a.m.