help mcmcconverge


mcmcconverge varlist [if] [in], iter(varname) chain(varname) saving( filename) [replace]

options Description ------------------------------------------------------------------------- iter(varname) variable identifying iterations of each Markov chain chain(varname) variable identifying independent Markov chains saving(filename) location to save file of results replace overwrite existing results file


mcmcconverge is a command for assessing the convergence of Markov chains in Markov Chain Monte Carlo (MCMC) estimation. It calculates the convergence statistics described in section 11.6 of Gelman et al. (2003).

The command assumes that you begin with a dataset in memory containing sequences of draws from two or more Markov chains. The variable specified in the chain() option should identify chains, and the variable specified in the iter() option should identify iterations within each chain. Each variable in varlist should contain draws of a different scalar estimand. The data should be arranged as a panel in long form, where chain identifies panels and iter identifies observations within panels. This panel is required to be balanced after any restrictions specified in the if/in option are applied.

The command saves results in the file specified by saving(filename). Each observation in the results file corresponds to a different scalar estimand. Each variable in the results file contains a different convergence statistic.

The convergence statistics are:

B The between-sequence variance. W The within-sequence variance. varplus The marginal posterior variance of the estimand. Rhat The potential scale reduction from further simulations; convergence is achieved when Rhat is near 1. neff The effective number of independent draws. neffmin min(neffmin,mn), where m is the number of chains and n is the number of iterations per chain.


Sam Schulhofer-Wohl, Federal Reserve Bank of Minneapolis, The views expressed herein are those of the author and not necessarily those of the Federal Reserve Bank of Minneapolis or the Federal Reserve System.


Gelman, Andrew, John B. Carlin, Hal S. Stern and Donald B. Rubin, 2003. Bayesian Data Analysis, 2nd ed. New York: Chapman & Hall.