[R-sig-ME] autocorrelated errors

Steve Walker steve.walker at utoronto.ca
Wed Aug 6 18:19:10 CEST 2014


Hi Paul,

tl;dr  There is some work in this direction, but unfortunately it is 
still somewhat experimental.

1. It is currently not possible to fit models with correlated residuals, 
per se, in lme4.  This is because the c++ machinery in lme4 only allows 
for observation weights (heterogeneous variance), not correlations.

2. Having said that, there is enough of this machinery exposed to fit 
models with flexible covariance structures in the random effects 
covariance matrix, if you are willing to write code for these 
structures.  There is currently no API on how to do this, although such 
an API is a long-term goal.

3. The flexLambda branch of lme4 on github is currently being developed 
specifically to facilitate the development of such flexible covariance 
structures.  It can be installed with:  install_github("lme4", user = 
"lme4", ref = "flexLambda").  However, this branch is not stable and 
should be considered experimental.

4. Fabian Scheipl has implemented AR1, compound symmetry, and diagonal 
structures in flexLambda (see 
https://github.com/lme4/lme4/blob/flexLambda/R/reGenerators.R).  Note 
however that there are no special functions for interpreting the output 
of such structures (e.g. plot, summary, etc...), and so unfortunately at 
this point you have to "know what you are doing".

5. All of these structures in flexLambda take place in the relative 
covariance factor for the random-effects, Lambda, and not in the 
residual variance, sigma^2.  One might be tempted to set the residual 
variance to zero, and handle residual variance in the relative 
covariance factor, Lambda.  Then one could construct a covariance 
structure that is effectively for the residuals, but using Lambda 
instead of sigma^2.  One challenge here is that lme4 machinery cannot 
handle models with zero residual variance (i.e. sigma^2 = 0) -- roughly 
because sigma^2 scales both the residual variance and the random-effects 
covariance matrix.  One may carefully set prior weights to get around 
this (https://github.com/lme4/lme4/issues/224#issuecomment-50510943), 
but this is somewhat hackish.

6. The modular approach to lmer and glmer may also be useful, if you 
just want to hack some specific model fits.  See ?modular and the 
Appendix of the lmer preprint (http://arxiv.org/abs/1406.5823).  The 
main difference between the modular and flexLambda approaches is how the 
covariance parameters are mapped into Lambda (see the last paragraph on 
p. 20 of the preprint for more details).

Cheers,
Steve


On 2014-08-05, 7:23 PM, Paul Johnson wrote:
> Sorry to bother you, but
>
> I ask here every year or so if anybody is working on lme4 with time or
> spatially correlated random errors. Bring corStruct back to life?
>
> If nobody is, maybe we could start a project together? I'm getting
> great & fast estimates from lme4 with the cross sectional models, but
> to work on longitudinal panels, we need some AR(1) error terms, or
> such.
>
> pj
>



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