Metropolis_OAAT {HydroPortailStats}R Documentation

One-At-A-Time Metropolis sampler

Description

Performs nsim iterations of the OAAT Metropolis sampler (simulated vector is updated one component at a time). a.k.a block Metropolis sampler with blocks of length one. Sometimes also called 'Metropolis-within-Gibbs'.

Usage

Metropolis_OAAT(f, x0, nsim, sdjump, ...)

Arguments

f

function, log-pdf of the target distribution

x0

numeric vector, starting point

nsim

integer, number of simulations

sdjump

numeric vector, standard deviation of the Gaussian jump for each component

...

other arguments passed to f

Value

A list with the following components:

x

numeric matrix nsim*length(x0), MCMC simulations

fx

numeric vector, corresponding values f(x)

moverate

numeric vector, move rate associated with each component

Examples

# Bivariate target distribution: beta(0.8,0.4) X exp(1)
f=function(x){stats::dbeta(x[1],0.8,0.4,log=TRUE)+stats::dexp(x[2],log=TRUE)}
x0=c(0.5,2)
sdjump=c(0.5,1)
mcmc=Metropolis_OAAT(f,x0,1000,sdjump)
graphicalpar=par(mfrow=c(1,3))
plot(mcmc$x);hist(mcmc$x[,1]); hist(mcmc$x[,2])
par(graphicalpar)

[Package HydroPortailStats version 1.0.3 Index]