title: Is there a way to dump JAGS node values for debug purposes?
body: <p>I got the following error from JAGS:</p>
  
  <pre><code>Error in node Y[107]
  Invalid parent values
  </code></pre>
  
  <p>From this mere information it is very difficult to find out what is happening there. It is caused by this part of code:</p>
  
  <pre><code>pi[j,1] &lt;- 1 - M[site[j]] * phi[j] * (1 - (1 - q[j])^6)
  pi[j,2] &lt;- M[site[j]] * phi[j] * (1 - q[j])^interval[j] * q[j]
  pi[j,3] &lt;- 1 - pi[j,1] - pi[j,2]
  Y[j] ~ dcat(pi[j,])
  </code></pre>
  
  <p>It would have been very useful to print out the parent values of node <code>Y[107]</code>, i.e. the nodes <code>pi[107,]</code>! That would give me very clear feedback where to look for the error! Is there such a way in JAGS?</p>
  
  <p>In Chapter 3.2 of the JAGS manual, JAGS is speaking about leaving some useful <code>jags.dumpN.R</code> files:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>however, I am not sure if this applies to my case. So I tried to get the dump files. Since I am using <code>runjags::run.jags()</code> to run JAGS, I tried to run it in the debugging mode:</p>
  
  <pre><code>R&gt; outRJ &lt;- 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 &amp;  : 
    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
  </code></pre>
  
  <p>Unfortunatelly, there are no dumps or files with any useful information in the  <code>runjagsfiles_3</code> directory.</p>
  
  <p>Is there any way to get those "Invalid parent values" out of JAGS?</p>
  
  <p>I am using JAGS 3.4.0.</p>
  
  <p>PS: I intentionally do not submit my full model code here. My question is general about  JAGS, not why my model doesn't work.</p>