old and new lme4

Posted on Updated on


(This is a guest post by Klinton Bicknell.)

update 2014-06-24: Using lme4.0 probably isn’t necessary anymore. See post here.

The lme4 package‘s major 1.0 release was back in August. I and others have noticed that for typical psycholinguistic datasets, the new >=1.0 versions of lme4 often yield models with substantially poorer fits to the data than the old pre-1.0 versions (sometimes worse by many points of log likelihood), which suggests that the new lme4 isn’t as reliably converging to the actual maximum likelihood (or REML) solution. Since unconverged models yield misleading inferences about model parameters, it’s useful to be able to fit models using the old pre-1.0 lme4.

Happily, the lme4 developers have created a new package (named “lme4.0”), which is a bugfix-only version of the old pre-1.0 lme4. This allows for the installation of both old and new versions of lme4 side-by-side. As of this posting, lme4.0 is not yet on CRAN, but is installable by performing the following steps:

1. install the latest version of the new lme4

2. run this command in R:

install.packages("lme4.0", type="both",
                 repos=c("http://lme4.r-forge.r-project.org/repos",
                         getOption("repos")[["CRAN"]]))

3. If you’re on a Mac, you probably also need to install the gfortran package from here.

After that, you should just be able to load library(lme4.0) and have access to the pre-1.0 version of lme4. If you’re planning to load both versions at once, note that the latest-loaded package takes precedence on the search path, so if you do library(lme4) first and then library(lme4.0) next, the lmer command will use the lme4.0 package. Regardless of search path order, you can specify a particular package’s version of a function with :: syntax, e.g., lme4::lmer and lme4.0::lmer.

The new lme4 is under active development, so hopefully it will soon be able to consistently produce models that are as good as those produced by lme4.0. Until then, I recommend comparing crucial models across both versions, and putting more trust in the model with the higher log likelihood or lower deviance. (For comparing linear models, note that the “REML criterion” in new lme4 model summaries corresponds to “REMLdev” in lme4.0, and lower is better. For comparing binomial models, note that higher is better for log likelihoods, and in the usual case that these are negative, higher means closer to zero.)

13 thoughts on “old and new lme4

    Ben Bolker said:
    March 18, 2014 at 10:23 am

    I would be very interested particularly in reports of divergence/bad model fits from the most recent version of lme4 (1.1-5), now that we have switched from Nelder-Mead to bobyqa as the default optimizer.

    Like

      klintonbicknell responded:
      March 18, 2014 at 12:57 pm

      Thanks, Ben! IIRC, I have seen the difference in results using the 1.1-x line, but I don’t think I’ve tried 1.1-5 yet. I’ll try to check that version soon, and put together a reproducible example to send your way in case the difference still exists.

      Like

    Emily Morgan said:
    May 5, 2014 at 9:11 pm

    Incidentally, if you’re on a Mac, you probably need to do Step 3 before Step 2.

    Liked by 1 person

    tiflo said:
    May 8, 2014 at 8:05 am

    Hi Ben, I’ll ping Klinton about this again. He just started his job at Northwestern and is probably a bit swamped.

    Like

    drew said:
    May 15, 2014 at 12:24 pm

    Totally blows up on MacOS X 10.9. For some reason it’s convinced that the Fortran libraries are in /usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2, but that’s not a directory that exists if you install the linked fortran (which is 4.2.3, not 4.8.2), but if you install 4.8.2 from the GCC wiki (https://gcc.gnu.org/wiki/GFortranBinaries) or via homebrew, that directory still doesn’t exist. I don’t know enough about R’s build system to persuade it to look in the right place. The best I can discern, it has the location of gfortran 4.8.2 on MacOS 10.8 (darwin13.0.0) hardcoded somewhere.

    Like

      Ben Bolker said:
      May 15, 2014 at 12:36 pm

      Where did you install from? Binary, or source … ?

      Like

      stevencarlislewalker said:
      May 15, 2014 at 12:50 pm

      FWIW it works for me on 10.9, both from source and from binary. However, I remember that after I updated to Mavericks it took some careful tweaking to get compilers working properly together. If I remember correctly, updating to a (possibly development) version of R, which was recent enough for Simon Urbanek to have had time to work his magic, was an important step … I think. What version of R are you using?

      Like

      tiflo said:
      June 5, 2014 at 12:32 pm

      Klinton Bicknell just sent me this fix and it worked for me (had the same problem). For some reason, R 3.1 on the mac tries to compile pointing to a library that doesn’t exist. I just figured out how to get things to work:

      In the file /Library/Frameworks/R.framework/Resources/etc/Makeconf

      find the line

      FLIBS = -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm

      and remove the -lquadmath

      Like

        Kingdom of Tides said:
        October 21, 2014 at 8:25 am

        Thank you very much for this, it worked!

        If anyone is as much of a beginner as I am, the way to open this file and edit it is to use the file.edit(“”) command in R.

        Like

    more on old and new lme4 « HLP/Jaeger lab blog said:
    June 24, 2014 at 12:19 pm

    […] is an update to my previous blog post, in which I observed that post-version-1.0 versions of the lme4 package yielded worse model fits […]

    Like

Questions? Thoughts?