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

gibbs

Metropolis within Gibbs sampling algorithm of a posterior distribution


Description

Implements a Metropolis-within-Gibbs sampling algorithm for an arbitrary real-valued posterior density defined by the user

Usage

gibbs(logpost,start,m,scale,...)

Arguments

logpost

function defining the log posterior density

start

array with a single row that gives the starting value of the parameter vector

m

the number of iterations of the chain

scale

vector of scale parameters for the random walk Metropolis steps

...

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

vector of acceptance rates of the Metropolis steps of the algorithm

Author(s)

Jim Albert

Examples

data=c(6,2,3,10)
start=array(c(1,1),c(1,2))
m=1000
scale=c(2,2)
s=gibbs(logctablepost,start,m,scale,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.