I got the following error from JAGS:
Error in node Y[107]
Invalid parent values
From this mere information it is very difficult to find out what is happening there. It is caused by this part of code:
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,])
It would have been very useful to print out the parent values of node Y[107]
, i.e. the nodes pi[107,]
! That would give me very clear feedback where to look for the error! Is there such a way in JAGS?
In Chapter 3.2 of the JAGS manual, JAGS is speaking about leaving some useful jags.dumpN.R
files:
If a model compiles and initializes correctly, but an error occurs during updating, then the current state of the model will be dumped to a le named jags.dumpN.R where N is the chain number. You should then load the dumped data into R to inspect the state of each chain when the error occurred.
however, I am not sure if this applies to my case. So I tried to get the dump files. Since I am using runjags::run.jags()
to run JAGS, I tried to run it in the debugging mode:
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
Unfortunatelly, there are no dumps or files with any useful information in the runjagsfiles_3
directory.
Is there any way to get those "Invalid parent values" out of JAGS?
I am using JAGS 3.4.0.
PS: I intentionally do not submit my full model code here. My question is general about JAGS, not why my model doesn't work.