# How autocorrelation affects ESS
# get a few Markov chains
x = matrix(NA, 500, 3) # sample size is 500
phi = c(0,.3,.9) # no, low, high
for (i in 1:3) x[,i] = sarima.sim(ar=phi[i])
apply(x, 2, ESS, digits=0)
Run the code above in your browser using DataLab