[R-sig-ME] Fitting multi-response mixed effects models with lmer

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Sun Jul 14 22:07:43 CEST 2019


 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 using gmail.com> wrote:
>
> 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 using r-project.org>
> wrote:
>
> > Send R-sig-mixed-models mailing list submissions to
> >         r-sig-mixed-models using r-project.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> > or, via email, send a message with subject or body 'help' to
> >         r-sig-mixed-models-request using r-project.org
> >
> > You can reach the person managing the list at
> >         r-sig-mixed-models-owner using r-project.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of R-sig-mixed-models digest..."
> >
> >
> > Today's Topics:
> >
> >    1. Fitting multi-response mixed effects models with lmer
> >       (Alejandro Catalina)
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Sat, 13 Jul 2019 18:02:20 +0300
> > From: Alejandro Catalina <alecatfel using gmail.com>
> > To: r-sig-mixed-models using r-project.org
> > Subject: [R-sig-ME] Fitting multi-response mixed effects models with
> >         lmer
> > Message-ID: <e44b3683-1a88-45f8-8dc8-1c07595c0dd7 using Spark>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Dear all,
> >
> > I found myself trying to fit a multi-response model with lmer the other
> > day and today I learned that it is indeed not implemented. Is there anyone
> > looking on that direction or does anyone have any pointers or suggestions?
> > I guess I can iteratively fit one model for each response but I’m guessing
> > that would be much slower. Furthermore, I would need to later combine all
> > the models into a single object for my specific requirements. This is the
> > issue I opened on lme4’s GitHub:
> >
> >         Hi,
> > I am trying to solve the following formula with lmer:
> > cbind(y.1, y.2, y.3) ~ u + (u | floor_id) + (u | county_id)
> > which works fine for standard lm models without the group terms, but it
> > fails when I have the mixed effects terms with the following error:
> > Error in initializePtr() : updateMu: Size mismatch
> > If this is not the right place to post this issue please tell me, I
> > appreciate any pointers forward.
> >
> > Thank you all,
> >
> > Best,
> > Alejandro
> >
> >         [[alternative HTML version deleted]]
> >
> >
> >
> >
> > ------------------------------
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > R-sig-mixed-models mailing list
> > R-sig-mixed-models using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
> >
> > ------------------------------
> >
> > End of R-sig-mixed-models Digest, Vol 151, Issue 10
> > ***************************************************
>
> --
> Jonathan A. Nations
> PhD Candidate
> Esselstyn Lab <https://esselstyn.github.io/>
> Museum of Natural Sciences <https://www.lsu.edu/mns/>
> Louisiana State University
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list