Skip to content
Prev 17934 / 20628 Next

Trying to understand the syntax of lmer

On Sat, Sep 14, 2019 at 5:42 PM Sorkin, John <jsorkin at som.umaryland.edu> wrote:
Yes
Yes
I'm confused.  Are you referring to this model

(a) > lmer(distance ~ age +(1|Subject)+(0+age|Subject), data=Orthodont)

or

(b)  lmer(distance ~ age + (age|Subject), data=Orthodont)

  Both models allow varying intercepts and slopes among Subjects.
(a) intercept-slope covariance is constrained to 0
 (b) variance-covariance matrix is positive semi-definite (i.e., both
eigenvalues >=0).  Correlation can be any value between -1 and 1.
(a) No.
(b) Yes.
(a) it's constrained to be zero
 (b) VarCorr(fitted_model)$Subject[1,2]
Yes. In the second model, the fixed effect specification is slightly
redundant.
  distance ~ age*Sex + ... (or ~ Sex*age + ...) will include the main
effects as well as the interaction.
(questions about fixed-effect model specification are not specific to
mixed models, but follow R's general rules as implemented by
model.matrix() ...)

See:

  section 2.2 of Bates et all JSS paper [vignette("lmer",package="lme4")]
 and https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#model-specification
(and links therein:
http://www.rensenieuwenhuis.nl/r-sessions-16-multilevel-model-specification-lme4/
and https://rpsychologist.com/r-guide-longitudinal-lme-lmer)
Message-ID: <CABghstTi4SAkaCsP2hksLEPJ5mqiyRQtiRJSNsAox6DF_T_OdQ@mail.gmail.com>
In-Reply-To: <BN7PR03MB37305318FC2A8D8B8A3298B3E2B20@BN7PR03MB3730.namprd03.prod.outlook.com>