Distributional regression for endpoint inflated binomial model

I’m interested in trying out a few different link functions for regression on the mixture proportion simplex. This is how my custom family is currently set up:

ei_binomial <- custom_family(
  "ei_binomial",
  dpars = c("mu", "po", "pm"),
  links = rep("identity", 3),
  lb = c(NA, 0, 0), ub = c(NA, 1, 1),
  type = "int", vars = c("yo[n]", "ym[n]", "trials[n]")
)
ei_binomial_funs <- "
  real ei_binomial_lpmf(int y, real mu, real po, real pm, int yo, int ym, int T) {
    return log(yo*po + ym*pm + (1-po-pm)*exp(binomial_logit_lpmf(y|T, mu)));
  }
  int ei_binomial_rng(real mu, real po, real pm, int T) {
    int which_component = categorical_rng([po, pm, (1-po-pm)]');

    if (which_component == 1) {
      return 0;
    }
    if (which_component == 2) {
      return T;
    }

    return binomial_rng(T, inv_logit(mu));
  }"

The resulting fits are consistent with a model I previously specified directly in Stan that uses a proper simplex for the proportions, but the joint posterior of the mixing proportions doesn’t constrain the sum to 1 so it behaves badly when trying to do posterior checks.

I was wondering whether it’s possible to specify a simplex parameter for a custom family or if there’s some other approach that might work. I know that I could use unrestricted parameters and transform them inside the pmf but I was hoping to be able to use a non-linear specification to easily try out different link functions from R itself.


  • Operating System: Ubuntu 18.04.1 LTS
  • brms Version: 2.7.0

It is not possible to specify simplex parameters with brms for your use-case. Either use Stan directly (as you already did apparently), or specify the mixing proportions in a way that guarantees a sum to one contraint. I recomment looking at the zero_one_inflated_beta family of brms for such an example.

1 Like