You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I've been working with some Gamma GLMs lately and, while I really appreciate the dgamma2 density for making life easy, I find that it produces different results than dgamma (when dgamma is used properly) and am trying to struggle with why and/or how to create a model that will produce equivalent results. Let's start with an example data set from Witman et al. 2016 Ecological Monographs (happy to provide ref) that is looking at the duration of ecological experiments over the recent history of the discipline.
We can model this with a Gamma distribution (durations!) and a log link.
g_glm <- glm(Duration ~ Year.c, data = gamma_sample, family = Gamma(link = log))
coef(g_glm)
which leads to
(Intercept) Year.c
5.798676770 -0.002591553
OK - now, with dgamma2
gamma2_mod <- alist(
#likelihood
Duration ~ dgamma2(mu, scale),
log(mu) <- a + b*Year.c,
#priors
a ~ dnorm(0,100),
b ~ dnorm(0,1),
scale ~ dexp(2)
)
gamma2_fit <- map(gamma2_mod, gamma_sample)
This leads to somewhat different coefficient estimates (and is quite sensitive to the scale prior) (which is where I suspect the trouble might be coming in)
> coef(gamma2_fit)
a b scale
5.186479426 -0.001695557 153.327060740
Now, with the dgamma formulation, you have to do a little but more work in model construction, making rate = log_mu/shape
dzagamma2 was close but no cigar to recovering the coefficients that I used to generate the data (although it got the probability right). dzagamma was right on the money, as it were.
Advice or thoughts?
The text was updated successfully, but these errors were encountered:
OK, I get this - but, so, for your parameterization of a gamma, what is the correct way to create a flat prior, if not an exponential? Would be helpful to show students this.
So, I've been working with some Gamma GLMs lately and, while I really appreciate the
dgamma2
density for making life easy, I find that it produces different results than dgamma (when dgamma is used properly) and am trying to struggle with why and/or how to create a model that will produce equivalent results. Let's start with an example data set from Witman et al. 2016 Ecological Monographs (happy to provide ref) that is looking at the duration of ecological experiments over the recent history of the discipline.We can model this with a Gamma distribution (durations!) and a log link.
which leads to
OK - now, with dgamma2
This leads to somewhat different coefficient estimates (and is quite sensitive to the scale prior) (which is where I suspect the trouble might be coming in)
Now, with the
dgamma
formulation, you have to do a little but more work in model construction, making rate = log_mu/shapeThis works pretty well, though, as compared to the original.
So... what's going on here?
Note, I've found the same problem with the
dzagamma2
. Using some simulated dataI built the corresponding dzaggama2 model and then wrote
dzagamma2
was close but no cigar to recovering the coefficients that I used to generate the data (although it got the probability right).dzagamma
was right on the money, as it were.Advice or thoughts?
The text was updated successfully, but these errors were encountered: