Getting around truncation limitation for mixture models in brms


I am aware that truncated distributions are not yet supported in brms formulas for mixture models, but was wondering if there was a strategy for getting around this limitation.

mix <- mixture(gaussian, gaussian)
prior <- c(
  prior(normal(mup1, varp1), Intercept, dpar = mu1),
  prior(normal(mup2, varp2), Intercept, dpar = mu2)
fit1 <- brm(bf(response ~ 1, theta1 ~ s(days, k=15)), data = ts, family = mix,
            prior = prior, chains = 2, stanvars = stanvars)

However, the distribution of my response variable looks like this, because the instrument that measures these values has a saturation limit:


I suspect this can be done by making mix a mixture of custom distributions, but I’m not sure how to go about it.

  • Operating System: Debian 9
  • brms Version: 2.3.1


Yeah would you could do is to define a truncated normal distribution as a custom family and then put that into your mixture model. You can see how a truncated normal looks like in stan code my running

make_stancode(y | trunc(lb = 0, ub = 5) ~ 1, data = data.frame(y = 1), family = gaussian())