[R-sig-ME] MCMCglmm for binomial models? -- updated to use rcppbugs
Whit Armstrong
armstrong.whit at gmail.com
Tue May 1 03:36:54 CEST 2012
Paul,
Quick reply: rcppbugs is a new package that attempts to provide a pure
R alternative to using OpenBUGS/WinBUGS/JAGS for MCMC.
The core of the package is c++, but the model specification is in R
(hence my previous post saying no c++ required).
The first versions of the software shipped as pure c++, so one needed
to write a c++ model and use Rcpp and inline to call the model. This
version still ships standalone and can be found here:
https://github.com/armstrtw/CppBugs
The R api for cppbugs is rcppbugs, and the project page is here:
https://github.com/armstrtw/rcppbugs
I'll reply to the other questions in line, but let me post an example
of a linear model so everyone can get the flavor of the package:
## assuming your data is in matrix X and vector y, and NC is the
number of columns of X
library(rcppbugs)
b <- mcmc.normal(rnorm(NC),mu=0,tau=0.0001)
tau.y <- mcmc.gamma(runif(1),alpha=0.1,beta=0.1)
y.hat <- linear(X,b)
y.lik <- mcmc.normal(y,mu=y.hat,tau=tau.y,observed=TRUE)
m <- create.model(b, tau.y, y.hat, y.lik)
## then to run the model:
cat("running model...\n")
ans <- run.model(m, iterations=1e5L, burn=1e4L, adapt=1e3L, thin=10L)
## and view the 'trace' of b
print(ans[["b"]])
> I don't have the thread going back to the ancient times (:)), so I
> can't tell what the point of this might be. I wonder "what the hell
You're cracking me up. The original post was by Bob Farmer
investigating why his MCMCglmm results were not converging to his
WinBUGS model.
That was about the time that I produced a stable api for the pure c++
version of my code, so I posted the c++ model as an example. It was
about 25x faster than JAGs.
Now that I've released the R version of cppbugs, I re-posted the model
in rcppbugs form.
> I tried to install rcppbugs on Debian, but ended in failure, so
> obviously I'm missing some devel headers*.
Looks like you just need the boost headers, which ship with debian, so
you should be good to go after that.
> While I track back to find
> out WTF on that, how about you post an explanation of why rcppbugs is
> worth the effort in the first place?
I posted some crude benchmarks over on the Rcpp list. Happy to post
them here as well (or off list if you want).
Very roughly, for the linear model above, rcppbugs is between 3x and
5x faster vs MCMCpack, and between 50x and 75x faster than JAGS.
-Whit
More information about the R-sig-mixed-models
mailing list