3
$\begingroup$

I am running a simple beta regression model in JAGS, following the example given here. Here is my JAGS model code as an R object:

jags.model = "
model {
#model
for (i in 1:N){
y[i] ~ dbeta(alpha[i], beta[i])
alpha[i] <- mu[i] * phi
beta[i]  <- (1-mu[i]) * phi
logit(mu[i]) <- a + b*x1[i] + c*x2[i] + d*x3[i] + e*x4[i] + f*x5[i]
}

#priors
a  ~ dnorm(0, .0001)
b  ~ dnorm(0, .0001)
c  ~ dnorm(0, .0001)
d  ~ dnorm(0, .0001)
e  ~ dnorm(0, .0001)
f  ~ dnorm(0, .0001)
t0 ~ dnorm(0, 0.010)
phi <- exp(t0)
}" 

In the linked example there is a gamma prior on the phi parameter. However, I kept getting errors, so I shifted to an alternative expoential prior on phi to keep it positive. Every time I run this code using runjags I get the error: value out of range in 'gammafn', which prints out many many times until I tell the code to stop running. I am unsure what the problem is here, as I am no longer using a gamma function in any of this code. Any insight, or alternative methods to run a beta-regression in JAGS, would be appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

This happens because the initial values of the chains draw non-sensical values for the model. However, as it continues to run the chains move towards better values and the error message stops coming up. So, if its endlessly printing you have a problem. However, if it prints ~ 20-40 times and then stops, you're probably okay. JAGS will keep running and you will get a result.

$\endgroup$

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.