The first exaample on the "lmer" help page uses a formula
"Reaction ~ Days + (Days|Subject)". Here, "Subject" is the name of a
column in the data.frame "sleepstudy", with levels "308", "309", ... .
Does this answer your question? If no, please provide commented,
minimal, self-contained, reproducible code, as requested in the posting
guide "http://www.R-project.org/posting-guide.html". Your example is
not "self-contained, reproducible".
Hope this helps.
Spencer
Leigh Ann Starcevich wrote:
Dear guRus:
I am using lmer for a mixed model that includes a random intercept for a
set of effects that have the same distribution, Normal(0, sig2b). This set
of effects is of variable size, so I am using an as.formula statement to
create the formula for lmer. For example, if the set of random effects has
dimension 8, then the lmer call is:
Zs<- paste("Z",1:mb,sep="")
Trendformula <-as.formula(paste("LogY ~ WYear + (1+WYear|Site) + (1|",
paste(paste(Zs,collapse="+"), ")")))
fit2.4a<-lmer(Trendformula, data = testsamp)
which, for mb=8, expands to:
fit1<-lmer(LogY ~ WYear + (1 | Site) + (1 | Year) + (1 | Z1+ Z2 + Z3 + Z4 +
Z5 + Z6 + Z7 + Z8), data = testsamp)
I have no problems with this. However, if the set of random effects has a
dimension of 30, then the lmer call is:
fit2<-lmer(LogY ~ WYear + (1 | Site) + (1 | Year) + (1 | Z1+Z2 + Z3 + Z4 +
Z5 + Z6 + Z7 + Z8 + Z9 + Z10 + Z11 + Z12 + Z13 + Z14 + Z15 + Z16 + Z17 +
Z18 + Z19 + Z20 + Z21 + Z22 + Z23 + Z24 + Z25 + Z26 + Z27 + Z28 + Z29+
Z30), data = testsamp)
In this case, I get an error because the name "Z1+Z2 + Z3 + Z4 + Z5 + Z6 +
Z7 + Z8 + Z9 + Z10 + Z11 + Z12 + Z13 + Z14 + Z15 + Z16 + Z17 + Z18 + Z19 +
Z20 + Z21 + Z22 + Z23 + Z24 + Z25 + Z26 + Z27 + Z28 + Z29+ Z30" is too long
to print in the output. Is there any way to name the random effect in
lmer so that the shorter (and more descriptive) name may be used and the
error avoided? Or is there a way to combine these into a single variable
prior to the lmer function call? In SAS, I am able to parameterize these
as a Toeplitz structure with bandwidth 1.
Thanks for any help.
Leigh Ann Starcevich
Doctoral student
Oregon State University
Corvallis, Oregon
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.