Open davibf11 opened 2 years ago
This would be a very welcome addition. glmTMBB
has a natural implementation of many of these structures which seem to work (exclusively?) at the group level, and anything from the lme4
group is usually a good start. https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html
Possibly related to this issue https://github.com/paul-buerkner/brms/issues/1025
Hello,
First and foremost, thank you for all of the excellent work that's done here!
brms
is an excellent package and really helps decrease dependence on working in basestan
, which is helpful when working with others (as fun as it is to pick through thousands of lines of a complicated model...).One feature that I think would be really helpful for
brms
to be able to implement would be to allow for AR correlation structures within random effects. This is something that I do frequently in basestan
when working with data that has groups that are ideal to pool information over, and which also has multiple observations over multiple time periods.I've put together an example script (and
stan
code) together here to give an idea about what I'm talking about. This is different from thestan
models that I usually use - I modified it to try to use a lot of similar code to whatbrms
usually outputs. Essentially, we'd be fitting the following model:y ~ 1 + (ar(time, p = 1) | group)
The correlation structure is achieved using a pretty straightforward spectral decomposition. This allows for each group to have a separate random effect for each time period with the specific correlation structure. I'm sure there's a more intuitive way to set this up in
brms
to allow for users to set differentp
values, but I figured I would put something together to give an idea of what I'm talking about. Let me know if this doesn't make sense, or if there's anything else I can do to clarify!