1

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().

M--
  • 25,431
  • 8
  • 61
  • 93
  • You should provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It should be [minimal, but complete and verifiable example](https://stackoverflow.com/help/minimal-reproducible-example). Your question should be clear and specific. – M-- Oct 21 '20 at 14:43

1 Answers1

1

The scale parameter is a positive number, so using exponential priors like dexp(2) makes sure that your model samples appropriate scale values. So your model should sample well and you shouldn't have problems using extract.samples.

M--
  • 25,431
  • 8
  • 61
  • 93