BUGS error messages
Asked Answered
C

2

11

I am new to WinBUGS/OpenBUGS and having difficulty debugging my code.

Does anyone know of a list of potential error messages for BUGS models and their meanings in plain English?

Contractive answered 23/2, 2014 at 14:36 Comment(0)
B
17

The WinBUGS manual has a list of some common error. I have added some additional notes from my own experience:

  • expected variable name indicates an inappropriate variable name. I occasionally get this error in providing the data, might have used 1.02e04 instead of 1.02E04.

  • undefined variable - variables in a data file must be defined in a model (just put them in as constants or with vague priors). If a logical node is reported undefined, the problem may be with a node on the 'right hand side'. I occasionally get this error when I have removed a variable from the model but not from the data or missed a comma in the data.

  • invalid or unexpected token scanned - check that the value field of a logical node in a Doodle has been completed.

  • index out of range - usually indicates that a loop-index goes beyond the size of a vector (or matrix dimension); sometimes, however, appears if the # has been omitted from the beginning of a comment line

  • linear predictor in probit regression too large indicates numerical overflow. See possible solutions below for Trap 'undefined real result'.

  • logical expression too complex - a logical node is defined in terms of too many parameters/constants or too many operators: try introducing further logical nodes to represent parts of the overall calculation; for example, a1 + a2 + a3 + b1 + b2 + b3 could be written as A + B where A and B are the simpler logical expressions a1 + a2 + a3 and b1 + b2 + b3, respectively. Note that linear predictors with many terms should be formulated by 'vectorizing' parameters and covariates and by then using the inprod(.,.) function

  • unable to choose update method indicates that a restriction in the program has been violated

You might also hit a trap at the start or during the MCMC. The BUGS manual list the following common traps (I always get the first two, never met the last two):

  • undefined real result indicates numerical overflow. Possible reasons include:

    • initial values generated from a 'vague' prior distribution may be numerically extreme - specify appropriate initial values;
    • numerically impossible values such as log of a non-positive number - check, for example, that no zero expectations have been given when Poisson modelling;
    • numerical difficulties in sampling. Possible solutions include:
    • better initial values;
    • more informative priors - uniform priors might still be used but with their range restricted to plausible values;
    • better parameterisation to improve orthogonality;
    • standardisation of covariates to have mean 0 and standard deviation 1.
    • can happen if all initial values are equal.Probit models are particularly susceptible to this problem, i.e. generating undefined real results. If a probit is a stochastic node, it may help to put reasonable bounds on its distribution, e.g.

        probit(p[i]) <- delta[i]
        delta[i] ~ dnorm(mu[i], tau)I(-5, 5)
      

      This trap can sometimes be escaped from by simply clicking on the update button. The equivalent construction

        p[i] <- phi(delta[i])
      

      may be more forgiving.

  • index array out of range possible reasons include:

    • attempting to assign values beyond the declared length of an array;
    • if a logical expression is too long to evaluate break it down into smaller components.
  • stack overflow can occur if there is a recursive definition of a logical node.

  • NIL dereference (read) can occur at compilation in some circumstances when an inappropriate transformation is made, for example an array into a scalar.

  • Trap messages referring to DFreeARS indicate numerical problems with the derivative-free adaptive rejection algorithm used for log-concave distributions. One possibility is to change to "Slice" sampling

Byng answered 25/2, 2014 at 23:5 Comment(0)
P
2

This WinBUGS User Manual might be of some use.

Primaveria answered 23/2, 2014 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.