I know that one of the advantages of mixed models is that they allow to specify variance-covariance matrix for the data (compound symmetry, autoregressive, unstructured, etc.) However, lmer function in R does not allow for easy specification of this matrix. Does anyone know what structure lmer uses by default and why there is no way to easily specify it?
- 31,547
- 2
- 92
- 179
- 713
- 2
- 7
- 8
3 Answers
Mixed models are (generalized versions of) variance components models. You write down the fixed effects part, add error terms that may be common for some groups of observations, add link function if needed, and put this into a likelihood maximizer.
The various variance structures you are describing, however, are the working correlation models for the generalized estimating equations, which trade off some of the flexibility of the mixed/multilevel models for robustness of inference. With GEEs, you are only interested in conducting inference on the fixed part, and you are OK with not estimating the variance components, as you would in a mixed model. For these fixed effects, you get a robust/sandwich estimate that is appropriate even when your correlation structure is misspecfieid. Inference for the mixed model will break down if the model is misspecified, though.
So while having a lot in common (a multilevel structure and ability to address residual correlations), mixed models and GEEs are still somewhat distinct procedures. The R package that deals with GEEs is appropriately called gee, and in the list of possible values of corstr option you will find the structures you mentioned.
From the point of view of GEEs, lmer works with exchangeable correlations... at least when the model has two levels of hierarchy, and only random intercepts are specified.
- 31,547
- 2
- 92
- 179
The FlexLamba branch of lmer provides such a functionality.
See https://github.com/lme4/lme4/issues/224 for examples how to implement a specific structure of errors or random effects.
- 1,032
-
1Can I have both the regular and FlexLambda branches installed at once?. How? – skan Sep 19 '15 at 12:30
To my knowledge lmer is not having an "easy" way to address this. Also given that in most cases lmer makes heavy use of sparse matrices for Cholesky factorization I would find it unlikely that it allows for totally unstructured VCV's.
To your address your question on "default structure": there is not a concept of default; depending on how you define your structure, you use that structure. Eg. using random effects like : $(1|RandEff_1)+(1|RandEff_2)$ where each random effect has 3 levels will result in unnested and independent random effects and a diagonal random effects VCV matrix of the form:
$R = \begin{bmatrix} \sigma_{RE1}^2 & 0& 0 & & 0 & 0 & 0\\ 0 & \sigma_{RE1}^2& 0 & & 0 & 0 & 0\\ 0 & 0& \sigma_{RE1}^2 & & 0 & 0 & 0\\ 0& 0& 0 & & \sigma_{RE2}^2 & 0 & 0 \\ 0 & 0& 0 & & 0 & \sigma_{RE2}^2 & 0\\ 0& 0& 0 & & 0& 0 & \sigma_{RE2}^2 \\\end{bmatrix}$
All is not lost with LME's though: You can specify these VCV matrix attributes "easily" is you are using the R-package MCMCglmm. Look at the CourseNotes.pdf, p.70. In that page it does give some analogues on how lme4 random effects structure would be defined but as you'll see yourself, lmer is less flexible than MCMCglmm in this matter.
Half-way there is problem nlme's lme corStruct classes, eg. corCompSymm, corAR1, etc. etc. Fabian's response in this tread gives some more concise examples for lme4-based VCV specification but as mentioned before they are not as explictly as those in MCMCglmm or nlme.
-
I don't "trust" MCMCglmm, because of the naive choice of prior distributions. – Stéphane Laurent Feb 12 '13 at 09:38
-
A. I don't think it is "naive"; they can reflect valid assumptions. You can even define improper priors if you feel that strongly for something. B. That was only part of my answer, it didn't say it is the only way to go; I gave example for lme4. C. If you need to do multivariate mixed effects it is practically the only available package along with sabreR... – usεr11852 Feb 12 '13 at 13:41
-
Sorry, my comment was not a criticism about your answer. When saying "naive priors", I talked about the noninformative priors. – Stéphane Laurent Feb 12 '13 at 14:28
-
It does not seem likely that this R matrix is right. Even the "classical" repeated-measures ANOVA allows for non-zero correlations between the conditions (I'm thinking of the compound symmetry matrix). Seems to me that this matrix would only be valid for a between-subject design with random assignment with two clusters. – Nikita Kuznetsov Feb 12 '13 at 21:58
-
The matrix is "right"; given that I indeed defined two clusters as: $(1|RandEff_1)+(1|RandEff_2)$, it makes sense. Clearly it encodes no compound symmetry in the dynamics of the variance. – usεr11852 Feb 13 '13 at 08:48
-
mixedcommand indeed allows exchangeable, unstructured and independent structures (not the autoregressive one though for which you need to make additional assumptions that your units are observed at the regular time intervals). Won't vouch for SAS or R though as I don't know them as thoroughly. Let me see if I can edit my response to make my points clearer. – StasK Jan 19 '16 at 22:53