3

我从 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 的一般性问题,而不是为什么我的模型不起作用。

4

1 回答 1

2

恐怕没有办法从您的模型中转储任何值。您从 JAGS 手册中引用的关键行是“并正确初始化”-您的模型没有发生这种情况,所以没有什么可以转储的,抱歉。正如@nicola 建议的那样,您将不得不手动为 Y[] 的(随机)父母指定合理的初始值。

顺便说一句 - 我对你系统上的 TASKLIST 失败感兴趣 - 你能给我一些关于你的平台的细节吗?

于 2014-11-28T09:45:34.807 回答