Jags in Parallel

Kris Voss
  • Kris Voss

    Kris Voss - 2012-12-05


    I'm running jags through R. I'm trying to run in parallel. I have two quad core processors. The code runs fine when I use the jags(...) function but when I try jags.parallel(...) using the same ... inputs, I get the following error:

    THIS WORKS FINE (Right now I'm just making sure I can get it to run that's why n.iter is low):
    model1.sim <- jags.parallel(spp.data,model1.inits,parameters,model.file =

    model1.sim.par <- jags.parallel(spp.data,model1.inits,parameters,model.file = model.file,n.chains=3,n.iter=100)
    Error in get(name, envir = envir) : invalid first argument

    Any ideas on how to fix this?

  • Martyn Plummer

    Martyn Plummer - 2012-12-13

    I don't know. Ask the maintainer of the R2jags package.

  • Daniel Hocking

    Daniel Hocking - 2013-01-15

    Kris - Did you ever find an answer? I'm having the same problem.

  • Josh

    Josh - 2013-01-15

    I tend to get that error when creating data while creating the data object, using an object that is not included in the jags data object to initialize or a function that is not part of a library that is not in my base R.

    For example, this does not work, quotes or not
    jags.data <- list("y" = dat$y, "n" = nrow(dat))

    This does work
    y <- dat$y
    n <- nrow(dat)
    jags.data <- list("y", "n")

    Now inits, this does not work because J is not passed in data, notice the added package for access to a function
    inits <- function(){
    list(x = rnorm(1), x2 = rmvnorm(1, J))

    This would work though
    jags.data <- list("y", "n", "J") # J is not part of the model, but jags gracefully passes over that fact
    inits <- function(){
    list(x = rnorm(1), x2 = rmvnorm(1, J))

    Hopefully my wild guess will help out. I don't think it works to pass an object for any of the control parameters either, so no nthin, nb, nc type syntax.

    It can be helpful to run a simple model (lm or even a function like mean) using snowfall directly to understand how this wrapper works.


  • Josh

    Josh - 2013-01-15

    Duplicate post

    Last edit: Josh 2013-01-15

Log in to post a comment.