Autocorrelation

An ideal sample from a distribution, including the posterior, should have autocorrelation equal to zero (unless we expect a correlation like in time-series). A sample is autocorrelated when a value at a given iteration is not independent of the sampled values at other iterations. In practice, samples generated from MCMC methods will be autocorrelated, especially Metropolis-Hastings, and to a lesser extent NUTS and SMC. ArviZ comes with a convenient function to plot the autocorrelation:

az.plot_autocorr(trace_cm, var_names=['a'])

Figure 8.11

 az.plot_autocorr shows the average correlation of sample values compared to successive points (up to 100 points). Ideally, we should see no autocorrelation. In practice, we want samples that quickly drop to low values of autocorrelation. Let's also plot the autocorrelation for the non-centered model:

az.plot_autocorr(trace_ncm, var_names=['a'])

Figure 8.12

By comparing Figures 8.11 and 8.12, we can easily see that the samples from the non-centered model has almost no autocorrelation while the samples from the centered model show larger values of autocorrelation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.9.237