[R] correctness of a formula in lme (from package nlme)

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Wed Oct 27 16:21:49 CEST 2010


Hello!
This is a sanity check based on my inexperience with mixed effects
models - I'd like to make sure the formula I wrote is correct for what
I am trying to do:

In my data set "MyData", I have a response variable (DV), 8 numeric
predictors (a through h) and a factor "group" with several levels.
I'd like to run a mixed effects regression such that:
for a, b, c, and d - only fixed effects are estimated
for the intercept, for e, f, g, and h - both fixed and random effects
(given group) are estimated - because I suspect that the intercept and
the regression coefficients of predictors e, f, g, and h vary by
group.

Is the formula I wrote correct or am I doing it wrong?

my.model <- lme(DV ~a+b+c+d+e+f+g+h, random = random = ~ e+f+g+h
|group, data = MyData)


Thanks a lot for confirming!

Example:

library(nlme)
data(Orthodont)
fm1 <- lme(distance ~ age+Sex, Orthodont, random = ~ age + Sex| Subject)
summary(fm1)
ranef(fm1)

When I run it like this I do get fixed effects in summary(my.model)
and I do get random coefficients by group (in my example - by Subject)
in ranef(fm1). I just want to make sure it's what I want.
Thanks a lot!


-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com



More information about the R-help mailing list