0
$\begingroup$

I am having a hard time try to figure out how to translate a simple INAR(1) model in JAGS. \begin{equation} Y_t = \alpha \circ Y_{t-1} + e_t \end{equation} where $\circ$ is the binomial thinning operator and $e$ a Poisson noise. In simple words the binomial thinning operator is a random operator which avoids the so called "multiplication problem" in the context of count data and, loosely speaking, can be interpreted as:

\begin{equation} \alpha \circ Y_{t-1} = Bin(Y_{t-1}, \alpha) \end{equation}

(the reason is that the expected value of the binomial is exactly $Y_{t-1} \times \alpha$ ) See for a quick intro: https://wires.onlinelibrary.wiley.com/doi/full/10.1002/wics.1502

Here is what I have tried:

model{
  #INAR(1)
  
  for (t in 2:T) {
    e[t] ~ dpois(lambda_e)
    P[t] ~  dbin(alpha, Y[t-1])
    Y[t]  ~ dsum(P[t],e[t])
  }
  
  e[1] ~ dpois(lambda_e)
  P[1] ~ dbin(alpha, Y[1])
  Y[1]  ~ dsum(P[1],e[1])
  
  
  #priors
  alpha  ~ dunif(-1,1)
  lambda_e  ~ dgamma(1, 0.001)
}
Error in jags.model(file = Model, data = dat, n.chains = N_chains, n.adapt = N_adapt) : 
  RUNTIME ERROR:
Possible directed cycle involving some or all
of the following nodes:
P[1]
P[2]
P[3]
P[4]
...

Does someone have any idea about how to solve this issue?

$\endgroup$

1 Answer 1

1
$\begingroup$

Have you tried googling the error? JAGS models are defined in terms of directed acyclic graphs (DAGs), it does not allow for cycles in model definition.

Another problematic part in your definition is that $t$ depends on $t-1$. JAGS is a declarative language, the for loop does not go sequentially through the steps, so it doesn't guarantee to do the $t-1$ computation before the $t$ step. If you need this, don't use JAGS.

$\endgroup$
2
  • $\begingroup$ Yes, the problem is that JAGS alternates three different errors when I try to adjust the code and so is very confusing (the one above, "Y[1] is a logical node and cannot be observed" and "SumMethod cannot fix the stochastic parents of this node to satisfy the sum constraint.."). However, I expected that such a simple model should have been feasible in JAGS. For instance normal ARMA or INGARCH models can be easily estimated despite they require for loops to be executed in a precise order. $\endgroup$
    – pietrosan
    Sep 16, 2021 at 10:11
  • $\begingroup$ @pietrosan can help with JAGS, but some models are hard to specify in this language. Moreover JAGS is not actively maintained and has known bugs, so using something more modern (e.g. Stan) is generally a better bet. $\endgroup$
    – Tim
    Sep 16, 2021 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.