[R-sig-ME] Trying to understand the syntax of lmer

Sorkin, John j@ork|n @end|ng |rom @om@um@ry|@nd@edu
Sat Sep 14 23:41:49 CEST 2019

I hope you will not mind my asking seven questions, questions designed to allow me to know if my basic understanding of lmer syntax is correct. Below I post code and in the comments 7 questions. 

Orthodont$nsex <- as.numeric(Orthodont$Sex=="Male")
Orthodont$nsexage <- with(Orthodont, nsex*age)

# (1) Is this a model with a random intercept in which, each subject has his, or her own intercept?
lmer(distance ~ age +(1|Subject),data=Orthodont)

# (2) Is this a model with a random slope, where age is the slope, each subject having their own slope?
lmer(distance ~ age + (0+age|Subject), data=Orthodont)

# (3) Is this a model with random intercept, Subject, and random slope age?
# (4) If it is, what is the assumed covariance structure between slope and intercept?
# (5) Is the covariance structure assumed to be unstructured?
# (6) How can I get the estimated covariance between intercept (subject) and slope (age)?
lmer(distance ~ age +(1|Subject)+(0+age|Subject), data=Orthodont)
# (7) The next two models, I believe have a random intercept (a sparate slope for each subject),
#     an age*sex interaction, a random slope (age) for each subject. Are my assumptions correct?
lmer(distance ~ age +Sex+nsexage+(1|Subject)+(0+age|Subject), data=Orthodont)
lmer(distance ~ age +Sex+Sex*age+(1|Subject)+(0+age|Subject), data=Orthodont)

Thank you for your patients with my eight questions.


John David Sorkin M.D., Ph.D.

Professor of Medicine

Chief, Biostatistics and Informatics

University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine

Baltimore VA Medical Center

10 North Greene Street


Baltimore, MD 21201-1524

(Phone) 410-605-7119

(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

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