[R-sig-ME] syntax for nested random factors in lme
Jake Westfall
jake987722 at hotmail.com
Tue Feb 9 19:13:21 CET 2016
Kathleen,
In R formulae, the "B/A" syntax gets expanded to "B + A:B" -- in other words, effects are estimated for the Bs and for the As-within-Bs. But since you already have B in the fixed part of the model, this means your model is trying to estimate both fixed and random effects of B, which is certainly the problem. Try replacing "B/A" with "A:B" and see if that works better.
Jake
________________________________________
From: R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> on behalf of Kathleen Côté <kathleen.cote at gmail.com>
Sent: Monday, February 8, 2016 5:00 PM
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] syntax for nested random factors in lme
Hi,
I've been taught that if I want to nest random factor A into B in an lme
model, the syntax is as follows: lme(y~x+B,random=~1|B/A). This seems to be
confirmed by the information contained in the Introduction to R manual
found here: https://cran.r-project.org/doc/manuals/R-intro.pdf.
In the case of my data, matters seem to be complicated by the fact that B
is a categorical variable with only 2 levels. When I run the lme with the
above syntax, I obtain an NaN p value for B as a fixed factor in the
model. When
I rewrite the random factor as random=~1|A/B, I obtain a p value.
Is the correct format for a nested random factor indeed B/A in this case
(i.e. nesting A into B)? Is it incorrect to write it as A/B?
Additionally, some sources of information I've come across suggest that
having B as a stand-alone fixed factor as well as part of a random factor
is nonsensical. Other people have suggested that it's acceptable as long as
that same factor is part of a nested random factor and not as a stand-alone
random factor, e.g. as I have it in my model, lme(y~x+B,random=~1|B/A). Are
you able to comment on this or confirm whether my model is acceptable?
Thank you,
Kathleen
[[alternative HTML version deleted]]
_______________________________________________
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