Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rwmetrop

Random walk Metropolis algorithm of a posterior distribution


Description

Simulates iterates of a random walk Metropolis chain for an arbitrary real-valued posterior density defined by the user

Usage

rwmetrop(logpost,proposal,start,m,...)

Arguments

logpost

function defining the log posterior density

proposal

a list containing var, an estimated variance-covariance matrix, and scale, the Metropolis scale factor

start

vector containing the starting value of the parameter

m

the number of iterations of the chain

...

data that is used in the function logpost

Value

par

a matrix of simulated values where each row corresponds to a value of the vector parameter

accept

the acceptance rate of the algorithm

Author(s)

Jim Albert

Examples

data=c(6,2,3,10)
varcov=diag(c(1,1))
proposal=list(var=varcov,scale=2)
start=array(c(1,1),c(1,2))
m=1000
s=rwmetrop(logctablepost,proposal,start,m,data)

LearnBayes

Functions for Learning Bayesian Inference

v2.15.1
GPL (>= 2)
Authors
Jim Albert
Initial release
2018-03-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.