Skip to content

Fitting multi-response mixed effects models with lmer

4 messages · jonnations, Ian Dworkin, Ben Bolker

#
Hi Alejandro,

This is easy to do in brms, if you?re willing to explore Bayesian options.
There is a nice vignette (brms multivariate) that covers this exact thing.

Jon

On Sun, Jul 14, 2019 at 3:01 AM <r-sig-mixed-models-request at r-project.org>
wrote:

  
    
#
It isn't terribly hard to roll your own: this is untested but should
get you started.

   respvars <- c("y.1","y.2","y.3")
   fits <- vector("list", 3)
   names(fits) <- respvars
   fits[[1]] <- lmer(y.1 ~ u + (u | floor_id) + (u | county_id),
data=your_data))
   for (i in 2:3) {
           fits[[i]] <- refit(fits[[1]], your_data[[respvars[i]]]
       }
  }
On Sun, Jul 14, 2019 at 10:33 AM jonnations <jonnations at gmail.com> wrote:
#
Alejandro,

 Ben B. and I taught some examples of "tricking" lmer for multivariate
response models, see here
https://mac-theobio.github.io/QMEE/MultivariateMixed.html

Cheers
Ian
On Sun, 14 Jul 2019 at 10:33, jonnations <jonnations at gmail.com> wrote:

            

  
    
#
I thought Alejandro was interested in fitting these responses as
*independent* outcomes (since he says below "I can iteratively fit one
model for each response but I?m guessing that would be much slower"; I
think the loop using refit() every time after the first would be
reasonably fast - I certainly don't see a super-easy way to do it faster
...)
On 2019-07-14 4:36 p.m., Ian Dworkin wrote: