# A slice of infinity

**Xi'an's Og » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**P**eng Yu sent me an email about the conditions for convergence of a Gibbs sampler:

The following statement mentions convergence. But I’m not familiar what the regularity condition is.

“But it is necessary to have a finite probability of moving away from the current state at all times in order to satisfy the regularity conditions on which the whole MCMC theory depends.”

Slice sampler is discussed in your book

. I think that the “regularity condition” may have been discussed in your book. If so, would you please let me know where it is? Thanks and look forward to hearing from you!Monte Carlo Statistical Methods

**T**he quote is from Martyn Plummer and deals with a stopping rule in ** JAGS** implementation of the slice sampler. (The correct wording should be “strictly positive probability” rather than “finite probability”, I think.) However, this has nothing to do with a “regularity condition” on the irreducibility of a Markov chain: if a slice sampler is implemented for an unbounded density target, say a

*Beta(1/2,1/2)*, there is no irreducibility condition connected with the infiniteness of the density. In theory, (a) the chain never visits the “state” where the density is infinite (if only because we are dealing with a continuous state space) and (b) after visiting a value

*x*with a large density

*f(x)*, the slice sampler allows for a move away from it since the slice involves a uniform simulation over

*(0,f(x))*. In practice, the problem is caused by values of

*f(x)*that cannot be computed and hence produce an error message like

Singularity in likelihood found by Slicer.

If those singularities can be localised, a neighbourhood excluding them should be introduced. (More easily said than done, obviously!)

Here is an example of a slice sampler with the *Beta(1/2,1/2)* distribution:

#graphics dote=function(x,y) points(x,y,col="gold",pch=19,cex=.4) mote=function(x,y,z,w) lines(c(x,z),c(y,w),col="gold",lwd=.5) cst=dbeta(.5,.5,.5)*.5 #normalising constant #inverting f(x)=d, 2nd degree equation hitden=function(d) .5+.5*sqrt(1-4*( cst/ max(d,dbeta(.5,.5,.5)))^2)*c(-1,1) #output curve(dbeta(x,.5,.5),0,1,ylab="density",lwd=2,col="steelblue",n=1001) x=runif(1);u=runif(1)*dbeta(x,.5,.5);dote(x,u) for (t in 1:100){ #100 slice steps bo=hitden(u) nx=sample(c(runif(1,0,bo[1]),runif(1,bo[2],1)),1) nu=runif(1)*dbeta(nx,.5,.5) mote(x,u,nx,nu) x=nx;u=nu;dote(x,u) }

which clearly explores the whole area under the *Beta(1/2,1/2)* density. Even when started at a large density value like *f(.999999)*, it eventually leaves the vicinity of this highly improbable value.

Filed under: R, Statistics, University life Tagged: beta distribution, convergence, Gibbs sampling, JAGS, R, slice sampling

**leave a comment**for the author, please follow the link and comment on their blog:

**Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.