Posterior summaries are valid only after the chains have reached their stationary distribution and are long enough. Crossa et al. (2011) used three diagnostics: Raftery and Lewis (1995), Heidelberger and Welch (1983) and Gelman and Rubin (1992). bayes_ammi() computes all three, together with effective sample sizes, through the package coda.
The first chain starts at the least-squares fit and the others at dispersed values (singular values scaled by factors between 0.5 and 1.5, perturbed scores, error variance scaled between 0.5 and 2).
3 Traces
plot(x = fit, which ="trace", pars =c("mu", "sigma2", "lambda[1]", "lambda[2]", "alpha[8,1]"))
4 Gelman-Rubin
The potential scale reduction factor compares the variance between chains with the variance within them. Values below 1.1 (better, 1.01) indicate that the chains have mixed.
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.9999 1.0000 1.0002 1.0002 1.0004 1.0014
5 Raftery-Lewis
The dependence factor \(I\) measures how much longer the chain must be than an independent sample of the same precision; \(I > 5\) indicates strong autocorrelation.
The stationarity test is applied to the whole chain, then after dropping the first 10%, 20%, … of it. The half-width test asks whether the mean is estimated precisely enough. Each test has level 0.05, so among many parameters a few failures are expected by chance.
The Monte Carlo standard error mc_se is \(\mathrm{sd}/\sqrt{\mathrm{ess}}\). Run longer chains when it is not small compared with the precision you need. The weak second singular value mixes more slowly than the other parameters.
8 The draws for further analysis
fit$draws is a coda::mcmc.list, so every function of coda applies:
lambda[1] lambda[2]
Lag 1 0.08931897 0.7099201
Lag 5 0.02070703 0.3129273
Lag 10 0.01404242 0.1274023
9 posterior and bayesplot
The draws also convert to a draws_df of posterior, which gives the rank-normalised \(\widehat{R}\) and the bulk and tail effective sample sizes of Vehtari et al. (2021), and the plots of bayesplot take the mcmc.list directly (Gabry et al. 2019):
bayesplot::mcmc_rank_overlay(x = fit$draws, pars =c("lambda[1]", "lambda[2]"))
Rank plots are flat and overlapping when the chains mix well.
10 Interpretation of convergence
bam_interpret(x = fit , higher_better =TRUE , top =5 )$findings[1:2]
[1] "The chains have converged by the criteria of Crossa et al. (2011) (largest potential scale reduction factor 1.001); the smallest effective sample size of the main parameters is 1,400."
[2] "6 of 198 Heidelberger-Welch stationarity and half-width tests failed (about 5% fail by chance at level 0.05)."
11 References
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
Gelman, A. and Rubin, D. B. (1992). Inference from iterative simulation using multiple sequences. Statistical Science, 7(4), 457–472.
Raftery, A. E. and Lewis, S. M. (1995). The number of iterations, convergence diagnostics and generic Metropolis algorithms. In W. R. Gilks, D. J. Spiegelhalter and S. Richardson (eds), Practical Markov Chain Monte Carlo. Chapman and Hall, London.
Heidelberger, P. and Welch, P. D. (1983). Simulation run length control in the presence of an initial transient. Operations Research, 31(6), 1109–1144.
Plummer, M., Best, N., Cowles, K. and Vines, K. (2006). CODA: convergence diagnosis and output analysis for MCMC. R News, 6(1), 7–11.
Vehtari, A., Gelman, A., Simpson, D., Carpenter, B. and Burkner, P.-C. (2021). Rank-normalization, folding, and localization: an improved R-hat for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667–718.
Gabry, J., Simpson, D., Vehtari, A., Betancourt, M. and Gelman, A. (2019). Visualization in Bayesian workflow. Journal of the Royal Statistical Society A, 182(2), 389–402.