I am creating a model to predict the age of trees from their height using the rethinking package. In my data set, age is gamma distributed. To accommodate the gamma likelihood, I made this model using map()
:
fit2<- map(
alist(
age ~ dgamma2(mu, scale),
log(mu) <- b + m*height,
b ~ dnorm(16.3759, 10),
m ~ dnorm(10.9808, 10),
scale ~ dexp(2)
),
data = d
)
However, I am concerned that "scale" isn't normally distributed and thus I can't use extract.samples()
to sample the multi-dimensional posterior. I believe if I log the scale parameter, it becomes normal, and thus using extract.samples()
will work.
How do I modify the code above to do this? I've seen this done in other examples with dbetabinom()
but never with dgamma2()
.