Why Autocorrelation Matters
Posterior simulation produces a sequence of draws, not a collection of independent observations. In an MCMC chain, nearby draws are often similar because each new state is generated using the current state. Consequently, 2,000 saved draws may contain less information about a posterior quantity than 2,000 independent draws would. The relevant question is not just how many values were saved, but how strongly they depend on one another.
This tutorial connects that dependence to Monte Carlo precision and examines thinning, the practice of retaining only selected iterations. Thinning can make a file smaller, but it does not make the underlying chain explore the posterior better. Whether it helps a particular analysis depends on what is being optimized: storage, computation after sampling, or precision per MCMC transition.
Lag Autocorrelation and Effective Sample Size
Let \(\theta_1,\ldots,\theta_n\) be post-warmup draws from a stationary chain, and let \(g(\theta)\) be a scalar posterior quantity of interest, such as a treatment-effect parameter or a function of several parameters. Write \(Y_t=g(\theta_t)\). The lag-\(k\) autocorrelation describes the linear dependence between values \(k\) iterations apart.
The effective sample size (ESS) is an interpretation of precision, not a literal count of independent draws hidden inside the chain. If \(\tau=4\), for example, \(n\) correlated draws provide roughly the same precision for estimating the mean of \(g(\theta)\) as \(n/4\) independent draws with the same marginal variance. ESS is specific to the quantity being estimated: different parameters or functions \(g\) can have very different autocorrelation patterns.
The variance approximation relies on a chain that has reached its stationary target, has finite variance for \(g(\theta)\), and has dependence that weakens sufficiently for a central limit approximation to apply. It is not a correction for a chain that has failed to explore the target distribution. In practice, \(\rho_k\) and \(\tau\) must be estimated from a finite run, so ESS and Monte Carlo standard errors are themselves uncertain.
How the Variance Formula Arises
A short derivation explains why positive autocorrelation reduces precision. Suppose \(Y_t\) is stationary with mean \(\mu_g\) and autocovariance \(\gamma_k=\operatorname{Cov}(Y_t,Y_{t+k})=\sigma_g^2\rho_k\). The sample mean is \(\bar{Y}=n^{-1}\sum_{t=1}^{n}Y_t\). Expanding its variance and grouping pairs of observations by their lag gives
If the autocorrelations are summable and \(n\) is large, the factor \(1-k/n\) is close to 1 for lags that materially contribute to the sum, yielding \(\operatorname{Var}(\bar{Y})\approx \sigma_g^2\tau/n\). For independent draws, every \(\rho_k=0\) for \(k>0\), so \(\tau=1\) and the usual independent-draw variance is recovered. With positive dependence, \(\tau\) is generally greater than 1, reducing the effective sample size.
This is an asymptotic justification, not a license to sum noisy estimated autocorrelations across every available lag. At large lags, estimates are unstable. Practical estimators use truncation or smoothing rules; reported ESS and Monte Carlo standard errors should therefore be treated as diagnostics with finite-run uncertainty, rather than exact properties of the chain.
Worked Example: Autocorrelation and Precision in an AR(1) Chain
Suppose a hypothetical post-warmup chain of 2,000 draws has values \(Y_t\) following a stationary first-order autoregressive pattern with lag-one autocorrelation \(0.60\). For this model, \(\rho_k=0.60^k\). Assume the sample standard deviation of \(Y_t\) is \(0.12\) log-odds units. Calculate the approximate ESS and Monte Carlo standard error for the posterior mean of \(Y_t\).
Because the autocorrelations form a geometric series,
Thus \(n_{\mathrm{eff}}=2{,}000/4=500\). The approximate Monte Carlo standard error is
For comparison, 2,000 independent draws with the same standard deviation would have Monte Carlo standard error \(0.12/\sqrt{2{,}000}=0.002683\) log-odds units. The chain's 2,000 correlated draws therefore provide approximately the precision of 500 independent draws for this mean. This calculation assumes the AR(1) autocorrelation pattern and stationarity stated in the example; an estimated lag-one correlation alone would not generally determine all higher-lag correlations.
What Thinning Changes
Thinning by an integer \(m\) means retaining every \(m\)th post-warmup draw, for example iterations \(m,2m,3m,\ldots\). If the original chain has lag autocorrelation \(\rho_k\), the thinned sequence has lag-\(j\) autocorrelation \(\rho_{jm}\). Thinning therefore reduces both the number of retained draws and the dependence between adjacent retained values. Its effect on precision must account for both changes, not just the reduced autocorrelation.
Worked Example: Thinning Every Third Draw
Consider a hypothetical stationary AR(1) chain with 4,000 post-warmup draws and lag-one autocorrelation \(0.60\). Suppose the sample standard deviation of the posterior quantity is \(0.20\) log-odds units. Compare using all draws with retaining iterations 3, 6, and so on through 3,999.
For the full chain, the AR(1) result gives \(\tau=4\), so the ESS is \(4{,}000/4=1{,}000\). Its Monte Carlo standard error is approximately \(0.20/\sqrt{1{,}000}=0.006325\) log-odds units.
The stated thinning scheme retains \(3{,}999/3=1{,}333\) draws. The lag-one autocorrelation of this retained sequence is the original lag-three autocorrelation, \(0.60^3=0.216\). Its successive autocorrelations are \(0.216^j\), so
The thinned sequence therefore has
Thinning reduced dependence between neighboring retained draws, but the effective sample size fell from 1,000 to 859.4 because 2,667 draws were discarded. The estimated Monte Carlo standard error increased. The comparison uses the same underlying 4,000 transitions; it does not suggest that the thinned chain is less correlated per retained draw, only that it contains less information overall for this estimate.
When the Autocorrelation Is Negative
Autocorrelation need not be positive. Some samplers or parameterizations produce alternating values, and then negative lag correlations can make the sample mean more precise than an independent-draw calculation would suggest. In that case \(\tau\) can be below 1, and the corresponding asymptotic ESS can exceed the number of draws. This does not mean there are literally more draws; it means the dependence reduces the variance of the mean relative to independent draws with the same marginal variance.
Worked Example: Thinning an Alternating Chain
For illustration, suppose a hypothetical stationary AR(1) chain has 1,200 post-warmup draws and lag-one autocorrelation \(-0.40\), with standard deviation \(0.10\) units for the posterior quantity. Its autocorrelations are \((-0.40)^k\). Compare the full chain with retaining every second draw.
For the full chain,
The corresponding Monte Carlo standard error is \(0.10/\sqrt{2{,}800}=0.001890\) units. When every second draw is retained, the new lag-one autocorrelation is \((-0.40)^2=0.16\), and
The thinned sequence's approximate Monte Carlo standard error is \(0.10/\sqrt{434.5}=0.004797\) units. Keeping every draw preserves the beneficial alternation; thinning removes it. This idealized AR(1) calculation illustrates why thinning should not be justified merely by saying that retained values are less autocorrelated.
Diagnostics, Alternatives, and Limitations
For a real analysis, inspect autocorrelation and ESS for the posterior quantities that matter to the scientific conclusion, not just for one convenient parameter. A slow-moving treatment effect, a variance parameter, and a clinically relevant function of parameters can have different dependence patterns. Compare chains and use the trace plots and rank-normalized \(\hat{R}\) diagnostics discussed in earlier material as complementary checks. A reassuring autocorrelation estimate or large ESS does not prove that the chain has reached or adequately explored the intended posterior.
Common warning signs include autocorrelations that remain large across many lags, substantial changes in estimated ESS as the run length increases, and Monte Carlo standard errors too large for the precision needed in the analysis. Estimated autocorrelations can also be noisy, especially near the end of a finite sequence. If estimates look erratic at high lags, that is not evidence that the chain has become independent at a particular cutoff; it may simply reflect estimation noise.
The usual alternative to thinning is to retain the full post-warmup sequence and improve precision by running longer or by improving the sampler or parameterization. For a fixed amount of MCMC computation, keeping all draws usually preserves more information for estimating posterior expectations. Thinning can nevertheless be reasonable when storage is genuinely constrained or when saving and processing every draw is costly. In such cases, choose the interval based on the practical constraint, and check the resulting ESS and Monte Carlo standard error rather than assuming a particular interval is statistically optimal.
Thinning is not a remedy for poor exploration. If distinct parts of the posterior are not visited, keeping fewer draws cannot recover what was missed. Nor does thinning make a biased or nonstationary sequence valid. Finally, ESS for a posterior mean does not automatically describe precision for every other summary; the dependence structure relevant to a different function may differ.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A stationary chain has 900 draws and integrated autocorrelation time \(\tau=3\). What is its approximate ESS?
- For an AR(1) chain with lag-one autocorrelation \(0.5\), calculate \(\tau\).
- Why can a thinned chain have lower lag-one autocorrelation but a lower ESS than the full chain?
- Can an asymptotic ESS exceed the number of draws? Explain what that means.
- Name one practical reason to thin and one claim thinning does not justify.
Solutions. (1) \(n_{\mathrm{eff}}=900/3=300\). (2) \(\tau=(1+0.5)/(1-0.5)=3\). (3) Thinning reduces dependence among retained draws but also discards observations; the loss in count can outweigh the reduced dependence, so the resulting ESS can be smaller. (4) Yes. Negative autocorrelation can reduce the variance of the sample mean below the independent-draw variance, so the asymptotic ESS can exceed \(n\); it is a precision comparison, not a literal number of independent values. (5) Storage limits can motivate thinning. Thinning does not justify claiming that a chain has converged or explored all relevant regions of its target distribution.