[R-sig-ME] implicit nesting

array chip arrayprofile at yahoo.com
Wed Jul 7 02:33:12 CEST 2010


Dear Dr. Bates,

I am learning lmer() from lme4 package. I came across your article "Fitting linear mixed models in R" in R News (vol5, May 2005). I have 2 questions:

1. one is about the implicit nesting in the section "Specifying levels" where you gave an example dataset "Pixel" from MEMSS package. You said "If we wish to fit a model with random effects for "side within dog" we must first create a dog/side factor as 
      > Pixel$DS <- wirth(Pixel, Dog:Side)[drop=TRUE]
". 
I still don't quite understand why we have to create a new factor variable like the above. What is wrong if we simply specify a model like this (it runs and produces results):
  > fm <- lmer(pixel~day + (day|Side) + (day|Dog), Pixel)


2. the 2nd question is about the example you gave in the section "Nested and non-nested grouping factors" where you considered the dataset "star" from mlmRev package. In this example, the model specification is:
   > fm4 <- lmer(math ~ gr + sx + eth + cltype + (yrs | id) + (yrs | sch), star)

In this model, you didn't include "yrs" as a fixed effect. The how should we explain the random slope? When "yrs" is included as a fixed effect in the model, we can explain random slope as a random slope around a fixed common slope. But if "yrs" is not included as a fixed effect, does that mean the random slope is around a common fixed slope of 0?

Actually, I tried to add "yrs" as a fixed effect:
   > fm4 <- lmer(math ~ gr + sx + eth + cltype + yrs + (yrs | id) + (yrs | sch), star)
But I got an error message "Error in mer_finalize(ans) : Downdated X'X is not positive definite, 13.", why is that?

Thank you very much!

John








----- Original Message ----
From: Douglas Bates <bates at stat.wisc.edu>
To: adik at ilovebacon.org
Cc: r-sig-mixed-models at r-project.org
Sent: Mon, July 5, 2010 8:19:09 AM
Subject: Re: [R-sig-ME] lmer verbose output and random effects tables confusion

On Sun, Jul 4, 2010 at 3:11 PM, Adam D. I. Kramer <adik at ilovebacon.org> wrote:
> Hello,
>
>        For my own edification, could someone explain the relationship
> between the output of "verbose-mode" model fitting in lmer and the lmer
> object output?  I had been led to believe that the last line of the verbose
> output would be the random effects table (and then for nonlinear models, the
> fixed effects would follow), but when I fit this (rather complicated) model:
>
> lmer(formula = rating ~ rvalue + m:option.1000 + m:option2 + m + (1 +
> rvalue + m:option.1000 + m:option2 + m | studyID),
> data=cc2[as.logical(cc2$chosen),], verbose=TRUE, control=list(maxIter=10000,
> maxFN=10000))
>
> ...I get this output:
>
> (...8895 rows of output...)
> 8896:     1231.8223:  3.75608 0.0485706 0.381782  0.00000 0.141926  0.00000
> 0.0226706 -0.0359946 -0.192479  6.02644  5.82712 -10.4730 -6.48680 -30.9794
> 47.8011 -2.39961  9.36467  108.544  10.9610 -94.6165 -51.5401  124.184
> -41.8534 -48.6679  42.8230  2.19496 -1.26584  16.5468
>
> ...and this random effects table:
>
> Random effects:
>  Groups   Name           Variance   Std.Dev.  Corr
>  studyID  (Intercept)    6.5123e+00  2.551915
>          rvalue         9.5263e-03  0.097603 -0.941
>          ml             1.3536e+00  1.163462 -0.422  0.100
>          mh:option.1000 2.4708e+02 15.718900  0.978 -0.887 -0.461
>          ml:option.1000 8.2346e+02 28.696035  0.518 -0.489 -0.407  0.352
>          mh:option2     8.9316e+02 29.885807 -0.894  0.845  0.269 -0.955
>          ml:option2     1.3245e+03 36.393087 -0.455  0.461  0.303 -0.275
>  Residual                4.6160e-01  0.679410
>
> ...they do not correspond. Or do they? What might I be missing here? (I note
> that the deviance is reported correctly). Some of the numbers are close, but
> others are way off (for example, the zeroes in the verbose output show no
> corresponding zeroes here). What's up? How should I read this verbose
> output? Fixed effects follow, but also do not correspond:
>
> Fixed effects:
>              Estimate Std. Error t value
> (Intercept) 18.4601702  0.6169761  29.920
> rating       0.4912713  0.0956698   5.135
> ml          -8.6768828  0.3568779 -24.313
> mh:option    0.1097410  0.0371654   2.953
> ml:option    0.0899163  0.0245243   3.666
> mh:option2  -0.0012794  0.0004101  -3.120
> ml:option2  -0.0010715  0.0002906  -3.688
>
> Correlation of Fixed Effects:
>           (Intr) rating ml     mh:ptn ml:ptn mh:pt2
> rating     -0.934
> ml         -0.521  0.340
> mh:option  -0.207  0.022  0.337
> ml:option  -0.003  0.023 -0.530 -0.007
> mh:option2  0.096  0.075 -0.258 -0.924  0.017
> ml:option2 -0.098  0.090  0.459  0.092 -0.882 -0.024
>
> ...I note also that this is important for the user level because testing
> shows
> that when the user provides start values (via start=...), the verbose output
> starts out with the start values verbatim.

Which version of the lme4 package?

In all versions the parameters over which the optimization in lmer
takes place are those that determine the relative covariance factor
for the random effects.  I usually write these as theta.
In the case of a scalar random effects term the theta parameter
corresponds to the ratio of the standard deviation of the random
effect to the standard deviation of the residual noise term.  For a
vector-valued random effects the mapping from a collection of theta
parameters to the relative covariance factor depends on the version of
the lme4 package.  I think this version is still using the ST
formulation, in which case those 0's in the parameter vector at
convergence indicate convergence to a singular variance-covariance
matrix.

_______________________________________________
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