[R-sig-ME] lmer specification for random effects with several within-subject factors

Gabriel Baud-Bovy baud-bovy.gabriel at hsr.it
Mon Oct 7 23:03:40 CEST 2013


Hi,

In my previous post lmer specification for maximal random effects 
structure and one-between and two within-subject factors), I had 
actually two quite different questions, which is not a very good idea. 
Thanks to Tobias, I got an answer to my first question. To restate the 
second question, I'll use  a repeated-measure design with two crossed 
within subject factors (A: 3 levels and B:2 levels) and replications as  
an imaginery example. I assume that A and B are coded with sum contrasts.

I found many instances where one is told to use (1|S) +  (0+A|S) or 
(1|S) + (A-1|S) to simplify the correlation structure (I have done it 
myself) but I am not actually sure to fully understand what is 
happening.  More precisely, while the random effects specified by the 
formula (A*B|S) yields the results that I intuitively expected, I find 
the results obtained with (1|S) + (A-1|S)  + (B-1|S)  + (A:B-1|S) or 
(1|S) + (A-1|S)  + (B-1|S)  + (A:B-1|S) confusing. In these cases, I  am 
actually not sure how to interpet the random effects yielded by lmer.  
Also, the design matrix is redundant and this redundancy makes these 
models more difficult to fit, which is somewhat paradoxical since the 
intention is to simplify the correlation structure.

I think that I understand how the design matrix Z is produced (i.e., by 
binding together the terms that are specifed between parenthesis)  even 
though
there are some cases  where I am not sure because the results for fixed 
and random effects are different (see the example with the interaction 
below).

My question is whether the design matrix  Z specified by these formulae 
make sense in this context and how to interpret the results if it does?

I could not find any discussion of these issues behond the simple case 
of  removing correlation betweenintercept and slope  of a continuous 
covariate.

As I said above, fitting a model maximal random effect structure with  
Y~A*B+(A*B|S) yields the expected variance-covariance matrix

Groups   Name        Std.Dev. Corr
  S        (Intercept) 1.90664
           A1          0.71938 0.710
           A2          0.63624  -1.000 -0.727
           B1          0.38072  -0.613 -0.992 0.632
           A1:B1       0.51257  -0.394 -0.927  0.416 0.968
           A2:B1       0.62905  -0.972 -0.855  0.978 0.781  0.598
  Residual             2.07002

The corresponding design matrix Z for one subject is

       (Intercept) A1 A2 B1 A1:B1 A2:B1
  [1,]           1  1  .  1     1     .
  [2,]           1  1  .  1     1     .
  [3,]           1  1  . -1    -1     .
  [4,]           1  1  . -1    -1     .
  [5,]           1  .  1  1     .     1
  [6,]           1  .  1  1     .     1
  [7,]           1  .  1 -1     .    -1
  [8,]           1  .  1 -1     .    -1
  [9,]           1 -1 -1  1    -1    -1
[10,]           1 -1 -1  1    -1    -1
[11,]           1 -1 -1 -1     1     1
[12,]           1 -1 -1 -1     1     1

where columns A1, A2 and B1 corresponds to the expected sum contrasts. 
This matrix is the same as the design matrix for the fixed effects.

To  remove correlations between the intercept A, B and A:B interaction 
terms, I tried    Y~A*B+(1|S) + (A|S)  + (B|S)  + (A:B|S).

Groups   Name        Std.Dev. Corr
  S        (Intercept) 2.5421e-08
  S.1      (Intercept) 2.1751e-07
           A1          9.1658e-08 0.992
           A2          3.1944e-07 -0.991 -0.970
  S.2      (Intercept) 6.5355e-08
           B1          1.2692e-07 1.000
  S.3      (Intercept) 1.8430e+00
           A1:B1       1.8613e-01 0.828
           A2:B1       1.4158e+00 -0.959 -0.802
           A3:B1       7.9928e-01  0.957  0.901 -0.981
           A1:B2       1.8497e+00  0.433  0.457 -0.668 0.640
           A2:B2       7.5347e-01  0.252  0.347 -0.509 0.491  0.980
           A3:B2       6.7337e-01 -0.439 -0.353  0.674 -0.610 -0.981 -0.947
  Residual             2.0700e+00           1.8845e+00

I did not get the expected results. This removed correlation between the 
terms but also additional  (redundant) intercepts terms.  Moreover, the 
interaction terms includes not only an intercept but also every 
combination between the factor A and B. The design matrix is

       (Intercept) (Intercept) A1 A2 (Intercept) B1 (Intercept) A1:B1 
A2:B1 A3:B1 A1:B2 A2:B2 A3:B2
  [1,]           1           1  1  .           1 1           1     1     
.     .     .     .     .
  [2,]           1           1  1  .           1 1           1     1     
.     .     .     .     .
  [3,]           1           1  1  .           1 -1           1     
.     .     .     1     .     .
  [4,]           1           1  1  .           1 -1           1     
.     .     .     1     .     .
  [5,]           1           1  .  1           1 1           1     .     
