Do male morphs effect offspring fitness?

The goal of this study is to explore how polyphenism can affect offspring fitness and mating decisions.

Q1: Sex Ratio/ Ratio of polyphenism

H1: Fighters = more sons, scramblers = more daughters

H2: Fighters = more fighters; scramblers = more scramblers

Q2: Longevity

H1: fighter males > scrambler males

H2: sons = positive correlation with fathers; daughters = negative correlation with fathers

Q3: Correlations of Longevity

H2: sons = positive correlation with fathers; daughters = negative correlation with fathers

H3: fighters = positive correlation with fighters, neg with scramblers; no difference with scrambler fathers

Q4: Daughter Fecundity

H1: father like = more fecundity; father un-like = less fecundity

Description

Male fathers of different morphs were observed for their fitness (longevity), and their offspring was observed for fitness (longevity, and daughter fecundity mated with either a father-like morph, or opposite).

Q1: Ratios between father morphs

Q1: Sex Ratio/ Ratio of polyphenism

Sex:

H1: Fighters = more sons, scramblers = more daughters

Sex Ratio between father morph

#sex ratio
#for plot
sex_prop <- prop_off %>%
  group_by(father_morph) %>%
  mutate(prop_male=male/total) %>%
  mutate(prop_female=female/total)

male <- ggplot(sex_prop, aes(father_morph,prop_male, fill=father_morph)) + geom_boxplot() + scale_fill_uchicago() + theme_classic() + ylim(0,1)

female <- ggplot(sex_prop, aes(father_morph, prop_female, fill=father_morph))+ geom_boxplot() + scale_fill_uchicago() + theme_classic()+ ylim(0,1)

ggarrange(male, female, labels=c("A", "B"))

#Did sex ratio differ between fighters and scramblers? 
sex_ratio_mod <- glmer(cbind(female,male)~father_morph + trial + (1|fatherID), family="binomial", data=prop_off)

summary(sex_ratio_mod)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cbind(female, male) ~ father_morph + trial + (1 | fatherID)
##    Data: prop_off
## 
##      AIC      BIC   logLik deviance df.resid 
##    194.0    201.4    -93.0    186.0       43 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.83538 -0.51961 -0.02429  0.59408  1.96508 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept) 0.1309   0.3618  
## Number of obs: 47, groups:  fatherID, 47
## 
## Fixed effects:
##                       Estimate Std. Error z value Pr(>|z|)  
## (Intercept)            0.55870    0.28910   1.933   0.0533 .
## father_morphscrambler -0.01875    0.21331  -0.088   0.9299  
## trial                 -0.19266    0.10308  -1.869   0.0616 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) fthr_m
## fthr_mrphsc -0.322       
## trial       -0.853 -0.058
emmeans(sex_ratio_mod, pairwise~father_morph, type="response")
## $emmeans
##  father_morph  prob     SE  df asymp.LCL asymp.UCL
##  fighter      0.520 0.0378 Inf     0.446     0.593
##  scrambler    0.515 0.0373 Inf     0.442     0.587
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the logit scale 
## 
## $contrasts
##  contrast            odds.ratio    SE  df null z.ratio p.value
##  fighter / scrambler       1.02 0.217 Inf    1   0.088  0.9299
## 
## Tests are performed on the log odds ratio scale
sex_ratio_mod_male <- glmer(cbind(male,female)~father_morph + trial + (1|fatherID), family="binomial", data=prop_off)
emmeans(sex_ratio_mod_male, pairwise~father_morph, type="response")
## $emmeans
##  father_morph  prob     SE  df asymp.LCL asymp.UCL
##  fighter      0.480 0.0378 Inf     0.407     0.554
##  scrambler    0.485 0.0373 Inf     0.413     0.558
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the logit scale 
## 
## $contrasts
##  contrast            odds.ratio    SE  df null z.ratio p.value
##  fighter / scrambler      0.981 0.209 Inf    1  -0.088  0.9299
## 
## Tests are performed on the log odds ratio scale

Morph ratios between father morphs

Morph:

H2: Fighters = more fighters; scramblers = more scramblers

#for plot
morph_prop <- prop_off %>%
  group_by(father_morph) %>%
  mutate(prop_fighter=fighter/male) %>%
  mutate(prop_scram=scrambler/male)

fighter <- ggplot(morph_prop, aes(father_morph,prop_fighter, fill=father_morph)) + geom_boxplot() + scale_fill_uchicago() + theme_classic() + ylim(0,1)

