jags.parallel - Error in get(name, envir = envir) : invalid first argument

后端 未结 1 1996
既然无缘
既然无缘 2020-12-19 11:39

When using jags.parallel, I get the following error:

> out <- jags.parallel(win.data, inits, params, \"Poisson.OD.t.test.txt\",
+ nc, ni,          


        
相关标签:
1条回答
  • 2020-12-19 12:12

    Jags/R had practically two problems with this line:

    out <- jags.parallel(win.data, inits, params, "Poisson.OD.t.test.txt",
        nc, ni, nb, nt);
    

    Both are related to evaluation of function parameters - he is probably not able to resolve parameters which refer to other R variables:

    1) The win.data was encoded as variable names as usually for WinBUGS/Jags:

    win.data <- list(C.OD = C.OD, x = as.numeric(x)-1, n = length(x))`
    

    but jags.parallel issues the error "Error in get(name, envir = envir) : invalid first argument". He wants the data in this format:

    windata <- list("C.OD", "x", "n")
    

    Why? Don't ask me... I discovered this when reading the example of ?jags.

    2) The arguments nc, ni, nb, nt in function call are a problem! If I put constants, it is OK, but references to variables are unacceptable for him. Don't ask me why. Remedy found at strange jags.parallel error / avoiding lazy evaluation in function call.

    The complete fix looks like:

    out <- do.call(jags.parallel, list(names(win.data), inits, params, "Poisson.OD.t.test.txt",
        nc, ni, nb, nt));
    
    0 讨论(0)
提交回复
热议问题