On 3/16/06, Leonardo D Bacigalupe <L.Bacigalupe at sheffield.ac.uk>
wrote:> Hello all,
>
> I have a question regarding how to specify a nested model with mixed
> factors in lme.
>
> If I have a nested design with 2 factors (A and B), with B nested
> within A and with y as the dep var, then,
> if both A and B are random the model should read y~1,random=~1|A/B.
>
> Now if factor A is fixed (and this is where i get confused) how should
> be the model:
>
> (1) y~A,random=~1|A/B (in this option A is also random and should be
> only fixed e.g. treatment)
> (2) y~A,random=~A|B (does the A|B define the nested structure?)
If I understand the situation correctly you want to use A:B as the
grouping factor. In the lmer function (which is loaded with
library(lme4)) this is specified by
lmer(y ~ A + (1|A:B))
In lme this would be specified as
lme(y ~ A, random = 1 | A:B)
At least I think that would work. I would need to try it to be
certain that the A:B would be evaluated at the correct time. I know
that it is evaluated at the correct time in lmer, which I would advise
using instead of lme.