Skip to main content

What Is Rhat Bayesian?

by
Last updated on 5 min read

Rhat Bayesian refers to the Gelman-Rubin diagnostic, specifically the potential scale reduction factor (PSRF), which assesses whether Markov Chain Monte Carlo (MCMC) sampling has reached convergence.

What is Rhat Stan?

Rhat in Stan is a convergence diagnostic that estimates the potential scale reduction factor (PSRF) to determine whether MCMC chains have mixed well.

Stan’s Rhat function compares between-chain and within-chain variance for model parameters. You want values close to 1.0—anything above 1.1 means the chains haven’t quite settled in. Stan gives you extra metrics like ess_bulk and ess_tail to check effective sample size. Honestly, this is the best way to spot convergence issues early.

What is r-hat Bayesian?

R-hat, or the potential scale reduction factor, is a Bayesian diagnostic that checks whether MCMC chains have converged by comparing between-chain and within-chain variance.

Andrew Gelman and Donald Rubin introduced this in 1992, and it’s still the gold standard for convergence checks. Most folks consider R-hat below 1.05 acceptable. If you see high values, your chains haven’t explored the posterior fully. Always run multiple chains and check R-hat before trusting your results.

What is Gelman Rubin diagnostic?

The Gelman–Rubin diagnostic evaluates MCMC convergence by comparing within-chain and between-chain variance across multiple Markov chains.

This method, developed by Gelman and Rubin, uses the potential scale reduction factor (PSRF) to see if chains have mixed properly. A PSRF near 1.0? Great. Above 1.1? Not so much. You’ll find it in Bayesian tools like Stan, PyStan, and JAGS—it’s that important.

What is a Traceplot?

A traceplot visualizes MCMC sampling by plotting parameter values over iteration number, helping assess chain mixing and convergence.

Good traceplots look like a fuzzy caterpillar—no trends, no drifts, just a stable mess. Multiple chains overlapping nicely? That’s ideal. If they’re drifting apart or trending upward, your chains haven’t mixed well. You’ll find these in most Bayesian tools, from R’s coda package to Python’s ArviZ. Always pair traceplots with Rhat and ESS values.

How much does it cost to thin MCMC?

Thinning MCMC chains incurs no direct monetary cost, but it reduces storage and memory usage by discarding intermediate samples.

By default, thin = 1 keeps every sample. Set thin = 10, and you’re only storing every 10th iteration—saving about 90% of disk space. Modern methods like Hamiltonian Monte Carlo (HMC) often make thinning unnecessary because they produce less autocorrelated samples. Only thin when you’re tight on storage or need to downsample for plots.

Does MCMC always converge?

No, MCMC does not guarantee convergence—finite chains may never fully reach the target posterior distribution.

Convergence depends on your model’s complexity, the sampler you’re using, and how well you’ve tuned it. Mess up the warmup or specify a bad model, and you’ll get biased or unreliable samples. Always check Rhat, ESS, and traceplots. If things look off, try reparameterizing, adding more warmup steps, or switching to a robust sampler like NUTS.

What is a divergent transition?

A divergent transition occurs when an MCMC sampler fails to explore a region of the posterior due to numerical instability or model misspecification.

In Stan, you’ll see these as "max treedepth exceeded" errors or high energy warnings. Even a few divergences can skew your posterior estimates, especially in tricky regions. Dive into the problematic parameter’s geometry or reparameterize the model. Don’t ignore divergences—they’re a red flag.

How do you interpret an effective sample size?

Effective sample size (ESS) quantifies the number of independent samples that would provide the same precision as your correlated MCMC draws.

It’s calculated as n / (1 + 2 × sum(autocorrelations)). ESS below 100? That’s trouble—high autocorrelation means your estimates aren’t reliable. Stan gives you n_eff and n_eff_sampling, with the latter focusing on bulk ESS. Always pair ESS with Rhat to judge sampling quality. Aim for ESS > 400 per chain.

What is convergence MCMC?

Convergence in MCMC means that the generated Markov chain has reached a stationary distribution matching the target posterior.

At convergence, the chain forgets its starting point and explores the posterior consistently. Check Rhat, ESS, traceplots, and rank histograms to confirm. But remember: convergence ≠ accuracy. It just means you’re sampling from the right distribution. Never skip diagnostics before drawing inferences.

What is the Gelman Rubin statistic?

The Gelman–Rubin statistic is a ratio of between-chain variance to within-chain variance, used to assess MCMC convergence.

It’s computed as sqrt((n-1)/n + (m+1)/m × (B/W)), where B is between-chain variance and W is within-chain variance. Values near 1.0 mean you’re good. Above 1.1? Time to tweak your sampler. The statistic is unit-free, so you can compare it across models and parameters.

What is potential scale reduction factor?

The potential scale reduction factor (PSRF) estimates how much the posterior scale might shrink with infinite sampling.

As iterations increase, PSRF approaches 1.0. A PSRF of 1.05 suggests the posterior scale could shrink by ~5% with more samples. It’s tightly linked to Rhat and is a core part of Gelman–Rubin diagnostics. You’ll see it in Stan’s convergence summary.

What is burn in period in MCMC?

The burn-in period refers to the initial iterations discarded during MCMC to allow chains to reach the stationary distribution.

During burn-in, chains move from random starting points toward the posterior. Typical burn-in lengths range from 100 to 1000 iterations, depending on how complex your model is. Modern samplers like NUTS often need less burn-in. Always check traceplots to confirm chains have stabilized before keeping samples.

What is Bayesian convergence?

Bayesian convergence refers to the weak convergence of the posterior distribution to the true parameter as sample size increases.

This is backed by asymptotic theorems like the law of large numbers. In practice, you’ll rely on diagnostics like Rhat, ESS, and visual checks. Convergence ensures your credible intervals and posterior means are trustworthy. Never assume convergence without checking the numbers.

What does autocorrelation plot tell us?

An autocorrelation plot reveals the degree of correlation between MCMC samples at different lags, indicating sampling efficiency.

High autocorrelation at early lags means your chains are exploring slowly. For well-mixed chains, autocorrelation should drop as lag increases. Tools like ArviZ and coda generate these plots. If autocorrelation stays high, try thinning, reparameterizing, or increasing warmup steps.

What is autocorrelation MCMC?

Autocorrelation in MCMC refers to the correlation between successive samples, which reduces the effective sample size and slows convergence.

It happens because MCMC samples aren’t independent—they’re serially dependent. Gibbs sampling and Metropolis–Hastings both produce autocorrelated draws. Reduce it by tuning step size or switching to advanced samplers like NUTS. Always compute ESS to see how autocorrelation affects your inference.

Edited and fact-checked by the TechFactsHub editorial team.
David Okonkwo

David Okonkwo holds a PhD in Computer Science and has been reviewing tech products and research tools for over 8 years. He's the person his entire department calls when their software breaks, and he's surprisingly okay with that.