Specifying R-side and G-side Random Effects in brms

SAS PROC Glimmix permits both R-side and G-side random effects to be specified where the R-side, often the within individual error /residual that arises from either Repeated measures( or a time based multiple) measures, can be specified as an AR(1). The G-side represents the standard covariance matrix (of random intercept and/or random slope) at the group-ID level.

I can specify these models in “nlme” for example using:

rside_gside <- lme(sales ~ tv80+digital30+search50, random = ~1|storeid, correlation=corAR1(form=~1|storeid), data=storesales)

How do I specify both the R-side and G-side in brms?



Hi Sree,

G-side effects are specified using lme4-style syntax, so a G-side only model would look like:

gside <- brms(sales ~ tv80 + digital30 + search50 + (1|storeid),

R-side effects are specified using brms's autocor functions. For a list of these and how specify them, see the doc here: http://paul-buerkner.github.io/brms/reference/autocor-terms.html

So an R-side only model would look like:

rside <- brms(sales ~ tv80 + digital30 + search50 + ar(gr=storeid),

Naturally, a model combining R-side and G-side effects would then be:

rside_gside <- brms(sales ~ tv80 + digital30 + search50 +
                            ar(gr=storeid) + (1|storeid),

@andrjohns thank you so much for the set of succinct examples. Thanks for the reference too. I will review the notes.


1 Like

Looks like many of the popular options are covered. Instead of AR(1), is it possible to specify a fully parameterized / unstructured R matrix for correlated observations within independent stores?

1 Like

Good timing! The unstructured option landed in the github brms last week: https://github.com/paul-buerkner/brms/pull/1435


Fantastic! Looks like exactly what I need.