4

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.

Tomas
  • 57,621
  • 49
  • 238
  • 373
  • From what you have reported, it seems that your error arises during initialization and so no `jags.dumpN.R` will be generated. This kind of error typically happens when an invalid value is passed as a parameter of a distribution. My guess is that some of the `pi[107,]` might be negative. – nicola Nov 27 '14 at 10:01
  • Thanks @nicola. Do you know if and how these `pi[107,]` values can be dumped? – Tomas Nov 27 '14 at 10:09
  • 2
    I honestly don't know if you can, but I guess you cannot. Anyway, I might suggest (if possible) to remove the `Y` node and run the model monitoring the `pi` node. Eventually, you will be able to see how `pi[107,]` behaves. Anyway, first of all check the initial values of the `pi` node (if you are providing them). – nicola Nov 27 '14 at 10:20
  • @nicola, this is an interesting suggestion (to monitor `pi` this way). – Tomas Nov 28 '14 at 10:27

1 Answers1

2

I'm afraid there is no way to dump any values from your model. The key line you quoted from the JAGS manual is 'and initialises correctly' - this didn't happen for your model, so there is nothing to dump out, sorry. You will have to manually specify sensible initial values for the (stochastic) parents of Y[] as @nicola suggests.

Incidentally - I am interested in the failure of TASKLIST on your system - can you give me some details of your platform?

Matt Denwood
  • 2,537
  • 1
  • 12
  • 16
  • Hi Matt! Thanks for the response. 1) *"there is nothing to dump"* - I don't agree. JAGS **must** know the parent values when he reports this. He could easily do that. 2) I have Windows XP. – Tomas Nov 28 '14 at 11:32
  • For 1) I meant that there is nothing to dump because the model is immediately deleted if initialisation failed - although as you say it is theoretically possible for a dump-on-fail-initialisation to be written into JAGS (this might already happen if JAGS is compiled in 'debug mode', I'm not sure). For 2) - thanks, I thought that worked in XP but will check it out if I get chance. Matt – Matt Denwood Dec 01 '14 at 21:25