Modelling group-level variance of random slope/coefficient

Summary

  • I’d like to model the group-level variance of a random coefficient as a function of other group-level variables.
  • I know I can model sigma as a function of other variables. But cannot see how to model the random slope as well.

Adapting the fit_rent2 example from Bürkner (2018), suppose we have a model:

library(brms)
data("rent99", package = "gamlss.data")

bform <- bf(rentsqm ~ area + (area | district),
            sigma ~ area + (1 | district))
m1 <- brm(bform,
          data = rent99,
          chains = 4, cores = 4)

What I’d like is something like:

bform <- bf(rentsqm ~ area + (area | district),
            sigma ~  (1 | district),
--->        sigma[area] ~ district)          <---
m2 <- brm(bform,
          data = rent99,
          chains = 4, cores = 4)

sigma allows modelling of the group-level intercept. In theory, sigma[area] would allow modelling of the random slope for area.

Is anything like this possible?

Motivation

I may be confusing things, so to explain the motivation:

  1. We have a continuous outcome y that we relate to a binary covariate x1.
  2. We allow a group-level intercept for y and a group-level coefficient for x1.
  3. The effect of x1 on y is larger for some individuals than others.
  4. We want to consider what other variables explain this variation (e.g. x2).

So, the thinking was to model predictors of the group-level coefficient for x1, as suggested above (sigma[x1] ~ x2). A positive coefficient for for sigma[x1]_x2 would mean that the effect of x1 on y is larger for individuals with greater x2.

It’s entirely possible I’m missing something obvious, have the wrong approach and/or question. Any suggestions would be gratefully received.


  • Operating System: Arch Linux x86_64
  • brms Version: 2.16.1

It sounds like maybe you are asking something similar as on this post?
Maybe the suggestion of the LMMELSM package on that thread would help you?

Thanks for the reply.

Yes, I read that post with interest, because it seemed to have the answer. But from what I could tell, it talks about modelling the variance of the random intercept only. I don’t think (but would love to be wrong) it extends this to also model random slope variance.

I’ll have another read now.

Funny enough - once upon a time, LMMELSM did let you predict the random slope variance. However, this proved to cause enormous convergence problems, especially for the Latent factor models that LMMELSM was primarily created to fit. So I disabled the random slope variance modeling. Afterward, I realized it’d be easy to implement non-latent multivariate MELSMs as well, but never bothered to allow random slope variance modeling.

I think if you look at the stan files in lmmelsm, you may be able to just tweak it to allow random slope variance modeling as well.

3 Likes

Brillliant, thanks for the pointer. I’ll take a look and see what’s possible.