I am trying to fit a simple Dirichlet regression using rjags with a parametrization in terms of the mean and the precision. The model is written as follows:

model { # (0) priors for (i in 1:(k-1)) { beta0[i] ~ dnorm(0,1); } theta1 ~ dnorm(0, 4)

# (1) likelihood 
for (j in 1:n){
  p1[j,] ~ ddirch(a1[]);

# Parametrization in terms of the mean and the precision
for (i in 1:(k-1))
  a1[i] <- mu1[i]*phi1
  mu1[i] <- exp(beta0[i])/(1+ exp(beta0[i]))
a1[k] <- (1 - sum(mu1[1:(k-1)]))*phi1
phi1 <- exp(theta1)


I continuously get the same error:

Error in node p1[1,1:4] Invalid parent values

I think that it is due to the substraction (1 - sum(mu1[1:(k-1)])), which is giving negative values. Any ideas of how can I solve that?


closed as off-topic by Tim Aug 6 '18 at 21:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Tim
If this question can be reworded to fit the rules in the help center, please edit the question.