Menu

Stopping autorun.jags from extending run using Raftery and Lewis diagnostic

runjags
2015-08-13
2015-11-10
  • Jonathan Bartlett

    Firstly, thanks Matthew for creating such a useful and great package.

    I've been exploring using autorun.jags in a simulation study. One thing I'd like to try is for autorun.jags to run long enough for Gelman's Rhat to be below the threshold (and I've figured out how to set this), but not to then bother running further, i.e. using the Raftery and Lewis diagnostics to ensure accurate centiles. I have tried passing raftery.options=list(r=1), so that the required margin of error is large, which I think does the trick, but I wondered if there was a more definitive way of turning off this second stage of the automatic running in autorun.jags.

    Many thanks!
    Jonathan

     
  • Matt Denwood

    Matt Denwood - 2015-08-14

    Hi Jonathan

    Glad to hear you find the package useful! I had not thought to do this before, so there is currently no better way than what you describe to prevent the final chain extension being done. But it would definitely be something I could add to the development version. I will have a think about it and let you know - thanks for the suggestion!

    Best wishes,

    Matt

     
  • Matt Denwood

    Matt Denwood - 2015-09-16

    Just to confirm that as of runjags version 2.0.2 the raftery.options argument accepts a FALSE value which definitevely turns off chain extension for sample size.

    Thanks for the suggestion :)

    Matt

     
    • Ming Yang

      Ming Yang - 2015-11-07

      Hi Matt,

      Could you specify how to put the argument? I tried raftery.options = FALSE but it requires a named list, but I don't know which name for that argument should be.

      Thanks,
      Ming

       
  • Matt Denwood

    Matt Denwood - 2015-11-08

    The following works in runjags version 2.0.3:

        library('runjags')
        N <- 100
        X <- 1:N
        Y <- rnorm(N, 2*X + 10, 1)
    
        model <- "model {
        for(i in 1 : N){
            Y[i] ~ dnorm(true.y[i], precision)
            true.y[i] <- m * X[i] + c
        }
        m ~ dunif(-1000,1000)
        c ~ dunif(-1000,1000)
        precision ~ dexp(1)
        #monitor# m, c, precision
        #data# N, X, Y
        }"
    
        results <- autorun.jags(model=model, raftery.options=FALSE)
    

    This should also work in version 2.0.2 (currently on CRAN) as documented. Can you confirm the error you get, and the version of runjags you are trying this with?

    Matt

     
    • Ming Yang

      Ming Yang - 2015-11-09

      Thanks for your reply. I tried to installed version 2.0.2 but it still gives me the error:
      Error in autoextend.jags(runjags.object = obj, add.monitor = character(0), :
      Options to raftery.diag must be provided as a named list

      Ming

       
  • Matt Denwood

    Matt Denwood - 2015-11-10

    Again, I can confirm that the following does work on my system:

    library('runjags')
    N <- 100
    X <- 1:N
    Y <- rnorm(N, 2*X + 10, 1)
    
    model <- "model {
    for(i in 1 : N){
        Y[i] ~ dnorm(true.y[i], precision)
        true.y[i] <- m * X[i] + c
    }
    m ~ dunif(-1000,1000)
    c ~ dunif(-1000,1000)
    precision ~ dexp(1)
    #monitor# m, c, precision
    #data# N, X, Y
    }"
    
    results1 <- autorun.jags(model=model, raftery.options=FALSE)
    
    results2 <- run.jags(model=model, sample=1000)
    r2extended <- autoextend.jags(results2, raftery.options=FALSE)
    

    Whatever you are passing to raftery.options must be evaluated as !identical(raftery.options, FALSE) but I have no idea why this might be the case. I can't reproduce your error without more details of your system and the function call you are using.

    Also make sure to run the following to ensure that you have a recent enough package version:

    stopifnot(packageVersion('runjags')>='2.0.2')
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.