scrambler <- ggplot(morph_prop, aes(father_morph, prop_scram, fill=father_morph))+ geom_boxplot() + scale_fill_uchicago() + theme_classic()+ ylim(0,1)

ggarrange(fighter, scrambler, labels=c("A", "B"))

#Did fighter and scrambler males differ due to father morph?
male_ratio_mod <- glmer(cbind(scrambler,fighter)~father_morph + trial + (1|fatherID), family="binomial", data=prop_off)

summary(male_ratio_mod)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cbind(scrambler, fighter) ~ father_morph + trial + (1 | fatherID)
##    Data: prop_off
## 
##      AIC      BIC   logLik deviance df.resid 
##    165.5    172.9    -78.7    157.5       43 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.2535 -0.3459  0.1226  0.3739  1.4726 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept) 0.9726   0.9862  
## Number of obs: 47, groups:  fatherID, 47
## 
## Fixed effects:
##                       Estimate Std. Error z value Pr(>|z|)
## (Intercept)            -0.8279     0.6100  -1.357    0.175
## father_morphscrambler   0.2369     0.4214   0.562    0.574
## trial                   0.1725     0.2117   0.815    0.415
## 
## Correlation of Fixed Effects:
##             (Intr) fthr_m
## fthr_mrphsc -0.350       
## trial       -0.867 -0.009
emmeans(male_ratio_mod, ~father_morph, type="response")
##  father_morph  prob     SE  df asymp.LCL asymp.UCL
##  fighter      0.402 0.0731 Inf     0.270     0.549
##  scrambler    0.460 0.0729 Inf     0.324     0.602
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the logit scale
male_ratio_mod_fight <- glmer(cbind(fighter,scrambler)~father_morph + trial + (1|fatherID), family="binomial", data=prop_off)

emmeans(male_ratio_mod_fight, ~father_morph, type="response")
##  father_morph  prob     SE  df asymp.LCL asymp.UCL
##  fighter      0.598 0.0731 Inf     0.451     0.730
##  scrambler    0.540 0.0729 Inf     0.398     0.676
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the logit scale

Q2: Longevity of Fathers and Offspring

H1: fighter father > scrambler fathers

H2: females > males

Is father longevity different between morphs?

ggplot(father_fitness, aes(morph, longevity, fill=morph)) + geom_boxplot() + ylab("Father Longevity") + theme_classic2() + scale_fill_uchicago() + xlab("Father Morph") + theme(legend.position = "none")

#is longevity different between fighters and scramblers fathers?
fat.long <- lmer(longevity~morph + (1|trial), data=father_fitness)

summary(fat.long)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ morph + (1 | trial)
##    Data: father_fitness
## 
## REML criterion at convergence: 639.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.2865 -0.6564 -0.3783  0.5766  3.3706 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  trial    (Intercept)  462.4   21.50   
##  Residual             1223.4   34.98   
## Number of obs: 65, groups:  trial, 4
## 
## Fixed effects:
##                Estimate Std. Error     df t value Pr(>|t|)  
## (Intercept)      49.756     12.409  3.527   4.010   0.0205 *
## morphscrambler   -2.727      8.682 59.768  -0.314   0.7545  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## mrphscrmblr -0.342
emmeans(fat.long, pairwise~morph)
## $emmeans
##  morph     emmean   SE   df lower.CL upper.CL
##  fighter     49.8 12.4 3.83     14.7     84.8
##  scrambler   47.0 12.5 3.91     12.0     82.0
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast            estimate   SE df t.ratio p.value
##  fighter - scrambler     2.73 8.68 60   0.314  0.7545
## 
## Degrees-of-freedom method: kenward-roger

Does offspring longevity (between sexes) differ?

