heidelberger:welch:83 devised a method for detecting an initial transient in simulated sequences of discrete events, but which is also appropriate for use as a convergence diagnostic for the output of Gibbs samplers. Their idea is based on Brownian bridge theory and uses the Cramer-von-Mises statistic to test the null hypothesis that the sampled values for each variable form a stationary process. If the null hypothesis is rejected for a given variable, the test is repeated after discarding the first 10% of iterations. If the hypothesis is again rejected, a further 10% of iterations are discarded. This process is repeated until either a portion of the chain (of length
of the total number of iterations) passes the stationarity test, or 50% of the iterations have been discarded and the null hypothesis is still rejected. If the latter occurs, CODA reports the Cramer-von-Mises statistic and indicates that the stationarity test was failed. Missing values (NA) are shown in all other columns of the output table for that variable. This indicates that a longer BUGS run is needed in order to achieve convergence.
If the stationarity test is passed, CODA reports the number of iterations to keep (i.e. which are diagnosed to arise from a stationary process), the number of initial iterations to discard and the Cramer-von-Mises statistic. A halfwidth test is then carried out as follows: for each variable, the portion of the chain which passed the stationarity test is used to estimate the asymptotic standard error of the mean via the time-series method described in §3.2. CODA reports the sample mean of the retained iterates and the halfwidth of the associated 95% confidence interval for this mean (i.e.
asymptotic standard error). If the halfwidth is less than
times the sample mean (where
is a small fraction), the halfwidth test is passed and the retained sample is deemed to estimate the posterior mean with acceptable precision. If the halfwidth test is failed, this implies that a longer BUGS run is needed to increase the accuracy of the posterior estimates for the given variable. The CODA default for
is 0.1; see §5.7.4 for details of how change this value.
Selecting Heidelberger and Welch (option 4:) from the CODA Diagnostics Menu produces the output shown on the next page for the line example.
This suggests that convergence was achieved immediately for the second BUGS run (line2), and after 20 iterations for the first run (line1) for each variable. The halfwidth test indicates that iterations 21-200 from line1 or all 200 iterations from line2 (or a combined sample of all these iterations) should yield estimates of the posterior means for alpha and beta which meet the CODA default accuracy criterion of
. However, whilst the posterior sample for sigma from line1 passes the halfwidth test, the 200 samples from line2 do not provide a sufficiently precise estimate of sigma. Running this chain for longer should help to increase the precision.
HEIDELBERGER AND WELCH STATIONARITY AND INTERVAL HALFWIDTH TESTS: =================================================================
Iterations used = 1:200 Thinning interval = 1 Sample size per chain = 200
Precision of halfwidth test = 0.1
Chain: line1 ============
-+----------+----------------------------------------------------+- | | Stationarity # of iters. # of iters. C-vonM | | VARIABLE | test to keep to discard stat. | | ======== | ============ =========== =========== ====== | | | | | alpha | passed 180 20 0.177 | | beta | passed 180 20 0.243 | | sigma | passed 180 20 0.205 | -+----------+----------------------------------------------------+- -+----------+---------------------------------+- | | Halfwidth | | VARIABLE | test Mean Halfwidth | | ======== | ========= ==== ========= | | | | | alpha | passed 2.950 0.0600 | | beta | passed 0.798 0.0366 | | sigma | passed 0.868 0.0854 | -+----------+---------------------------------+-
Chain: line2 ============
-+----------+----------------------------------------------------+- | | Stationarity # of iters. # of iters. C-vonM | | VARIABLE | test to keep to discard stat. | | ======== | ============ =========== =========== ====== | | | | | alpha | passed 200 0 0.0698 | | beta | passed 200 0 0.1200 | | sigma | passed 200 0 0.0550 | -+----------+----------------------------------------------------+- -+----------+---------------------------------+- | | Halfwidth | | VARIABLE | test Mean Halfwidth | | ======== | ========= ==== ========= | | | | | alpha | passed 2.990 0.0544 | | beta | passed 0.812 0.0521 | | sigma | failed 0.982 0.1070 | -+----------+---------------------------------+-