[R] lmer: random factor nested in a fixed factor
Hank Stevens
HStevens at MUOhio.edu
Tue Oct 7 15:03:32 CEST 2008
hi folks,
I believe that the construction
y ~ A + (A|B)
(where A is a categorical variable for a fixed effect and
B is a categorical variable for a random effect) will generate random
effects for all of the fixed effect coefficients. That is, in addition
fitted a systematic fixed effect coefficient for intercept and
relevant added effects of levels of A, it will fit corresponding
random coefficients for each level of B, including random intercepts,
and relevant added random effects of A, given B (i.e. for each
separate B).
Thus if you think that each family has, in addition to a different
overall mean, also has a different response to levels of A (and you
have the replication to estimate them), then you should include (A|B)
and see if it is better than simply (1|B).
Hank
On Oct 6, 2008, at 11:02 AM, Christian Ritz wrote:
> Dear Agnes,
>
> I think your model specification should look like this:
>
> YourModel1 <- lmerlmer(y ~ poptype*matingtype + (1|poptype:pop) + (1|
> poptype:fam),
> data = ...)
>
>
> The "1" in front of "|" refers to models that are random intercepts
> models as opposed to
> general random coefficients models in which case "1" would need to
> be replaced by a
> variable that is quantitative. So, the "(poptype|/pop/fam)"
> construction is definitely not
> relevant to your problem, unless "poptype" is a quantitative
> variable...
>
> The combined factor "poptype:pop" corresponds to the factor pop, but
> taking the nesting
> structure into account. Similar for the construction "poptype:fam".
>
>> From the summary output of the lmer() fit you should be able to
>> check whether or not the
> correct number of groups are used for these random factors.
>
> Kind regards
> Christian
>
> ______________________________________________
> R-help at 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.
Dr. Hank Stevens, Associate Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056
Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/
http://www.cas.muohio.edu/ecology
http://www.muohio.edu/botany/
"If the stars should appear one night in a thousand years, how would men
believe and adore." -Ralph Waldo Emerson, writer and philosopher
(1803-1882)
More information about the R-help
mailing list