#between sexes
#singular error using trial as factor
offspring_long_sex <- lmer(longevity~sex*father_morph + (1|fatherID) + trial, contrast=list(sex=contr.sum, father_morph=contr.sum), data=full_long)
summary(offspring_long_sex)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ sex * father_morph + (1 | fatherID) + trial
##    Data: full_long
## 
## REML criterion at convergence: 2880.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.5124 -0.6763 -0.2311  0.4653  3.9477 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)  51.57    7.181  
##  Residual             493.98   22.226  
## Number of obs: 318, groups:  fatherID, 48
## 
## Fixed effects:
##                    Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)         47.2092     4.6455  48.1564  10.162 1.44e-13 ***
## sex1                -0.9320     1.4130 309.8701  -0.660   0.5100    
## father_morph1        0.7714     1.7376  52.1625   0.444   0.6589    
## trial               -2.7543     1.7138  47.4292  -1.607   0.1146    
## sex1:father_morph1   3.3143     1.3952 312.0760   2.375   0.0181 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) sex1   fthr_1 trial 
## sex1        -0.046                     
## fathr_mrph1 -0.012 -0.058              
## trial       -0.927  0.166  0.002       
## sx1:fthr_m1 -0.069 -0.051  0.291  0.050
Anova(offspring_long_sex, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
## 
## Response: longevity
##                     Chisq Df Pr(>Chisq)    
## (Intercept)      103.2713  1    < 2e-16 ***
## sex                0.4351  1    0.50950    
## father_morph       0.1971  1    0.65707    
## trial              2.5831  1    0.10801    
## sex:father_morph   5.6428  1    0.01753 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(offspring_long_sex, pairwise~sex|father_morph)
## $emmeans
## father_morph = fighter:
##  sex    emmean   SE  df lower.CL upper.CL
##  female   43.2 3.48 130     36.4     50.1
##  male     38.5 2.72  64     33.0     43.9
## 
## father_morph = scrambler:
##  sex    emmean   SE  df lower.CL upper.CL
##  female   35.1 3.73 160     27.7     42.4
##  male     43.5 2.64  64     38.3     48.8
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
## father_morph = fighter:
##  contrast      estimate   SE  df t.ratio p.value
##  female - male     4.76 3.89 311   1.225  0.2214
## 
## father_morph = scrambler:
##  contrast      estimate   SE  df t.ratio p.value
##  female - male    -8.49 4.09 311  -2.075  0.0388
## 
## Degrees-of-freedom method: kenward-roger
graph_sex <- emmip(offspring_long_sex, sex~father_morph, CIs=TRUE,type="response", plotit=FALSE)

emmeans(offspring_long_sex, pairwise~father_morph|sex)
## $emmeans
## sex = female:
##  father_morph emmean   SE  df lower.CL upper.CL
##  fighter        43.2 3.48 130     36.4     50.1
##  scrambler      35.1 3.73 160     27.7     42.4
## 
## sex = male:
##  father_morph emmean   SE  df lower.CL upper.CL
##  fighter        38.5 2.72  64     33.0     43.9
##  scrambler      43.5 2.64  64     38.3     48.8
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
## sex = female:
##  contrast            estimate   SE    df t.ratio p.value
##  fighter - scrambler     8.17 5.07 143.8   1.611  0.1094
## 
## sex = male:
##  contrast            estimate   SE    df t.ratio p.value
##  fighter - scrambler    -5.09 3.79  63.4  -1.343  0.1839
## 
## Degrees-of-freedom method: kenward-roger
sex_longevity <- ggplot(graph_sex, aes(x=father_morph, y=yvar, col=sex)) + theme_classic() + geom_pointrange(aes(ymin=yvar-SE, ymax=yvar+SE), position=position_dodge(width=0.5)) + ylab("Offspring Longevity") + xlab("Father Morph") + scale_color_uchicago() + theme(legend.position = "bottom", legend.title=element_blank()) + ylim(30,60)
#longevity between sexes
ggplot(full_long, aes(father_morph, longevity, fill=sex)) + geom_boxplot()+ scale_fill_uchicago() + ylab("Offspring Longevity (days)") + xlab("Father Morph") + theme_classic() 

#removing females
full_long_males <- full_long %>%
  filter(sex!="female")

Does longevity differ between scrambler vs fighter sons

#longevity between fighters and scramblers
ggplot(full_long_males, aes(father_morph, longevity, fill=offspring_morph)) + geom_boxplot()+ scale_fill_uchicago() + ylab("Offspring Longevity (days)") + xlab("Father Morph") + theme_classic()

#does longevity differ between sons (fighters vs scramblers) of different father morphs?
#singularity error, putting trial as factor
offspring_long_males <- lmer(longevity~offspring_morph*father_morph + (1|fatherID) + trial, contrast=list(offspring_morph=contr.sum, father_morph=contr.sum), data=full_long_males)
summary(offspring_long_males)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ offspring_morph * father_morph + (1 | fatherID) +  
##     trial
##    Data: full_long_males
## 
## REML criterion at convergence: 1958.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6847 -0.6256 -0.2049  0.3963  3.8381 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)  71.47    8.454  
##  Residual             501.98   22.405  
## Number of obs: 216, groups:  fatherID, 47
## 
## Fixed effects:
##                                Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)                      47.592      6.117  52.689   7.781  2.6e-10 ***
## offspring_morph1                 -2.712      1.660 209.463  -1.634   0.1038    
## father_morph1                    -2.770      2.043  42.890  -1.356   0.1822    
## trial                            -2.487      2.162  47.188  -1.150   0.2558    
## offspring_morph1:father_morph1    4.157      1.660 209.674   2.503   0.0131 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) offs_1 fthr_1 trial 
## offsprng_m1 -0.028                     
## fathr_mrph1  0.069 -0.050              
## trial       -0.943 -0.011 -0.058       
## offspr_1:_1 -0.045  0.043 -0.116  0.030
anova(offspring_long_males)
## Type III Analysis of Variance Table with Satterthwaite's method
##                               Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
## offspring_morph              1340.30 1340.30     1 209.463  2.6700 0.10376  
## father_morph                  923.01  923.01     1  42.890  1.8388 0.18219  
## trial                         664.30  664.30     1  47.188  1.3234 0.25578  
## offspring_morph:father_morph 3145.58 3145.58     1 209.674  6.2664 0.01307 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(offspring_long_males, pairwise~offspring_morph|father_morph)
## $emmeans
## father_morph = fighter:
##  offspring_morph emmean   SE   df lower.CL upper.CL
##  fighter           39.5 3.52 65.3     32.5     46.5
##  scrambler         36.6 4.13 86.0     28.4     44.8
## 
## father_morph = scrambler:
##  offspring_morph emmean   SE   df lower.CL upper.CL
##  fighter           36.7 3.54 73.7     29.7     43.8
##  scrambler         50.5 3.79 85.8     42.9     58.0
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
## father_morph = fighter:
##  contrast            estimate   SE  df t.ratio p.value
##  fighter - scrambler     2.89 4.86 207   0.595  0.5527
## 
## father_morph = scrambler:
##  contrast            estimate   SE  df t.ratio p.value
##  fighter - scrambler   -13.74 4.64 211  -2.962  0.0034
## 
## Degrees-of-freedom method: kenward-roger
graph_morph <- emmip(offspring_long_males, offspring_morph~father_morph, CIs=TRUE,type="response", plotit=FALSE)

long_morph <- ggplot(graph_morph, aes(x=father_morph, y=yvar, col=offspring_morph)) + theme_classic() + geom_pointrange(aes(ymin=yvar-SE, ymax=yvar+SE), position=position_dodge(width=0.5)) + ylab("Offspring Longevity") + xlab("Father Morph") + scale_color_aaas() + theme(legend.position = "bottom", legend.title=element_blank()) + ylim(30,60)

ggarrange(sex_longevity, long_morph, labels=c("A", "B"), nrow=2, ncol=1)

full_surv <- lmer(longevity~offspring_morph*father_morph + (1|fatherID) + trial, data=full_long)
Anova(full_surv)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: longevity
##                                Chisq Df Pr(>Chisq)   
## offspring_morph               3.3576  2   0.186599   
## father_morph                  0.0263  1   0.871187   
## trial                         2.5995  1   0.106895   
## offspring_morph:father_morph 12.9189  2   0.001566 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
graph_full_surv <- emmip(full_surv, offspring_morph~father_morph, CIs=TRUE, type="response", plotit=FALSE)

ggplot(graph_full_surv, aes(x=father_morph, y=yvar, col=offspring_morph)) + theme_classic()+ geom_pointrange(aes(ymin=yvar-SE, ymax=yvar+SE), position=position_dodge(width=0.5)) + scale_color_aaas() + xlab("Father Morph") + ylab("Offspring Longevity") + theme(legend.position = "bottom", legend.title=element_blank())

emmeans(full_surv, pairwise~offspring_morph|father_morph)
## $emmeans
## father_morph = fighter:
##  offspring_morph emmean   SE  df lower.CL upper.CL
##  females           43.2 3.40 129     36.5     50.0
##  fighter           39.9 3.24 111     33.5     46.3
##  scrambler         36.5 3.81 151     29.0     44.0
## 
## father_morph = scrambler:
##  offspring_morph emmean   SE  df lower.CL upper.CL
##  females           35.0 3.66 161     27.8     42.2
##  fighter           37.2 3.28 125     30.7     43.7
##  scrambler         50.9 3.52 146     44.0     57.9
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
## father_morph = fighter:
##  contrast            estimate   SE  df t.ratio p.value
##  females - fighter       3.32 4.33 309   0.767  0.7234
##  females - scrambler     6.74 4.65 306   1.451  0.3164
##  fighter - scrambler     3.42 4.61 307   0.741  0.7392
## 
## father_morph = scrambler:
##  contrast            estimate   SE  df t.ratio p.value
##  females - fighter      -2.21 4.53 309  -0.488  0.8771
##  females - scrambler   -15.94 4.71 311  -3.383  0.0023
##  fighter - scrambler   -13.73 4.45 311  -3.086  0.0062
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 3 estimates
emmeans(full_surv, pairwise~father_morph|offspring_morph)
## $emmeans
## offspring_morph = females:
##  father_morph emmean   SE  df lower.CL upper.CL
##  fighter        43.2 3.40 129     36.5     50.0
##  scrambler      35.0 3.66 161     27.8     42.2
## 
## offspring_morph = fighter:
##  father_morph emmean   SE  df lower.CL upper.CL
##  fighter        39.9 3.24 111     33.5     46.3
##  scrambler      37.2 3.28 125     30.7     43.7
## 
## offspring_morph = scrambler:
##  father_morph emmean   SE  df lower.CL upper.CL
##  fighter        36.5 3.81 151     29.0     44.0
##  scrambler      50.9 3.52 146     44.0     57.9
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
## offspring_morph = females:
##  contrast            estimate   SE  df t.ratio p.value
##  fighter - scrambler     8.23 4.97 143   1.655  0.1001
## 
## offspring_morph = fighter:
##  contrast            estimate   SE  df t.ratio p.value
##  fighter - scrambler     2.70 4.61 117   0.585  0.5595
## 
## offspring_morph = scrambler:
##  contrast            estimate   SE  df t.ratio p.value
##  fighter - scrambler   -14.45 5.18 148  -2.788  0.0060
## 
## Degrees-of-freedom method: kenward-roger

Q3: Correlations

Between father longevity and offspring sex longevity

H2: sons = positive correlation with fathers; daughters = negative correlation with fathers

H3: fighters = positive correlation with fighters, neg with scramblers; no difference with scrambler fathers

pooled_mod <- lmer(rescale(longevity)~rescale(father_long)*father_morph + (1|trial) + (1|fatherID) -1, data=full_long)
summary(pooled_mod)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: rescale(longevity) ~ rescale(father_long) * father_morph + (1 |  
##     trial) + (1 | fatherID) - 1
##    Data: full_long
## 
## REML criterion at convergence: -95.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6185 -0.6993 -0.2441  0.3566  3.8338 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  fatherID (Intercept) 0.0021101 0.04594 
##  trial    (Intercept) 0.0008287 0.02879 
##  Residual             0.0392838 0.19820 
## Number of obs: 318, groups:  fatherID, 48; trial, 4
## 
## Fixed effects:
##                                            Estimate Std. Error       df t value
## rescale(father_long)                        0.21025    0.07971 29.24910   2.638
## father_morphfighter                         0.14159    0.03671 18.68237   3.857
## father_morphscrambler                       0.26308    0.03205 10.09549   8.209
## rescale(father_long):father_morphscrambler -0.35014    0.10084 27.59873  -3.472
##                                            Pr(>|t|)    
## rescale(father_long)                        0.01323 *  
## father_morphfighter                         0.00109 ** 
## father_morphscrambler                      8.84e-06 ***
## rescale(father_long):father_morphscrambler  0.00172 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             rsc(_) fthr_mrphf fthr_mrphs
## fthr_mrphfg -0.764                      
## fthr_mrphsc -0.052  0.215               
## rscl(ft_):_ -0.745  0.573     -0.402
Anova(pooled_mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: rescale(longevity)
##                                     Chisq Df Pr(>Chisq)    
## rescale(father_long)               0.0059  1   0.938676    
## father_morph                      66.7839  2  3.148e-15 ***
## rescale(father_long):father_morph 12.0571  1   0.000516 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

fighter fathers and daughters correlation

long_sex <-  full_long %>%
  select(-offspring_morph)

long_fightfather <- long_sex %>%
  filter(sex == "female") %>%
  filter(father_morph == "fighter")

long_female_fight_corr <- lmer(longevity ~father_long + (1|fatherID) + (1|trial)-1, dat=long_fightfather) 
summary(long_female_fight_corr) #-ve corr not sig
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ father_long + (1 | fatherID) + (1 | trial) - 1
##    Data: long_fightfather
## 
## REML criterion at convergence: 530.5
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.30742 -0.77595 -0.01675  0.51580  2.34952 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)   13.15   3.626  
##  trial    (Intercept) 2026.06  45.012  
##  Residual              548.51  23.420  
## Number of obs: 56, groups:  fatherID, 19; trial, 4
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)
## father_long -0.004541   0.094430 10.851486  -0.048    0.963

scrambler fathers and daughters correlation

long_scramfather <- long_sex %>%
  filter(sex == "female") %>%
  filter(father_morph == "scrambler")

long_female_scram_corr <- lmer(longevity ~father_long + (1|fatherID) + (1|trial) -1, dat=long_scramfather) 
summary(long_female_scram_corr) #-ve corr not sig
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ father_long + (1 | fatherID) + (1 | trial) - 1
##    Data: long_scramfather
## 
## REML criterion at convergence: 392
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.7537 -0.6805 -0.1623  0.5307  3.0034 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)   20.53   4.531  
##  trial    (Intercept) 1290.93  35.930  
##  Residual              175.49  13.247  
## Number of obs: 46, groups:  fatherID, 20; trial, 4
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)
## father_long -0.01896    0.05774 12.89455  -0.328    0.748
long_morph <- full_long %>%
  filter(sex == "male")

Fighter father, scrambler son correlation

long_fightf_scramo <- long_morph %>%
  filter(father_morph == "fighter") %>%
  filter(offspring_morph == "scrambler")

long_fs_corr <- lmer(longevity ~father_long+ (1|fatherID) + (1|trial) -1, dat=long_fightf_scramo) 
summary(long_fs_corr) # sig +ve
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ father_long + (1 | fatherID) + (1 | trial) - 1
##    Data: long_fightf_scramo
## 
## REML criterion at convergence: 400.9
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.00063 -0.34238  0.00766  0.37938  2.88147 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept) 182.9    13.52   
##  trial    (Intercept) 270.5    16.45   
##  Residual             324.9    18.03   
## Number of obs: 44, groups:  fatherID, 18; trial, 4
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)   
## father_long  0.33827    0.09622 7.27172   3.516   0.0092 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Fighter father, fighter son correlation

long_fightf_fighto <- long_morph %>%
  filter(father_morph == "fighter") %>%
  filter(offspring_morph == "fighter")

long_ff_corr <- lmer(longevity ~father_long+ (1|fatherID) + trial-1, dat=long_fightf_fighto) 
summary(long_ff_corr) # sig +ve
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ father_long + (1 | fatherID) + trial - 1
##    Data: long_fightf_fighto
## 
## REML criterion at convergence: 558
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.62658 -0.44373  0.05595  0.41511  2.53578 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)  39.12    6.254  
##  Residual             378.70   19.460  
## Number of obs: 63, groups:  fatherID, 21
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## father_long  0.39862    0.06416 7.65313   6.213 0.000307 ***
## trial        6.21580    1.40519 8.69626   4.423 0.001808 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##       fthr_l
## trial -0.690

