[R-sig-ME] Follow up question testing three way interaction between two fixed effects and a random effect nested in a fixed

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Oct 31 10:59:19 CET 2014


Dear Eoin,

I would add the interaction of sex and PI to the fixed effects as well. You can keep Block:Line as grouping factor of the random effects.
M1<-lmer(Fitness ~ Sex * PI + Block + (0 + Sex * PI|Block:Line), noNAdata)
M2<-lmer(Fitness ~ Sex * PI + Block + (0 + Sex + PI|Block:Line), noNAdata)

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

Van: Eoin Duffy [mailto:eoinduffy0000 op googlemail.com]
Verzonden: donderdag 30 oktober 2014 16:55
Aan: ONKELINX, Thierry
CC: r-sig-mixed-models op r-project.org
Onderwerp: Follow up question testing three way interaction between two fixed effects and a random effect nested in a fixed

Dear Thierry

Thank you very much for your insightful reply. I was a bit unsure about specifying Block as a random effect so thanks for further clarifying that for me.

I have a follow up question about a similar, separate analysis if yourself or the mailing list have time to think about. I need to include an additional fixed factor (2 levels) which block (3 levels) is nested in which then has line (35 levels) nested in it.

So the background is. I am measuring male and female fitness in Drosophila (n=10/sex)  from 35 lines over three blocks (same line ID  during each block), all this was performed twice using different 'tester' flies from two different populations that were or were not infected with a parasite (i.e.parasite infection +/-: PI) in order to examine whether parasite infection deferentially affected intersexual fitness across lines.

So I'm primarily interested in the three way interaction between sex x line x parasite infection (PI), 'does intersexual fitness differ between lines if their fitness was measured using flies that were or were not infected with the parasite?'

My model looks like this, modifying from Thierry's suggested code below with PI (2 levels), Block (3 levels), Sex as fixed factors and line as a random factor nested within Block, nested with PI, which I think is right.

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

Which produces the below output

> anova(M1, M2)
refitting model(s) with ML (instead of REML)
Data: newdataWol
Models:
..1: Fitness ~ Sex + Block + WolInfection + (1 | WolInfection:Block:Line)
object: Fitness ~ Sex + Block + WolInfection + (0 + Sex | WolInfection:Block:Line)
       Df   AIC   BIC  logLik deviance  Chisq Chi Df Pr(>Chisq)
..1     6 11051 11089 -5519.6    11039
object  8 10986 11037 -5485.1    10970 69.012      2  1.033e-15 ***

My question is does it seem as through I have specified my models correctly in order to check the significance of the 3 way sex x line x parasite infection
interaction?

Any suggestions would be greatly appreciated.

Eoin



On Thu, Oct 30, 2014 at 10:10 AM, ONKELINX, Thierry <Thierry.ONKELINX op inbo.be> wrote:
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.




--
Eoin Duffy

PhD Researcher
Institute of Environmental Sciences
Jagiellonian University
Gronostajowa 7
30-387, Krakow
Poland
* * * * * * * * * * * * * 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