Mixed-effects location-scale models in brms

I am looking to build a mixed-effects location-scale model in brms, as implemented by Hedeker and Nordgren 2013 (https://www.ncbi.nlm.nih.gov/pubmed/23761062).

The parameterization is as such (taken from https://www.jstatsoft.org/article/view/v059c02):
Screen Shot 2020-01-28 at 9.01.43 PM

Basically, this allows covariates for the mean value, the variance of the between-subject random effects, and the variance of the within-subject error terms. There is example code by Williams et al 2019 on how to do this with a non-linear version of this model (https://link.springer.com/article/10.3758/s13428-019-01255-9), but I cannot figure out how to implement the original linear version in brms. Is this even possible?

Please also provide the following information in addition to your question:

  • Operating System: macOS Catalina 10.15.2
  • brms Version: 2.10.0
1 Like

This is possible. See the brms_multilevel vignette for details.

1 Like

Thanks Paul! I see from the vignette how to model the mean values and the “within-subject” variance (i.e., residual variance), using code such as

bf(y ~ X1 + (1 |c| subj), sigma ~ 1 + X1 + (1 |c| subj))

but it doesn’t say how to model the “between-subject” variance (i.e., the group-level intercepts) with covariates. In effect, I’m not sure how to model the \sigma_{u_{ij}} portion of the model above, since the parameters are not part of the syntax, but is required as both the coefficient for \theta_{1i} and as a non-linear outcome within the model in the form of \log\left(\sigma^2_{\upsilon_{ij}}\right).

1 Like

I am not sure I understand. You can predict sigma by whatever covariate you want as you do with X1 above. What is it that you don’t know how to model then?

1 Like

The sigma that brms allows to model as you have pointed out is the standard deviation of the residuals. However, as in Hedeker and Nordgren 2013 (MIXREGLS: A Program for Mixed-Effects Location Scale Analysis - PubMed), I also wish to model the standard deviation of the group effects:

In terms of the variance structure, covariates can be specified to have effects on both the between-subject and within-subject variances. Another use is for clustered data in which subjects are nested within clusters (e.g., clinics, hospitals, schools, etc.) and interest is in modeling the between-cluster and within-cluster variances in terms of covariates.

This means, in a panel data set with individuals as level-2 units, modeling both the within-group variability (that is, within-person variability over time), and the between-group variability (that is, variability between persons). sigma as it is allows me to model the within-group variability, but not the between-group variability. Hope this makes more sense?

1 Like

To my knowledge, brms does not let you do this [yet?]. It’s fairly simple to do via stan itself, however. The Williams/Rast/Zimprich paper does not model the between-group SD afaik.

So you can either code it up yourself in Stan, or you might be able to use a package of mine (https://github.com/stephensrmmartin/ICCier Use Split_bp_wp branch!) to fit the model. It’s intended for modeling ICCs, but we ultimately use a MELSM. Due to the focus on ICCs, the summary output, by default, hides some parameters (if I recall correctly), but can show the full parameter matrix of interest.
The basic specification may be: within ~ level1ResidSDPredictors|level2ResidSDPredictors, between ~ RandomEffectSDPredictors, mean ~ level1locationPredictors|level2locationPredictors. So, e.g.: ICCier(y, subj, within ~ 1|X1, between ~ X1, mean ~ 1|X1, data = ds) would model the residSD and between-group SDs from a level-2 variable: X2. Again, by default, the focus is on ICCs, so the summary(output) may hide some of the parameters, but there’s an option I believe for showing the full thing.

Did you ever succeed in modeling the BS variance in Stan or brms? If so, I’d love to hear/see how you did it because I’m working on the same problem.

Hi, unfortunately not. This paper (https://doi.org/10.1080/00273171.2018.1477577) seems to have some code to do it in Stan, but I haven’t yet looked at it closely and modified it for my own use. Let if know if you make any progress on it!

1 Like

Thank you! It does indeed look like they’ve added a BS variance model. I’ll check it out and let you know if I make any progress!

See here: Mixed-effect Location Scale Model with BS variance model

1 Like

Hi Madeline! Did you ever happen to get this working? I want to compute ICCs for each subject using brms in stan and I’m a little stuck. Curious to know if you’ve figured this out for the group-level?

FYI I’ve been engaged in ongoing work in this general domain:

I’m working on validating the solution proposed in the latter now and hope to have that plus code implementing/validating the former done in the next month or so.

Thanks so much! I’ll check it out today and follow up.

Hi Michaela,

I checked with @paul.buerkner a while back to determine whether it is possible to model the between subject variance in addition to the within subject variance using brms. He said that it’s not currently possible and that it isn’t high on the priority list.

To my knowledge, you’d have to write the model you’re interested in in Stan. I tried this and gave up after a sincere attempt. I found it to be pretty complicated.

I wish I could be more helpful!