Scrambler father, fighter son correlation

long_scramf_fighto <- long_morph %>%
  filter(father_morph == "scrambler") %>%
  filter(offspring_morph == "fighter")

long_sf_corr <- lmer(longevity ~father_long+ (1|fatherID) + trial -1, dat=long_scramf_fighto) 
summary(long_sf_corr) # not sig +ve
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ father_long + (1 | fatherID) + trial - 1
##    Data: long_scramf_fighto
## 
## REML criterion at convergence: 535
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.3749 -0.3462 -0.2599  0.3634  3.9605 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)  11.86    3.444  
##  Residual             498.80   22.334  
## Number of obs: 59, groups:  fatherID, 23
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## father_long  0.001621   0.063838 13.297286   0.025     0.98    
## trial       12.922057   1.389042 11.038999   9.303 1.47e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##       fthr_l
## trial -0.632

Scrambler father, scrambler son correlation

long_scramf_scrambo <- long_morph %>%
  filter(father_morph == "scrambler") %>%
  filter(offspring_morph == "scrambler")

long_ss_corr <- lmer(longevity ~father_long+ (1|fatherID) + trial -1, dat=long_scramf_scrambo) 
summary(long_ss_corr) # not sig +ve
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: longevity ~ father_long + (1 | fatherID) + trial - 1
##    Data: long_scramf_scrambo
## 
## REML criterion at convergence: 486.9
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.24014 -0.59517 -0.07654  0.51305  2.41395 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  fatherID (Intercept)  94.1     9.7    
##  Residual             942.6    30.7    
## Number of obs: 50, groups:  fatherID, 18
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## father_long  0.18142    0.07894  9.58998   2.298   0.0454 *  
## trial       14.59634    2.12119 10.52683   6.881 3.32e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##       fthr_l
## trial -0.535

