In R, I am running an MCMC Bayesian inference for data from mixture of Gamma distributions. JAGS is used here. The model file gmd.bug is as follows

Then, this is the inference phase

Here is the error that puzzled me

Anyone know what needs to be fixed here?

Code:

```
model {
for (i in 1:N) {
y[i] ~ dsum(p*one, (1-p)*two)
}
one ~ dgamma(alpha1, beta1)
two ~ dgamma(alpha2, beta2)
alpha1 ~ dunif(0, 10)
beta1 ~ dunif(0, 10)
alpha2 ~ dunif(0, 10)
beta2 ~ dunif(0, 10)
p ~ dunif(0, 1)
}
```

Code:

```
gmd.jags = jags.model("gmd.bug",
data = list(N = NROW(a), y=unlist(a)),
inits = inits, n.chains = 3, n.adapt = 1000)
```

Code:

```
Error in jags.model("gmd.bug", data = list(N = NROW(a), y = unlist(a)), :
Error in node y[1]
Node inconsistent with parents
```

Last edited: