#20 Better Error Message for "Invalid Parent Values"

open
nobody
None
1
2014-03-22
2014-03-21
Russell Almond
No

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.

1 Attachments

Related

Feature Requests: #20

Discussion

  • Martyn Plummer
    Martyn Plummer
    2014-03-21

    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) but mu is not provided as data or defined on the lef hand side of a relation
    b) You have a circular dependency: e.g. y ~ dnorm(x, sigma.y) and x ~ dnorm(y, sigma.x)

    Teasing these two cases apart is not so easy.

     

    • Anonymous
      2014-03-22

      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:

      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)| but |mu|
      is not provided as data or defined on the lef hand side of a relation
      b) You have a circular dependency: e.g. |y ~ dnorm(x, sigma.y)| and |x ~
      dnorm(y, sigma.x)|

      Teasing these two cases apart is not so easy.


      [feature-requests:#20]
      http://sourceforge.net/p/mcmc-jags/feature-requests/20/ Better Error
      Message for "Invalid Parent Values"

      Status: open
      Group: Next_Release_(example)
      Created: Fri Mar 21, 2014 07:31 PM UTC by Russell Almond
      Last Updated: Fri Mar 21, 2014 07:31 PM UTC
      Owner: nobody

      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.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/mcmc-jags/feature-requests/20/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      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

  • Martyn Plummer
    Martyn Plummer
    2014-03-22

    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.

     
  • Russell Almond
    Russell Almond
    2014-03-22

    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.

     


Anonymous


Cancel   Add attachments