Re: [R] lmer: random factor nested in a fixed factor

2008-10-07 Thread Hank Stevens

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@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)


__
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] lmer: random factor nested in a fixed factor

2008-10-06 Thread Marie-Agnes Coutellec

Hi all,

I try to build a model using lmer, with 2 crossed fixed factors (poptype 
and matingtype) and 2 random factors (pop and family) which I want to 
nest within poptype. Which of these formulae should I use ?

1. lmer(y~poptype*matingtype + (1|poptype/pop/fam))
2. lmer(y~poptype*matingtype + (poptype|/pop/fam))

thanks in advance
Agnes

--

Marie-Agnès Coutellec
UMR INRA-Agrocampus Ouest 985 ESE
Equipe Ecotoxicologie et Qualité des Milieux Aquatiques
65 rue de Saint-Brieuc - CS 84215
35042 Rennes cedex - FRANCE

tél.: +33(0)2 23 48 52 48
fax:  +33(0)2 23 48 54 40

__
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.


Re: [R] lmer: random factor nested in a fixed factor

2008-10-06 Thread Christian Ritz
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@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.