1     .     .     .     .
  [6,]           1           1  .  1           1 1           1     .     
1     .     .     .     .
  [7,]           1           1  .  1           1 -1           1     
.     .     .     .     1     .
  [8,]           1           1  .  1           1 -1           1     
.     .     .     .     1     .
  [9,]           1           1 -1 -1           1 1           1     .     
.     1     .     .     .
[10,]           1           1 -1 -1           1 1           1     .     
.     1     .     .     .
[11,]           1           1 -1 -1           1 -1           1     .     
.     .     .     .     .
[12,]           1           1 -1 -1           1 -1           1     .     
.     .     .     .     .

Note that column A1, B2, B1 correspond to the contrasts. For the 
intercation term, a different coding (dummy variables)
is used and an intercept term is added (this is quite surprising since 
A:B for fixed effect yields a different matrix).

If this matrix makes sense, how should I interpret the variance estimate 
associated with the intercept? Should simply
consider the sum as the estimate of the between subject variability? Is 
the split between the different terms
well defined ?

To  remove intercepts, I tried    Y~A*B+(1|S) + (A-1|S)  + (B-1|S)  + 
(A:B-1|S).  This yields

  Groups   Name        Std.Dev.   Corr
  S        (Intercept) 3.2644e-07
  S.1      A1 0.0000e+00
           A2          1.0269e-07 0.992
           A3          2.6214e-07 -0.9920.366
  S.2      B1 0.0000e+00
           B2          5.2044e-08 0.992
  S.3      A1:B1 1.9998e+00
           A2:B1       6.2886e-01 0.768
           A3:B1       2.6180e+00 0.998 0.724
           A1:B2       3.1261e+00 0.850 0.316 0.883
           A2:B2       2.1594e+00 0.944 0.516 0.964 0.976
           A3:B2       1.6618e+00 0.930 0.949 0.904 0.598 0.758
  Residual             2.0700e+00

and
       (Intercept) A1 A2 A3 B1 B2 A1:B1 A2:B1 A3:B1 A1:B2 A2:B2 A3:B2
  [1,]           1  1  .  .  1  .     1     .     . .     .     .
  [2,]           1  1  .  .  1  .     1     .     . .     .     .
  [3,]           1  1  .  .  .  1     .     .     . 1     .     .
  [4,]           1  1  .  .  .  1     .     .     . 1     .     .
  [5,]           1  .  1  .  1  .     .     1     . .     .     .
  [6,]           1  .  1  .  1  .     .     1     . .     .     .
  [7,]           1  .  1  .  .  1     .     .     . .     1     .
  [8,]           1  .  1  .  .  1     .     .     . .     1     .
  [9,]           1  .  .  1  1  .     .     .     1 .     .     .
[10,]           1  .  .  1  1  .     .     .     1 .     .     .
[11,]           1  .  .  1  .  1     .     .     . .     .     1
[12,]           1  .  .  1  .  1     .     .     . .     .     1

The intercept are indeed removed but each factor is dummy coded. 
Contrasts are not used anymore. This matrix is still rank deficient
and this model is still more difficult to fit than the original (A*B|S) 
model.

To summarize, I find the random effects of lmer difficult to interpret 
when using the formula (1|S) + (A-1|S)  + (B-1|S)  + (A:B-1|S) or (1|S) 
+ (A|S)  + (B|S)  + (A:B|S) . Moreover, their redundancy make them more 
difficult to fit than the (A*B|S).

I expected that (1|S) + (A-1|S)  + (B-1|S)  + (A:B-1|S) would all yield 
random effect structure that correspond to the fixed effects like when 
using (A*B|S) (see above) with a correlation structure like

  Groups   Name        Std.Dev.   Corr
  S        (Intercept) 3.2644e-07
  S.1      A1 0.0000e+00
           A2          1.0269e-07 0.992
  S.2      B1 0.0000e+00
  S.3      A1:B1 1.9998e+00
           A2:B1       6.2886e-01 0.768
  Residual             2.0700e+00

I was not sure what I was expecting with   (A|S)  + (B|S)  + (A:B|S) but 
it would be nice if there was a way to specificy a covariance

Groups   Name        Std.Dev.   Corr
  S        (Intercept) 3.2644e-07
A1          1.0269e-07 0.992
           A2          2.6214e-07 -0.9920.366
  S.1 B1          5.2044e-08 0.992
  S.2    A1:B1       6.2886e-01 0.768
           A2:B1       2.6180e+00 0.998 0.724
Residual             2.0700e+00

This would allow one to specify correlated random effects between the 
subject intercept and the various conditions while excluding
correlated random effects between the conditions (this appear quite fare 
from what is possible to do with lmer syntax(.

Best,

Gabriel

-- 
---------------------------------------------------------------------
Gabriel Baud-Bovy               tel.: (+39) 02 2643 4839 (office)
UHSR University                       (+39) 02 2643 3429 (laboratory)
via Olgettina, 58                     (+39) 02 2643 4891 (secretary)
20132 Milan, Italy               fax: (+39) 02 2643 4892



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