S4 classes around infrastructure provided by the dclone package to make package development with data cloning for hierarchical models easy as a breeze.
Sequential and parallel MCMC support for JAGS, WinBUGS, OpenBUGS, and Stan. See Solymos 2010 (R Journal 2(2):29--37).
Install the CRAN version of the package from R:
install.packages("dcmle")
Install the development version of the package from R using the
devtools
package:
devtools::install_github("datacloning/dcmle")
User visible changes in the package are listed in the NEWS file.
State space model:
## Data and model taken from Ponciano et al. 2009
## Ecology 90, 356-362.
paurelia <- c(17,29,39,63,185,258,267,392,510,
570,650,560,575,650,550,480,520,500)
paramecium <- new("dcFit")
paramecium@data <- list(
ncl=1,
n=length(paurelia),
Y=dcdim(data.matrix(paurelia)))
paramecium@model <- function() {
for (k in 1:ncl) {
for(i in 2:(n+1)){
Y[(i-1), k] ~ dpois(exp(X[i, k])) # observations
X[i, k] ~ dnorm(mu[i, k], 1 / sigma^2) # state
mu[i, k] <- X[(i-1), k] + log(lambda) - log(1 + beta * exp(X[(i-1), k]))
}
X[1, k] ~ dnorm(mu0, 1 / sigma^2) # state at t0
}
beta ~ dlnorm(-1, 1) # Priors on model parameters
sigma ~ dlnorm(0, 1)
tmp ~ dlnorm(0, 1)
lambda <- tmp + 1
mu0 <- log(2) + log(lambda) - log(1 + beta * 2)
}
paramecium@multiply <- "ncl"
paramecium@unchanged <- "n"
paramecium@params <- c("lambda","beta","sigma")
(m1 <- dcmle(paramecium, n.clones=1, n.iter=1000))
(m2 <- dcmle(paramecium, n.clones=2, n.iter=1000))
(m3 <- dcmle(paramecium, n.clones=1:3, n.iter=1000))
cl <- makePSOCKcluster(3)
(m4 <- dcmle(paramecium, n.clones=2, n.iter=1000, cl=cl))
(m5 <- dcmle(paramecium, n.clones=1:3, n.iter=1000, cl=cl))
(m6 <- dcmle(paramecium, n.clones=1:3, n.iter=1000, cl=cl,
partype="parchains"))
(m7 <- dcmle(paramecium, n.clones=1:3, n.iter=1000, cl=cl,
partype="both"))
stopCluster(cl)
Visit the dcexamples repository for classic BUGS examples using dcmle.
Find help on the Dclone users mailing list. More resources at datacloning.org.
Use the issue tracker to report a problem.
Solymos, P., 2010. dclone: Data Cloning in R. R Journal 2(2):29--37. [PDF]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.