Correlations between father and offspring longevity - FULL GRAPH

ggplot(full_long, aes(father_long,longevity , col=offspring_morph)) + geom_point() + facet_wrap(~father_morph) + geom_smooth(method="lm", se=FALSE) + theme_classic() + ylab("Offspring longevity (days)") + xlab("Father Longevity (days)") + scale_color_uchicago() 
## `geom_smooth()` using formula 'y ~ x'

full_mod <- lmer(longevity~father_long*father_morph*offspring_morph + (1|trial) + (1|fatherID), data=full_long)
Anova(full_mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: longevity
##                                            Chisq Df Pr(>Chisq)    
## father_long                               0.0240  1  0.8769937    
## father_morph                              0.0001  1  0.9922356    
## offspring_morph                           3.1671  2  0.2052410    
## father_long:father_morph                 14.8642  1  0.0001155 ***
## father_long:offspring_morph               1.8414  2  0.3982318    
## father_morph:offspring_morph             16.8609  2  0.0002181 ***
## father_long:father_morph:offspring_morph  5.7061  2  0.0576682 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emtrends(full_mod, pairwise~offspring_morph|father_morph, var="father_long")
## $emtrends
## father_morph = fighter:
##  offspring_morph father_long.trend     SE    df lower.CL upper.CL
##  females                  0.000397 0.0873 118.6  -0.1725   0.1733
##  fighter                  0.230143 0.0868  85.7   0.0575   0.4028
##  scrambler                0.232122 0.0867 108.6   0.0603   0.4040
## 
## father_morph = scrambler:
##  offspring_morph father_long.trend     SE    df lower.CL upper.CL
##  females                 -0.069214 0.0712 114.8  -0.2102   0.0718
##  fighter                 -0.186422 0.0813 156.4  -0.3470  -0.0258
##  scrambler               -0.064638 0.0674 116.2  -0.1981   0.0688
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
## father_morph = fighter:
##  contrast            estimate     SE  df t.ratio p.value
##  females - fighter   -0.22975 0.1147 289  -2.004  0.1131
##  females - scrambler -0.23172 0.1135 304  -2.042  0.1041
##  fighter - scrambler -0.00198 0.1134 275  -0.017  0.9998
## 
## father_morph = scrambler:
##  contrast            estimate     SE  df t.ratio p.value
##  females - fighter    0.11721 0.0983 300   1.193  0.4585
##  females - scrambler -0.00458 0.0897 305  -0.051  0.9986
##  fighter - scrambler -0.12178 0.0965 304  -1.261  0.4182
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 3 estimates
mylist_long <- list(father_long=seq(0,200, by=20), father_morph=c("fighter", "scrambler"), offspring_morph=c("females", "fighter", "scrambler"))

emmip(full_mod, offspring_morph~father_long|father_morph, at=mylist_long, CI=TRUE) + facet_grid(father_morph~.) + theme_classic() + xlab("Father Longevity")+ scale_color_aaas() + geom_line(size=1) + theme(legend.position="bottom", legend.title=element_blank())

Full Corellation Model

ggplot(full_long, aes(father_long,longevity , col=father_morph)) + geom_point() + geom_smooth(method="lm", se=FALSE) + theme_classic() + ylab("Offspring longevity (days)") + xlab("Father Longevity (days)") + scale_color_uchicago() 
## `geom_smooth()` using formula 'y ~ x'

Q4: Daughter Fecundity - Mating with father-like/ father unlike

Total fecundity

#total fecundity
ggplot(daught_fecund, aes(father_morph, egg_count, fill=mate_morph)) + geom_boxplot() + scale_fill_uchicago() + theme_classic() + ylab("Daughter Fecundity") + xlab("Father Morph")
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).

