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

故事扮演 提交于 2019-11-29 10:57:15
TMS

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));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!