Skip to content
Prev 77497 / 398502 Next

How to mimic pdMat of lme under lmer?

On 9/19/05, Joris De Wolf <joris.dewolf at cropdesign.com> wrote:
You need to generate the two columns of the indicator matrix for F as
separate model matrices.  This will involve some awkward construction
like
Linear mixed-effects model fit by REML
Formula: s ~ F + (F | R)
   Data: DS
      AIC      BIC    logLik MLdeviance REMLdeviance
 20.69259 23.60203 -4.346297    6.03915     8.692593
Random effects:
 Groups   Name        Variance Std.Dev. Corr
 R        (Intercept) 0.108796 0.32984
          F2          0.102008 0.31939  -0.014
 Residual             0.048525 0.22028
# of obs: 12, groups: R, 3

Fixed effects:
            Estimate Std. Error DF  t value  Pr(>|t|)
(Intercept)  50.9483     0.2106 10 241.9188 < 2.2e-16
F2            1.0083     0.2240 10   4.5014  0.001141
Linear mixed-effects model fit by REML
Formula: s ~ F + (0 + as.numeric(F == 1) | R) + (0 + as.numeric(F ==
2) |      R)
   Data: DS
      AIC      BIC    logLik MLdeviance REMLdeviance
 19.62621 22.05075 -4.813107   7.439584     9.626215
Random effects:
 Groups   Name               Variance Std.Dev.
 R        as.numeric(F == 1) 0.108796 0.32984
 R        as.numeric(F == 2) 0.207896 0.45596
 Residual                    0.048525 0.22028
# of obs: 12, groups: R, 3; R, 3

Fixed effects:
            Estimate Std. Error DF  t value Pr(>|t|)
(Intercept) 50.94833    0.21060 10 241.9188  < 2e-16
F2           1.00833    0.34891 10   2.8899  0.01611

There are probably more elegant ways of doing this but I don't think
there is any really clean way.  If you want to assume that all the
variances are equal then you can estimate the model using an
interaction.
Linear mixed-effects model fit by REML
Formula: s ~ F + (1 | F:R)
   Data: DS
      AIC     BIC    logLik MLdeviance REMLdeviance
 17.77917 19.7188 -4.889587   7.669022     9.779175
Random effects:
 Groups   Name        Variance Std.Dev.
 F:R      (Intercept) 0.158346 0.39793
 Residual             0.048525 0.22028
# of obs: 12, groups: F:R, 6

Fixed effects:
            Estimate Std. Error DF  t value Pr(>|t|)
(Intercept) 50.94833    0.24672 10 206.5049  < 2e-16
F2           1.00833    0.34891 10   2.8899  0.01611