MCMC packages in R

Is there an R package for MCMC that can

• accept my self-defined (log)likelihood function (can be done in MCMCpack)

and

• lets the user define contraints to the proposals (like only accept values from the [0,1] interval, or take only positive values (possible in rSTAN)

I already definded my model in R code but obviously no MCMC package in R can handle constraints on the parameters like rstan and I don't want to recode it in rstan.

Update:

I found that the LaplacesDemon package is perfect for my needs, but the package is obviously abandoned :(

The t-walk package implementing the t-walk algorithm allows you to define the support for your (log)likelihood function, if that is what you are after.

Supp a function that takes a vector of length=dim and returns TRUE if the vector is within the support of the objective and FALSE otherwise. Supp is *always* called right before Obj. 

It also seems to be a pretty general sampling algorithm. From the package:

The t-walk is a "A General Purpose Sampling Algorithm for Continuous Distributions" to sample from many objective functions (specially suited for posterior distributions using non-standard models that would make the use of common algorithms and software difficult); it is an MCMC that does not required tuning.

R package here: www.cimat.mx/~jac/twalk/

• I just wanted to add that I've used the package and it has worked very well for me (but that was on pretty simple models). – Rasmus Bååth Sep 7 '14 at 15:26
• I took a look at the blog in your profile and read the post where you mentioned the LaplacesDemon package. It does indeed allow constraints on the parameters (unlike you said in your post, so this might be a new feature). So thank you for finding this great package. – spore234 Sep 7 '14 at 15:37

You should also check out Mamba, a new MCMC package, but its not in R, but rather julia:

https://github.com/brian-j-smith/Mamba.jl

it relies on the julia Distributions package which allows you to create your own distributions