[R-sig-ME] Why do lme() models runs so fast and converge as compared to lmer()?
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Thu Sep 21 01:45:35 CEST 2023
I'm still a little surprised that lme4 is so slow. Is there a
possibility that you're using a parallelized BLAS and it's
over-parallelizing (i.e., hogging lots of memory)? What is the memory
usage and CPU performance during your runs (i.e. does it look like
memory is getting overcommitted and/or lots of threads are running
simultaneously)?
e.g. see https://github.com/lme4/lme4/issues/627 ;
https://github.com/lme4/lme4/issues/726
lme, lmer, and glmmTMB are all well-respected as far as I know (the
least-cited and newest of these, glmmTMB, currently has more than 5000
Google Scholar citations ...)
On 2023-09-18 7:33 a.m., Santosh Srinivas wrote:
> Thank you, Dr. Bolker. The advice to set calc.derivs = FALSE is much
> appreciated.
>
> We tried glmmTMB() for the same model and found it quite fast. Models
> converged with default optimizers.
>
> Following this, we also tried Julia and were surprised by the
> orders-of-magnitude improvement in speed.
>
> We are tending to stick to R and use glmmTMB(). We hope that academic
> journals are generally receptive to using this package for hypothesis
> testing. From a cursory Google scholar search, it appears that glmmTMB()
> is used/cited less often (and Julia's MixedModels far and few) as
> compared to lme() and lmer().
>
> Assuming that models are specified identically, I am hoping the results
> for hypothesis testing (e.g., significance of a coefficient of
> theoretical importance) should be identical regardless of whether one
> uses R's lme(), lmer(), or glmmTMB(), or Julia's MixedModels().
Yes, they should. There are some details such as whether a
finite-size correction (e.g. Satterthwaite/Kenward-Roger) is applied,
but given the size of your data set I doubt that's much of an issue)
>
> On this note, anything that you suggest we state explicitly in the
> journal manuscript when presenting the results using glmmTMB() as
> opposed to lme() or lmer()?
>
> Thanks!
> sbs
> ------------------------------------------------------------------------
> *From:* R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> on
> behalf of Ben Bolker <bbolker using gmail.com>
> *Sent:* Monday, September 18, 2023 2:11 AM
> *To:* r-sig-mixed-models using r-project.org <r-sig-mixed-models using r-project.org>
> *Subject:* Re: [R-sig-ME] Why do lme() models runs so fast and converge
> as compared to lmer()?
> This is mildly surprising but not impossible. I haven't looked into
> it/run any experiments yet, but:
>
> * lme handles a more restricted range of model types, so it's possible
> that its algorithm is faster on simple examples;
>
> * 'doesn't converge' may not be the issue you think it is. I would
> improve performance and turn off convergence checking that is known to
> be dodgy for large data sets via control = lmerControl(calc.derivs =
> FALSE)), and more generally try these suggestions:
> https://rdrr.io/cran/lme4/f/vignettes/lmerperf.Rmd
> <https://rdrr.io/cran/lme4/f/vignettes/lmerperf.Rmd>
>
> cheers
> Ben Bolker
>
> On 2023-09-17 5:21 a.m., Santosh Srinivas wrote:
>> Hi, I am running the following similar models using lme() and lmer():
>>
>> f = y ~ x + year * post_event + (year|user_id)
>>
>> where,
>>
>> * year (integer) ranges from 0 (for the year 2010) to 10 (for the year2020);
>> * post_event (factor variable) is 1 for years 2013 onwards, and 0 otherwise;
>> * Number of Observations: 3586633; and
>> * Number of Groups: 1109.
>>
>> The lme4's lmer() runs for several minutes and never succeeds to converge with any optimizer I try, whereas the former seems to converge in a few minutes.
>>
>> Not sure if I am doing anything wrong, or whether such convergence and performances are generally expected of lme().
>>
>> Request your help.
>>
>> Thanks & regards,
>> sbs
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> <https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
>
> --
> Dr. Benjamin Bolker
> Professor, Mathematics & Statistics and Biology, McMaster University
> Director, School of Computational Science and Engineering
> (Acting) Graduate chair, Mathematics & Statistics
> > E-mail is sent at my convenience; I don't expect replies outside of
> working hours.
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> <https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
> E-mail is sent at my convenience; I don't expect replies outside of
working hours.
More information about the R-sig-mixed-models
mailing list