[R-sig-ME] Testing interaction between fixed effect and random effect nested within another random effect

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Oct 30 10:10:34 CET 2014


Dear Eoin,

Much depends on how you code Line. If Each line has a unique code, thus each line ID occurs in only one block, then (1|Sex:Block:Line) is equal to (1|Sex:Line). If you have a crossed design and you reuse line ID among block (a line ID can occur in more than one block), then (1|Sex:Block:Line) is different from (1|Sex:Line). (1|Sex:Block:Line) is the most explicit way to write it and it does not depends on the coding of line ID.

A few more things:
- Although block is random from a philosophical standpoint, it is better to use it as a fixed effect because it has only 3 levels. More details on http://glmm.wikidot.com/faq
- I'd rather look at (0 + Sex|Line) than (1|Line:Sex). (0 + Sex|Line) allows for a different variance in line effect between male and female, and a correlation between male and female within the line

M1 <- lmer(FitnessCured ~ Sex + Block + (0 + Sex|Block:Line), noNAdata)
M2 <- lmer(FitnessCured ~ Sex + Block + (1|Block:Line), noNAdata)
anova(M1, M2)

Best regards,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-sig-mixed-models-bounces op r-project.org [mailto:r-sig-mixed-models-bounces op r-project.org] Namens Eoin Duffy
Verzonden: dinsdag 28 oktober 2014 22:14
Aan: r-sig-mixed-models op r-project.org
Onderwerp: [R-sig-ME] Testing interaction between fixed effect and random effect nested within another random effect

Hello mixed model list


I am working on a mixed model using lmer in R and I am a bit stuck on some coding. I have measured male and female fitness in Drosophila from 35 inbred lines (genotype) over three blocks.

My response variable is 'fitness' with n=10 individuals/sex/line/block tested.

Sex is fixed, Block is random and Line nested within block is random. I primarily interested in the interaction between sex and line. Therefore my model looks like

m1<-lmer(FitnessCured~Sex+(1|Block/Line)+(1|Block)+(1|Sex:Line),noNAdata)

If I wanted to tested the significance of the Sex:Line interaction my plan is to just compare the above model to a model without the interaction and use anova to compare the two models

e.g. m2<-lmer(FitnessCured~Sex+(1|Block/Line)+(1|Block),noNAdata)
anova(m1,m2)

However what I am wondering is if I am testing the significance of the Sex:Line interaction (included as a random effect) will R know Line is nested within Block ???

How do I specify the interaction between Sex by Line nested within Block ??

Should it be something like

 m1T<-lmer(FitnessCured~Sex+(1|Block/Line)+(1|Block)+(1|Sex:Block:Line)

Any thoughts would be appreciated. I have included a sample of my data below

     Block Line Sex FitnessInfected FitnessCured2        1    2   M
      1.4573       0.22153        1    2   M          1.1551
1.13794        1    2   M          1.4573       1.13797        1    2
 M          1.4573       0.41089        1    2   M         -1.5648
  1.137911       1    2   F         -0.2669      -1.247312       1
2   F          0.2785      -1.247313       1    2   F         -0.5396
    -1.247314       1    2   F         -0.5396       0.460215       1
  2   F          1.8237      -1.247316       1    2   F
0.7330       0.496517       1    2   F          1.5511      -1.247318
     1    2   F         -0.5396       1.477419       1    2   F
  1.0966       1.186820       1    2   F         -0.5396
-1.247321       1    3   M          1.2054       0.716222       1    3
  M          1.2585       0.314624       1    3   M         -1.5648
   0.267226       1    3   M         -0.8932      -0.861527       1
3   M          0.5047       1.137928       1    3   M          0.7704
     1.137929       1    3   M         -1.5648      -1.768931       1
  3   F         -0.5396       0.678232       1    3   F
-0.5396      -1.247333       1    3   F         -0.5396       1.077834
      1    3   F         -0.5396      -1.247335       1    3   F
  -0.5396      -1.247336       1    3   F         -0.5396
0.714537       1    3   F         -0.5396       0.7508

--
Eoin Duffy

PhD Researcher
Institute of Environmental Sciences
Jagiellonian University
Gronostajowa 7
30-387, Krakow
Poland

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-mixed-models op r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.



More information about the R-sig-mixed-models mailing list