Better Error Message for "Invalid Parent Values"
Brought to you by:
martyn_plummer
The node printed with the "Invalid Parent Values" method may not be at the locus of the problem, but instead it may be at an ancestor of the given node. Some additional information tracing what it is doing to initialize that node might help.
The attached big of jags program, part of a hierarchical mixture model, shows the problem. JAGS identifies the problem as being at tau[100,2], but the problem is in fact in the definition of gamma0 (a parent of tau), which was intended to be a normal instead of a gamma.
Anonymous
Yes. This is one of those situations where, if something goes wrong, you need to go back and do it again, but step-by-step so you can see exactly where the error occurred. I haven't yet implemented this second stage forensic examination of the error but it clearly needs to be done.
One problem is that two quite distinct situations can cause the same problm in the compiler
a) You forgot to define a variable: e.g.
y ~ dnorm(mu, tau)
butmu
is not provided as data or defined on the lef hand side of a relationb) You have a circular dependency: e.g.
y ~ dnorm(x, sigma.y)
andx ~ dnorm(y, sigma.x)
Teasing these two cases apart is not so easy.
The code fragment I posted with the bug report was an aborted attempt to
make a slightly smaller model that hat the problem. I found and fixed
the problem in the original code (I was changing my parameterization
from using gammas to using half normals, and I missed one bit of code on
the change).
The purpose of the request was to put better error reporting on your to
do list. In many ways it would be more helpful than new distributions
and samplers.
Thanks,
--Russell
On 03/21/2014 05:22 PM, Martyn Plummer wrote:
--
Russell Almond
Associate Professor, Measurement & Statistics
Educational Psychology and Learning Systems
1114 W. Call St.
Florida State University
Tallahassee, FL 32306
(850) 644-5203
ralmond@fsu.edu
http://ralmond.net/
Related
Feature Requests: #20
Yes, I get that. This is a known issue but it is good to have a reproducible example.
I think my reply was badly phrased. When I wrote "you" I didn't mean you the user. I was speaking generally: when one writes a program (like JAGS) there are times when it is necessary to repeat some of the steps (within the JAGS program) that led to an error in order to get a better diagnosis and give a comprehensible error message. What I am really saying is that this is not just a case of finding a better error message to put in at the point where the error occurs. It requires a bit more effort.
But I agree. Error messages can never be too too explicit.
One trick I found useful in coding StatShop was to use catch the error message at each level and add some context information and then throw it up one higher level. Then at the highest level function that reported the error would have all of the context information (e.g., which chain, which cycle, which parameters, ...)
In the case of cicular dependencies, this should trace out the loop to make ic clear to the user where the cycle is. In the case of an undefined node, it should give the actual node where the lack of definition occured and not just the node at which the problem was observed.
Mind you, I was working in Java, I'm not sure what kind of support there is for this kind of thing in C++, and in C you would need to build it manually. Hopefully, that gives you some approaches for implementing it though.
I have actually posted a similar request https://sourceforge.net/p/mcmc-jags/bugs/36/ . I think it would be great if JAGS could dump that "invalid parent value", along with the child node value, that would be very helpful. Then you can immediatelly see that you have e.g. 1 ~ dbern(0). This is also case of "Node inconsistent with parents" and "Observed node inconsistent with unobserved parents at initialization".