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:
- We have a continuous outcome
y
that we relate to a binary covariatex1
. - We allow a group-level intercept for
y
and a group-level coefficient forx1
. - The effect of
x1
ony
is larger for some individuals than others. - 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