Does total fecundity differ between daughters of differently morphed fathers when the daughters are mated with a father-like or father-unlike morph?

#boundary error 
#made trial factor
daught_tot_fecund_mod <- glmer(total~father_morph*mate_morph + trial + (1|fatherID2) + (1|daught_ID), family="poisson", data=daught_tot_fecund)
Anova(daught_tot_fecund_mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: total
##                          Chisq Df Pr(>Chisq)  
## father_morph            0.3902  1    0.53219  
## mate_morph              0.5848  1    0.44442  
## trial                   3.1759  1    0.07473 .
## father_morph:mate_morph 0.5411  1    0.46197  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
daught_tot_fecund_mod.grid <- ref_grid(daught_tot_fecund_mod)

emmeans(regrid(daught_tot_fecund_mod.grid), pairwise~father_morph|mate_morph)
## $emmeans
## mate_morph = fighter:
##  father_morph rate   SE  df asymp.LCL asymp.UCL
##  fighter      73.5 31.6 Inf     11.57     135.4
##  scrambler    42.3 16.8 Inf      9.34      75.3
## 
## mate_morph = scrambler:
##  father_morph rate   SE  df asymp.LCL asymp.UCL
##  fighter      41.3 18.3 Inf      5.41      77.2
##  scrambler    41.0 16.8 Inf      8.01      73.9
## 
## Confidence level used: 0.95 
## 
## $contrasts
## mate_morph = fighter:
##  contrast            estimate   SE  df z.ratio p.value
##  fighter - scrambler   31.186 35.8 Inf   0.871  0.3836
## 
## mate_morph = scrambler:
##  contrast            estimate   SE  df z.ratio p.value
##  fighter - scrambler    0.323 24.8 Inf   0.013  0.9896

Fecundity Rate

ggplot(daught_fecund, aes(week, egg_count, col=mate_morph)) + facet_grid(~father_morph) + geom_smooth(method="lm", formula = y~I(x^2)) + ylab("Daughter Fecundity") + xlab("Week") + scale_color_uchicago() + theme_classic()
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

# Does rate of fecundity change between daughters of different morphed fathers when the daughters are mated with father-like and unlike mates?
#sing error, trial as factor
#used optimx to converge model
daught_rate_fecund_mod <- glmer(egg_count~rescale(week)+I(rescale(week)^2)*mate_morph*father_morph+ + trial + (1|obs_effect) + (1|fatherID2) + (1|daught_ID), family="poisson", glmerControl(optimizer ='optimx', optCtrl=list(method='nlminb')), data=daught_fecund)

Anova(daught_rate_fecund_mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: egg_count
##                                             Chisq Df Pr(>Chisq)   
## rescale(week)                              1.6062  1   0.205031   
## I(rescale(week)^2)                         8.4598  1   0.003631 **
## mate_morph                                 0.0228  1   0.880089   
## father_morph                               1.4840  1   0.223152   
## trial                                      3.0003  1   0.083247 . 
## I(rescale(week)^2):mate_morph              0.2562  1   0.612761   
## I(rescale(week)^2):father_morph            5.9731  1   0.014526 * 
## mate_morph:father_morph                    0.2151  1   0.642797   
## I(rescale(week)^2):mate_morph:father_morph 2.5407  1   0.110943   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emtrends(daught_rate_fecund_mod, pairwise ~ father_morph, var="(week)^2")
## NOTE: Results may be misleading due to involvement in interactions
## $emtrends
##  father_morph (week)^2.trend   SE  df asymp.LCL asymp.UCL
##  fighter                -171 25.3 Inf      -221      -122
##  scrambler              -287 52.7 Inf      -390      -184
## 
## Results are averaged over the levels of: mate_morph 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast            estimate   SE  df z.ratio p.value
##  fighter - scrambler      116 49.7 Inf   2.328  0.0199
## 
## Results are averaged over the levels of: mate_morph
mylist_fecund <- list(week=seq(0,15, by=2), father_morph=c("fighter", "scrambler")) 

emmip(daught_rate_fecund_mod, father_morph~week^2, at=mylist_fecund, CI=TRUE) + theme_classic() + ylab("Linear Prediction") + xlab("Week of Egg Count") + theme(legend.position="bottom", legend.title=element_blank()) + scale_color_uchicago()
## NOTE: Results may be misleading due to involvement in interactions

Longevity

longevity_fert_daught <- daught_fecund %>%
  group_by(trial, daught_ID, father_morph, mate_morph) %>%
  top_n(1, week) %>%
  unique()

fit_daught <- survfit(Surv(week)~father_morph+mate_morph + (1|daught_ID), data=longevity_fert_daught)

ggsurvplot(fit_daught, data=longevity_fert_daught) 

mod.surv.daught <- coxme(Surv(week)~father_morph*mate_morph + egg_count +(1|daught_ID), data=longevity_fert_daught)
Anova(mod.surv.daught)
## Analysis of Deviance Table (Type II tests)
## 
## Response: Surv(week)
##                         Df  Chisq Pr(>Chisq)   
## father_morph             1 1.3503   0.245228   
## mate_morph               1 0.0300   0.862441   
## egg_count                1 6.7307   0.009477 **
## father_morph:mate_morph  1 0.0446   0.832747   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1