



   I'm not an expert, but I am working with nested random effects as 
well. It sounds to me that the term C is redundant. B being different 
locations in each country, if you include it as a random effect, it's 
obvious that each location is different from the others, so you don't 
need any other way of coding them as the software will already detect 
all the possible differences between them. 



   In "lmer", the way of writing the random effects temm would be:



   +(1|A/B)



   OR



   +(A|B)



   I'm not sure about the second way, but I've tried both ways and I get the same results, so I guess it's valid as well. 



   Other than that, if you are assuming Gaussian errors (this is, if you
 don't need to change the "family" term), I strongly recommend you use 
"lme" (from package "nlme") rather than "lmer", and switch to "lmer" 
only if you find some problem with "lme". The reason for that is that 
"lmer" is a newer function, so it's more likely to find bugs and 
problems as we can say it's still somehow in an "experimental" phase, if
 you know what I mean. It's not so probable that you find this kind of 
problems with "lme", a more set and known function (as it was developed 
before).



   I insist I'm not an expert, so let's see what the rest of the list members think.



   Note that the syntax for the random effects using "lme" is different:



   ", random=~1|A/B" 

--- El mié, 19/1/11, DUYME Florent <F.DUYME@arvalisinstitutduvegetal.fr> escribió:

De: DUYME Florent <F.DUYME@arvalisinstitutduvegetal.fr>
Asunto: [R-sig-ME] nested factor
Para: "'r-sig-mixed-models@r-project.org'" <r-sig-mixed-models@r-project.org>
Fecha: miércoles, 19 de enero, 2011 18:27

Hi,



I would like to include a nested factor in a mixed model (using lmer):



The data:

my_data<-structure(list(Y = c(4L, 6L, 8L, 2L, 4L, 5L, 7L, 8L, 9L, 4L,

5L, 6L, 3L, 8L, 3L, 6L, 6L, 7L, 8L, 10L, 11L, 15L, 9L, 13L),

    A = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,

    2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("a",

    "b", "c"), class = "factor"), B = structure(c(1L, 2L, 3L,

    4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L,

    3L, 4L, 5L, 6L, 7L, 8L), .Label = c("b1", "b2", "b3", "b4",

    "b5", "b6", "b7", "b8"), class = "factor"), C = structure(c(1L,

    12L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 2L, 3L, 4L, 5L, 6L,

    7L, 8L, 9L, 10L, 11L, 13L, 14L, 15L, 16L, 17L), .Label = c("c1",

    "c10", "c11", "c12", "c13", "c14", "c15", "c16", "c17", "c18",

    "c19", "c2", "c20", "c21", "c22", "c23", "c24", "c3", "c4",

    "c5", "c6", "c7", "c8", "c9"), class = "factor"), fact = structure(c(1L,

    1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L,

    1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L), .Label = c("f1", "f2"), class = "factor")), .Names = c("Y",

"A", "B", "C", "fact"), class = "data.frame", row.names = c(NA,

-24L))



A =  countries

B = locations in each country (b1 = 1st location , b2 = 2nd location, ...); that factor is nested within A

C = other way for coding the locations (as each location is different form each others)

fact = qualitative fixed factor



the model :

res_mm<-lmer(Y~fact+(1|C%in%A),my_data)



the results:

ranef(res_mm) gives



$`C %in% A`

       (Intercept)

FALSE 5.211116e-15



and ranef(lmer(Y~fact+(1|B%in%A),my_data)) gives



$`B %in% A`

       (Intercept)

FALSE 5.211116e-15





I don't understand the "FALSE" in the result. Is there something wrong with the coding or in the model ?



Thanks



florent








    [[alternative HTML version deleted]]

_______________________________________________
R-sig-mixed-models@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



      
	[[alternative HTML version deleted]]


