Specifying several families in a brms model

Hi!

I’m having a bit of trouble specifying a model I’m interested in fitting in brms. If I understand correctly, it would be a distributional model, but how does one specify several families in that context?

Here’s a simplified version of the model I’m trying to code:
y~NegativeBinomial(mu, shape)
where:

  • mu depends linearly on, day, with slope and intercept to be estimated.
  • shape ~ Exponential(lambda), with lambda to be estimated.

The main response variable y would seem to imply that I need to select family = brms::negbinomial(link="log"), but then, how do I specify the exponential distribution for shape?

I’m ignoring the priors on the intercept, slope and lambda above, but those would obviously need to be specified in the model.

And just in case it matters: I actually intend to add grouping factors here for a multilevel model, but didn’t want to complicate my question unnecessarily - hopefully this doesn’t fundamentally change the answer.

Many thanks!

On the off-chance it’s relevant:

  • Operating System: Ubuntu 20.04.1 LTS
  • brms Version: 2.13.5
1 Like

A small correction: the model I’m trying to fit is nonlinear, so for the sake of argument, let’s make mu=exp(a * day), where a is a parameter to be estimated.

I was told (outside of this forum) that it might be important that my model is nonlinear, and I excluded that from my initial post in an attempt to make my question as simple as possible. (Sorry for adding this outside the original post, but I’m unable to edit it.)

Thanks again!

Sorry, your question seems to have fallen through.

I think you have a conceptual misunderstanding: In distributional models, the distributional parameters (here mu and shape) do not have a “distribution”, only the outcome has a distribution. Both mu and shape are a deterministic function of model coefficients and data. In this, the model you are after is fundamentally different.

AFAIK brms generally only allows you to put distributions on data, not on latent (unobserved) parameters. You might be able to hack around this limitation but you would be going a bit against brms and I cannot guarantee this will work much better than writing the model in Stan directly. You could IMHO either use stanvars to inject new parameters to the model. And maybe a clever combination with prior might let you do this. What you are trying to achieve looks similar to the behavior of the shrinkage priors horseshoe and lasso, so maybe you would be able to see how those are implemented and write your own… But really this would involve getting to know some brms internals.

Hope this clarifies more than confuses.

Thank you, Martin! That definitely helps clarify. Stan it is, then :-)