[R-sig-ME] More naive questions: Speed comparisons? what is a"stack imbalance" in lmer? does lmer center variables?

Doran, Harold HDoran at air.org
Wed Sep 23 18:12:25 CEST 2009

> 1.  One general question for general discussion:
> Is HLM6 faster than lmer? If so, why?
> I'm always advocating R to students, but some faculty members 
> are skeptical.  A colleague compared the commercial HLM6 
> software to lmer.
>  HLM6 seems to fit the model in 1 second, but lmer takes 60 seconds.
> If you have HLM6 (I don't), can you tell me if you see 
> similar differences?

Whether or not this is true on the data used for the example is not too
interesting to me. What *is* interesting to me is that HLM cannot for
sure to handle large models with complex random effects. In other words,
you might find small toy examples where HLM is faster than the lmer
function. However, with large data sets and complex structures for the
marginal variance/covarianc matrix, HLM can't even compete. 

> My first thought was that LM6 uses PQL by default, and it 
> would be faster.  

You suspect that PQL would be faster than what? 

However, in the output, HLM6 says:
> Method of estimation: restricted maximum likelihood
> But that doesn't tell me what quadrature approach they use, does it?

I don't think we can answer your question in a meaningful way w/o you
providing more information. REML is also the default in lmer and it is
essentially like integrating out the fixed effects with a uniform prior.
But, are you estimating linear or generalized mixed models?

> Another explanation for the difference in time might be the 
> way HLM6 saves the results of some matrix calculations and 
> re-uses them behind the scenes.  If every call to lmer is 
> re-calculating some big matrix results, I suppose that could 
> explain it.

What matrices are saved at each iteration in HLM? I'm curious. Of
course, the model matrices don't change, but others do. 

> There are comparisons from 2006 here
> http://www.cmm.bristol.ac.uk/learning-training/multilevel-m-so

I looked very briefly at the materials on this link. They evaluate a
very old version of the mixed model functions in R (using R 1.5.1) and
we are now on R version 2.9.2. The older function, nlme, was a bit slow,
and I do recall it being slower than HLM (the software).

The nwer functions of lmer are very different than the days of old. I
think you will find, if you do some comparisons yourself, that the R
functions are extremely fast, and most likely I suspect would be faster
than HLM.

> that indicate that lme was much slower than HLM, but that 
> doesn't help me understand *why* there is a difference.
> 2. What does "stack imbalance in .Call" mean in lmer?
> Here's why I ask.  Searching for comparisons of lmer and HLM, 
>  I went to CRAN &  I checked this document:
> http://cran.r-project.org/web/packages/mlmRev/vignettes/MlmSoftRev.pdf
> I *think* these things are automatically generated.  The 
> version that's up there at this moment  (mlmRev edition 
> 0.99875-1)  has pages full of the error message:
> stack imbalance in .Call,
> Were those always there?  I don't think so.   What do they mean?
> 3. In the HLM6 output, there is a message at the end of the 
> variable list:
> '%' - This level-1 predictor has been centered around its grand mean.
> '$' - This level-2 predictor has been centered around its grand mean.
> What effect does that have on the estimates?  I believe it 
> should have no effect on the fixed effect slope estimates, 
> but it seems to me the estimates of the variances of random 
> parameters would be changed.  In order to make the estimates 
> from lmer as directly comparable as possible, should I 
> manually center all of the variables
> before fitting the model?   I'm a little stumped on how to center a
> multi-category factor before feeding it to lmer.  Know what I mean?

Centering will change some of the estimates. But, without providing more
details on what your model is, how your centering there is no way to
answer your question. For example, you say it won't affect slope. Slope
of what? 

> pj
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
> _______________________________________________
> R-sig-mixed-models at 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