This is a closely related post but I am specifically looking for help with gamma mixture models.
I was able to achieve convergence on a gamma mixture model by setting lb
and ub
on the intercept priors so that the intercepts didn’t “swap” places. I tried to do this without setting hard bounds on the parameters but no matter how tight I made the sd on the intercept priors, they still managed to swap places unless I set the hard bound to prevent them from swapping.
However, the model that I got to converge is just a simpler version of the real model I want to fit, which also includes a random effect as well as a fixed treatment effect. Note that all the fixed and random effects only act on the mu
parameter of the gamma distribution, the shape parameter is common across both treatments. I don’t know if this is appropriate or if I should change that.
This is the simpler model with only a fixed effect that converged:
gammamix2_prior <- c(
prior(normal(log(0.3), 1), dpar = 'mu1', class = 'Intercept', lb = log(.01), ub = log(.5)),
prior(normal(log(0.8), 1), dpar = 'mu2', class = 'Intercept', lb = log(.5), ub = log(10)),
prior(normal(0, 0.1), dpar = 'mu1', class = 'b'),
prior(normal(0, 0.1), dpar = 'mu2', class = 'b'),
prior(gamma(1, 1), class = 'shape1'),
prior(gamma(1, 1), class = 'shape2')
)
fit_gammamix2_area_nore <- brm(bf(area ~ treatment),
data = dat_long, family = mixture(Gamma(link = 'log'), Gamma(link = 'log')), prior = gammamix2_prior,
chains = 3, iter = 3000, warmup = 2000, seed = 3567')
And here is the model with an additional random effect. This one didn’t converge. Note I added additional iterations and increased adapt_delta
to attempt to deal with divergent transitions.
fit_gammamix2_area <- brm(bf(area ~ treatment + (1 | sample:treatment)),
data = dat_long, family = mixture(Gamma(link = 'log'), Gamma(link = 'log')), prior = gammamix2_prior,
chains = 3, iter = 5000, warmup = 4000,
control = list(adapt_delta = 0.95), seed = 5567)
Here is what the data look like. First here’s the distributions for the treatments, ignoring the random effect of sample, with the fitted distributions from the models and 95% credible interval to show that the 2-component gamma mixture model is a good fit (for now the fit does not include random term). Incidentally I did try a simpler fit with only a single gamma distribtion (unimodal, not a mixture model) but the fit was very poor so I am really committed to making the mixture model work if possible.
(thick lines are observed density curves, thin lines and shaded regions are model fits with 95% credible interval)
And here’s what the individual samples’ distributions look like, to show what kind of random variation we are dealing with.
Is there any additional prior specification that might help, or some other tricks? Thanks in advance.