我从JAGS收到以下错误:
Error in node Y[107]
Invalid parent values
从这些纯粹的信息中很难找出那里发生的事情。它是由这部分代码引起的:
pi[j,1] <- 1 - M[site[j]] * phi[j] * (1 - (1 - q[j])^6)
pi[j,2] <- M[site[j]] * phi[j] * (1 - q[j])^interval[j] * q[j]
pi[j,3] <- 1 - pi[j,1] - pi[j,2]
Y[j] ~ dcat(pi[j,])
打印出节点Y[107]
的父值,即节点pi[107,]
非常有用!这会给我非常明确的反馈,在哪里寻找错误!在JAGS中有这样的方式吗?
在JAGS手册的第3.2章中,JAGS谈到留下一些有用的jags.dumpN.R
文件:
如果模型正确编译并初始化,则会发生错误 在更新期间,然后将模型的当前状态转储到 一个名为jags.dumpN.R的文件,其中N是链号。那你应该 将转储的数据加载到R中以检查每个链的状态 发生了错误。
但是,我不确定这是否适用于我的情况。所以我试着获取转储文件。由于我使用runjags::run.jags()
来运行JAGS,我尝试在调试模式下运行它:
R> outRJ <- run.jags("tmp_bugs_model.txt", params, win.data, nc, inits,
nb, ni - nb, thin = 1, summarise=TRUE, plot=FALSE, adapt = adapt,
modules = "glm",
keep.jags.files = TRUE, method = "interruptible",
jags = "c:/Program Files/JAGS/JAGS-3.4.0/i386/bin/")
Running the simulation using the simple method... (output will be displayed once the
simulation has termianted)
Welcome to JAGS 3.4.0 on Thu Nov 27 10:33:49 2014
JAGS is free software and comes with ABSOLUTELY NO WARRANTY
Loading module: basemod: ok
Loading module: bugs: ok
. Loading module: glm: ok
. . Reading data file data.txt
. Compiling model graph
Resolving undeclared variables
Allocating nodes
Graph Size: 2451
WARNING: Unused variable(s) in data table:
desetiminutovka
. Reading parameter file inits1.txt
. Reading parameter file inits2.txt
. Reading parameter file inits3.txt
. Initializing model
Error in node Y[107]
Invalid parent values
Deleting model
. Updating 500
-------------------------------------------------| 500
Can't update. No model!
. Can't set monitor. No model!
. Can't set monitor. No model!
. Can't set monitor. No model!
. Can't set monitor. No model!
. Can't set monitor. No model!
. Can't set monitor. No model!
. Updating 500
-------------------------------------------------| 500
Can't update. No model!
. No model
. No model
. No model
. Can't dump CODA output. No model!
. Updating 0
Can't update. No model!
Can't update. No model!
. Deleting model
.
Error in runjags.readin(directory = startinfo$directory, copy = (keep.jags.files & :
The simulation appears to have crashed - check the model output in failedjags$output for clues
In addition: Warning messages:
1: running command '"TASKLIST"' had status 1
2: Parallel and interruptible methods aren't available on your machine because testing the TASKLIST system command produced an error; switching to the simple method
JAGS files were saved to the 'runjagsfiles_3' folder in your current working
directory
不幸的是,runjagsfiles_3
目录中没有包含任何有用信息的转储或文件。
有没有办法从JAGS中获取那些“无效的父值”?
我正在使用JAGS 3.4.0。
PS:我故意不在这里提交完整的型号代码。我的问题是关于JAGS的一般问题,而不是为什么我的模型不起作用。
答案 0 :(得分:2)
我担心无法从您的模型中转储任何值。您从JAGS手册中引用的关键行是&#39;并正确初始化&#39; - 你的模型没有发生这种情况,所以没有什么可以倾倒的,对不起。你必须手动为Y []的(随机)父母指定合理的初始值,如@nicola建议的那样。
顺便说一句 - 我对TASKLIST在您的系统上失败感兴趣 - 您能否告诉我您平台的一些细节?