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 FitnessCured
2 1 2 M 1.4573 0.2215
3 1 2 M 1.1551 1.1379
4 1 2 M 1.4573 1.1379
7 1 2 M 1.4573 0.4108
9 1 2 M -1.5648 1.1379
11 1 2 F -0.2669 -1.2473
12 1 2 F 0.2785 -1.2473
13 1 2 F -0.5396 -1.2473
14 1 2 F -0.5396 0.4602
15 1 2 F 1.8237 -1.2473
16 1 2 F 0.7330 0.4965
17 1 2 F 1.5511 -1.2473
18 1 2 F -0.5396 1.4774
19 1 2 F 1.0966 1.1868
20 1 2 F -0.5396 -1.2473
21 1 3 M 1.2054 0.7162
22 1 3 M 1.2585 0.3146
24 1 3 M -1.5648 0.2672
26 1 3 M -0.8932 -0.8615
27 1 3 M 0.5047 1.1379
28 1 3 M 0.7704 1.1379
29 1 3 M -1.5648 -1.7689
31 1 3 F -0.5396 0.6782
32 1 3 F -0.5396 -1.2473
33 1 3 F -0.5396 1.0778
34 1 3 F -0.5396 -1.2473
35 1 3 F -0.5396 -1.2473
36 1 3 F -0.5396 0.7145
37 1 3 F -0.5396 0.7508