Speed up lmer function in R

后端 未结 3 1830
粉色の甜心
粉色の甜心 2021-02-01 07:32

I would like to share some of my thoughts when trying to improve the model fitting time of a linear mixed effects model in R using the lme4 package. <

相关标签:
3条回答
  • 2021-02-01 07:57

    lmer() determines the parameter estimates by optimizing the profiled log-likehood or profiled REML criterion with respect to the parameters in the covariance matrix of the random effects. In your example there will be 31 such parameters, corresponding to the standard deviations of the random effects from each of the 31 terms. Constrained optimizations of that size take time.

    It is possible that SAS PROC MIXED has specific optimization methods or has more sophisticated ways of determining starting estimates. SAS being a closed-source system means we won't know what they do.

    By the way, you can write the random effects as (1+Var1+Var2+...+Var30||Group)

    0 讨论(0)
  • 2021-02-01 08:02

    We have implemented random intercepts regression assuming compound symmetry in the R package Rfast. The command is rint.reg. It is 30+ times faster than the corresponding lme4 function. I do not know if this helps, but just in case.

    https://cran.r-project.org/web/packages/Rfast/index.html

    0 讨论(0)
  • 2021-02-01 08:02

    If you use glmer rather than lmer, there is a parameter nAGQ. I found that setting nAGQ=0 dramatically reduced the time it took to fit a fairly complex model (13 fixed effects, one random effect with varying intercept and slope, 300k rows). This basically tells glmer to use a less exact form of parameter estimation for GLMMs. See ?glmer for more details, or this post.

    0 讨论(0)
提交回复
热议问题