MCMC convergence: why Heidelberg's test says normal samples are non-stationary? I am learning about and playing with Heidelberg's convergence test to automatically stop a MCMC sampling.  
I would have said that if I sample, for instance, from a normal distribution, the test should pass. However, it seems that the second part of the test does not pass. 
library(coda)
heidel.diag(mcmc(rnorm(1000000)), eps=0.1, pvalue=0.05) # default parameters

 Stationarity start     p-value
 test         iteration        

var1 passed       1         0.89   

 Halfwidth Mean      Halfwidth
 test                         
var1 failed    -0.000909 0.00196  

What is going on here? 
 A: rnorm(1000000) is equivalent to rnorm(1000000, mean = 0, sd = 1)
You are thus generating 1000000 random values following a Gaussian distribution with mean 0 and variance 1. Using  mcmc() then merely transform the class of your object from numeric to mcmc, but does not change the values : the default values are mcmc(data= NA, start = 1, end = numeric(0), thin = 1) so by using them you sample your vector starting from the first value (start = 1) and up to the last value (end = numeric(0)), by taking every value (thin = 1).
Your succession of random values is expected to be stationary since this is an expected feature of random sampling of independent values from a distribution. That's why the stationarity test is successful, without the need to remove any values at the beginning (2nd column start iteration has value 1).
The halfwidth test is however not testing stationarity but rather the precision of your estimate, a bit like a coefficient of variation. It passes if the ratio between the halfwidth of the 95% confidence interval for the mean of the posterior distribution over this mean is lower than the eps argument (here 0.1).
As you sample from a distribution with mean 0, the mean of the posterior distribution is approx. equal to zero (here -0.000909). However narrow your confidence interval might be, and thus however small the halfwidth (a positive value), dividing it by 0, or an estimate of 0, is quite meaningless.
Conclusion: As with the coefficient of variation, the halfwidth test is only useful for estimates that are expected to differ from zero.
Try the same approach for normal distributions with different means to see the difference.
