MCMC Fitting

radvel.mcmc.convergence_calculate(chains, oldautocorrelation, minAfactor, maxArchange, minTz, maxGR)[source]

Calculate Convergence Criterion

Calculates the Gelman-Rubin statistic, autocorrelation time factor, relative change in autocorrellation time, and the number of independent draws for each parameter, as defined by Ford et al. (2006) (http://adsabs.harvard.edu/abs/2006ApJ…642..505F). The chain is considered well-mixed if all parameters have a Gelman-Rubin statistic of <= 1.03, the min autocorrelation time factor >= 75, a max relative change in autocorrelation time <= .01, and >= 1000 independent draws.

Parameters
  • chains (array) – A 3 dimensional array of parameter values

  • oldautocorrelation (float) – previously calculated autocorrelation time

  • minAfactor (float) – minimum autocorrelation time factor to consider well-mixed

  • maxArchange (float) – maximum relative change in autocorrelation time to consider well-mixed

  • minTz (int) – minimum Tz to consider well-mixed

  • maxGR (float) – maximum Gelman-Rubin statistic to consider well-mixed

Returns

tuple containing:
ismixed (bool):

Are the chains well-mixed?

afactor (array):

A matrix containing the autocorrelation time factor for each parameter and ensemble combination

archange (matrix):

A matrix containing the relative change in the autocorrelation time factor for each parameter and ensemble combination

autocorrelation (matrix):

A matrix containing the autocorrelation time for each parameter and ensemble combination

gelmanrubin (array):

An NPARS element array containing the Gelman-Rubin statistic for each parameter (equation 25)

Tz (array):

An NPARS element array containing the number of independent draws for each parameter (equation 26)

Return type

tuple

History:
2010/03/01:

Written: Jason Eastman - The Ohio State University

2012/10/08:

Ported to Python by BJ Fulton - University of Hawaii, Institute for Astronomy

2016/04/20:

Adapted for use in RadVel. Removed “angular” parameter.

2019/10/24:

Adapted to calculate and consider autocorrelation times

radvel.mcmc.convergence_check(minAfactor, maxArchange, maxGR, minTz, minsteps, minpercent, headless)[source]

Check for convergence

Check for convergence for a list of emcee samplers

Parameters
  • minAfactor (float) – Minimum autocorrelation time factor for chains to be deemed well-mixed and halt the MCMC run

  • maxArchange (float) – Maximum relative change in the autocorrelative time to be deemed well-mixed and halt the MCMC run

  • maxGR (float) – Maximum G-R statistic for chains to be deemed well-mixed and halt the MCMC run

  • minTz (int) – Minimum Tz to consider well-mixed

  • minsteps (int) – Minimum number of steps per walker before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.

  • minpercent (float) – Minimum percentage of total steps before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.

  • headless (bool) – if set to true, the convergence statistics will not be displayed in real time.

radvel.mcmc.mcmc(post, nwalkers=50, nrun=10000, ensembles=8, checkinterval=50, minAfactor=40, maxArchange=0.03, burnAfactor=25, burnGR=1.03, maxGR=1.01, minTz=1000, minsteps=1000, minpercent=5, thin=1, serial=False, save=False, savename=None, proceed=False, proceedname=None, headless=False)[source]

Run MCMC Run MCMC chains using the emcee EnsambleSampler :param post: radvel posterior object :type post: radvel.posterior :param nwalkers: (optional) number of MCMC walkers :type nwalkers: int :param nrun: (optional) number of steps to take :type nrun: int :param ensembles: (optional) number of ensembles to run. Will be run

in parallel on separate CPUs

Parameters
  • checkinterval (int) – (optional) check MCMC convergence statistics every checkinterval steps

  • minAfactor (float) – Minimum autocorrelation time factor to deem chains as well-mixed and halt the MCMC run

  • maxArchange (float) – Maximum relative change in autocorrelation time to deem chains and well-mixed

  • burnAfactor (float) – Minimum autocorrelation time factor to stop burn-in period. Burn-in ends once burnGr or burnAfactor are reached.

  • burnGR (float) – (optional) Maximum G-R statistic to stop burn-in period. Burn-in ends once burnGr or burnAfactor are reached.

  • maxGR (float) – (optional) Maximum G-R statistic for chains to be deemed well-mixed and halt the MCMC run

  • minTz (int) – (optional) Minimum Tz to consider well-mixed

  • minsteps (int) – Minimum number of steps per walker before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.

  • minpercent (float) – Minimum percentage of total steps before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.

  • thin (int) – (optional) save one sample every N steps (default=1, save every sample)

  • serial (bool) – set to true if MCMC should be run in serial

  • save (bool) – set to true to save MCMC chains that can be continued in a future run

  • savename (string) – location of h5py file where MCMC chains will be saved for future use

  • proceed (bool) – set to true to continue a previously saved run

  • proceedname (string) – location of h5py file with previously MCMC run chains

  • headless (bool) – if set to true, the convergence statistics will not display in real time

Returns

DataFrame containing the MCMC samples

Return type

DataFrame