I have a question about this model in JAGS, I want to make a bayesian linear regression with a y[i] that follows not a normal distribution but a gamma.
The model is this:
"model {
Priors:
a ~ dnorm(0, 0.0001) # mean, precision = N(0, 10^4)
b ~ dnorm(0, 0.0001)
shape ~ dunif(0, 100)
# Likelihood data model:
for (i in 1:N) {
linear_predictor[i] <- a + b * x[i]
# dgamma(shape, rate) in JAGS:
y[i] ~ dgamma(shape, shape / exp(linear_predictor[i]))
}
}
"
What should I change to make this code usable for a multiple linear regression with this data?
dataListGamma = list(
x = x,
y = y,
Nx = dim(x)[2],
Ntotal = dim(x)[1]
)
i'm receiving this error: Error in node (shape/(exp(linear_predictor[1331]))) how can this be possible? i cant understand if i run it again it changes the value that makes the problem
Something like this (making
ba vector with identical, independent priors for each element, and constructing the linear predictor with aforloop) should work: