No BSD License  

Highlights from
mcmc

4.05882

4.1 | 17 ratings Rate this file 49 Downloads (last 30 days) File Size: 16.12 KB File ID: #198

mcmc

by David Shera

 

22 Feb 1999

MCMC -- Markov Chain Monte Carlo Tools

| Watch this File

File Information
Description

MCMC -- Markov Chain Monte Carlo Tools Copyright (c) 1998, Harvard University. Full copyright in the file Copyright. Some routines require version 5 of Matlab, some will work with version 4

 There are three parts to this library of routines.
 1. *[rnd,pdf,lpr].m - distribution function tools to complement MATLAB's
 2. mcmc*.m - routines to calculate and display summaries of MCMC output
 3. other - other useful routines
  
   1. Distribution Function Tools

   These function help in random number generation and various calculations involving density functions.

 randrand - randomize both random number chains off the clock
 mvnormrnd - random multivariate normal - different from MATLAB's mvnrnd
 wishrnd - random Wishart value
 wishirnd - random Wishart value - integer df only
 invwishrnd - random inverse Wishart value
 invwishirnd - random inverse Wishart value - integer df only
 invwishpdf - inverse Wishart density
 metrop - a general Metropolis-Hastings step
 betalpr - log probability ratio for beta distribution
 gamlpr - log probability ratio for gamma distribution
 invwishlpr - log probability ratio for inverse wishart distribution
 mvnormlpr - log probability ratio for multivariate normal distribution
   
   2. MCMC Summaries
     
 mcmclt - lower triangle - for symmetric matricies to use with mcmctrace
 mcmcsumm - calculate summary statistics(includes autocorrelations and Gelman-Rubin statistics)
 mcmctrace - matrix of trace plots
 mcmcacf - to plot autocorrelations
 mcmcgr - Gelman-Rubin R statistic for convergence
 mcmcdemo - short demonstration program
 
   3. Other

 ltvec - convert a lower-triangular matrix into a vector
 veclt - convert a vector into a lower-triangular matrix
 ltindex - convert row and column index into lt-index

Please see the contents.m file for a full description.

MATLAB release MATLAB 5.2 (R10)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (19)
24 Jan 2003 Erasmo Mejia  
31 May 2003 pulak Ghosh  
10 Aug 2003 Birajashis Pattnaik

Problem with vesion

15 Oct 2003 Peter Xu

Could you send me the examples of MCMC (Markov Chain Monte Carlo) modelling.

Thanks.

from Peter Xu

15 Jan 2004 mohammad atef

plz send the file to me

29 Dec 2004 Felipe Reyes  
26 Apr 2005 Saverio Massi

Very good random generator for the Wishart: works much better than the one included in matlab (which is sometimes returning "strange samples")

15 Jul 2005 Mario Albeerto

inverse log function

09 Oct 2005 chen bw

I don't know how to excute ARS (adaptive rejection sampling) with matlab if the density is not standard.

05 Nov 2005 zhao xiaolin  
06 Dec 2005 la chen  
13 Dec 2005 yao hs  
02 Feb 2006 Atique Malik  
10 Oct 2006 Estevan Charreteiro

The veclt command only works for column vectors. But one can but in a transformation step to suit needs. Still a good program. thanks for posting.

10 Apr 2007 Zhang J.L.

Your programs are helpful for me, save my time. I will study it,thank you!

30 Apr 2008 kadek nanax  
17 Oct 2008 ipek cameller  
16 May 2010 Zuofeng

Hi David,

Thanks very much for help!

I am using your matlab function "mcmcgr" and have found one question.

I set up 5 chains each with length say 10000, and each chain only contains
zero components, so each chains is like "0,0,0,..." with 10000 zeros in it.

Obvious the convergence holds, but after I used mcmcgr to find its R
statistics, a "NaN" was reported. I don't know why this happens.

I am very grateful if you can help me with it!
Thanks a lot!

16 Nov 2010 David

There is a bug in this code:

In the definition of of the inverse wishart pdf the multivariate gamma distributrion is calculated as gammaln((d-k-klst)/2) which does not fit the definition of the multivariate gamma distribution: it should be gammaln(d - (k-klst)/2)

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics David Shera 22 Oct 2008 06:33:47
probability David Shera 22 Oct 2008 06:33:47
markov David Shera 22 Oct 2008 06:33:47
chain David Shera 22 Oct 2008 06:33:47
monte David Shera 22 Oct 2008 06:33:47
tools David Shera 22 Oct 2008 06:33:47
carlo David Shera 22 Oct 2008 06:33:47
carlo Peishi 22 Feb 2012 07:20:43
chain Peishi 22 Feb 2012 07:20:46
markov Peishi 22 Feb 2012 07:20:53

Contact us at files@mathworks.com