Winter 2020 Flight Trials: Morphology Modeling

Flight Trials Winter 2020 Dataset was conducted from 2/17/2020 - 3/10/2020. Soapberry bugs were flight tested twice for multiple hours in the flight mill and observed from 8 AM to (5-8 PM) each day. No morphological covariates were included for thorax width or body length (just looked at sex, host, and sym_dist). For wing length and beak length, sex, host, sym_dist, and thorax width were all included.

All Data

Reading Data

Testing Covariates

Comparing Models:

Reading the data

source_path = paste0(dir,"/Rsrc/")

script_names = c("center_flight_data.R",  # 1 function: center_data()
                 "clean_flight_data.R",   # 1 function: clean_flight_data()
                 "compare_models.R",
                 "get_Akaike_weights.R",
                 "regression_output.R")  

for (script in script_names) { 
  path = paste0(source_path, script)
  source(path) 
}

output_col = FALSE # Recommend changing this to TRUE if working in Base R or RStudio, and FALSE if generating an
data <- read_flight_data("data/all_flight_data-Winter2020.csv")
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## Please use a list of either functions or lambdas: 
## 
##   # Simple named list: 
##   list(mean = mean, median = median)
## 
##   # Auto named with `tibble::lst()`: 
##   tibble::lst(mean, median)
## 
##   # Using lambdas
##   list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
data_all <- data[[1]]
data_tested <- data[[2]]

data_tested <- data_tested[data_tested$trial_type=="T1",] # only the unique values pulled for those tested
data_tested <- center_data(data_tested)

data_all <- data_all %>%
  filter(trial_type != "T2")
data_all <- center_data(data_all)

Testing Models and Covariates

Experimental Set-Up Effects

## lm thorax_c ~ days_from_start_c data_tested 
## AIC:  158.4207 
## days_from_start_c    coeff:  -0.0020563  Pr(>|t|):  0.646594
## lm thorax_c ~ min_from_IncStart_c data_tested 
## AIC:  158.4888 
## min_from_IncStart_c  coeff:  4.53e-05    Pr(>|t|):  0.7056367

Comparing Models

Thorax

data<-data.frame(R=data_tested$thorax_c, 
                 A=data_tested$host_c, 
                 B=data_tested$sex_c, 
                 C=data_tested$sym_dist)

model_script = paste0(source_path,"generic models-gaussian glmer 3-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]      [,4]      [,5]      
## AICs   -44.08733 -43.42215 -42.52471 -41.90339 -41.5654  
## models 15        11        17        14        7         
## probs  0.3260686 0.2338118 0.1492762 0.1094134 0.09240135
## 
## m15  R ~ A * B + B * C
## m11  R ~ A * B + C
## m17  R ~ A * B + A * C + B * C
## m14  R ~ A * B + A * C
## m7   R ~ A + B + C
anova(m7, m11, test="Chisq") # Adding A*B marginally improves fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + B + C
## Model 2: R ~ A * B + C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)  
## 1    328 16.642                        
## 2    327 16.450  1   0.19221  0.05062 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m7, m12, test="Chisq") # Adding A*C does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + B + C
## Model 2: R ~ A * C + B
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    328 16.642                      
## 2    327 16.625  1  0.016788   0.5655
best.fit.thorax <- lm(thorax_c ~ host_c * sex_c + sym_dist, data=data_tested)
tidy_regression(best.fit.thorax, is_color=output_col)
## lm thorax_c ~ host_c * sex_c + sym_dist data_tested 
## AIC:  -43.42215 
## (Intercept)      coeff:  -0.0360092  Pr(>|t|):  0.1128104
## host_c           coeff:  -0.0828395  Pr(>|t|):  1.427492e-05 *
## sex_c            coeff:  0.2261295   Pr(>|t|):  7.939274e-41 *
## sym_dist         coeff:  0.0741271   Pr(>|t|):  3.528127e-06 *
## host_c:sex_c     coeff:  0.0285613   Pr(>|t|):  0.05147139 .
  • negative effect of host plant where if from GRT then smaller thorax length

  • strong positive effect of sex where if Female then larger thorax length

  • positive effect of sym_dist where if farther from Homestead, then longer thorax length

  • positive marginal effect of host*sex where if Female and from GRT then larger body

Body Length

data<-data.frame(R=data_tested$body_c, 
                 A=data_tested$host_c, 
                 B=data_tested$sex_c, 
                 C=data_tested$sym_dist)

model_script = paste0(source_path,"generic models-gaussian glmer 3-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]      [,4]     
## AICs   808.1386  808.4805  810.1276  810.4753 
## models 15        11        17        14       
## probs  0.3665623 0.3089642 0.1355967 0.1139541
## 
## m15  R ~ A * B + B * C
## m11  R ~ A * B + C
## m17  R ~ A * B + A * C + B * C
## m14  R ~ A * B + A * C
anova(m11, m15, test="Chisq") # Adding B*C does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ A * B + C
## Model 2: R ~ A * B + B * C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    327 214.07                      
## 2    326 212.56  1    1.5047   0.1287
best.fit.body <- lm(body_c ~ host_c * sex_c + sym_dist, data=data_tested)
tidy_regression(best.fit.body, is_color=output_col)
## lm body_c ~ host_c * sex_c + sym_dist data_tested 
## AIC:  808.4805 
## (Intercept)      coeff:  -0.0534409  Pr(>|t|):  0.5134984
## host_c           coeff:  -0.1850452  Pr(>|t|):  0.006706994 *
## sex_c            coeff:  0.7922666   Pr(>|t|):  4.241781e-39 *
## sym_dist         coeff:  0.2227673   Pr(>|t|):  0.0001033802 *
## host_c:sex_c     coeff:  0.1311645   Pr(>|t|):  0.01332877 *
  • negative effect of host where if from GRT then smaller body

  • strong positve effect of sex, where if Female then larger body

  • positve effect of sym_dist where if farther from Homestead, then larger body

  • positive host*sex interaction where if Female and from GRT then larger body

Wing Length

data<-data.frame(R=data_tested$wing_c, 
                 A=data_tested$host_c, 
                 B=data_tested$sex_c, 
                 C=data_tested$sym_dist, 
                 D=data_tested$thorax_c)

model_script = paste0(source_path,"generic models-gaussian glmer 4-FF.R")
model_comparisonsAIC(model_script)
##        [,1]       [,2]       [,3]      [,4]       [,5]       [,6]      
## AICs   309.4368   309.6572   309.6577  309.7867   309.9198   310.0324  
## models 100        109        99        76         96         108       
## probs  0.07469386 0.06690132 0.0668838 0.06270781 0.05867053 0.05545884
## 
## m100     R ~ A * B + B * C + B * D + C * D
## m109     R ~ A * B + A * C + B * C + B * D + C * D
## m99  R ~ A * B + A * D + B * D + C * D
## m76  R ~ A * B + B * D + C * D
## m96  R ~ A * B + A * C + B * D + C * D
## m108     R ~ A * B + A * C + A * D + B * D + C * D
best.fit.wing <- lm(wing_c ~ host_c * sex_c + host_c * thorax_c + sex_c * thorax_c + sym_dist * thorax_c, data=data_tested)
tidy_regression(best.fit.wing, is_color=output_col) 
## lm wing_c ~ host_c * sex_c + host_c * thorax_c + sex_c * thorax_c + sym_dist * thorax_c data_tested 
## AIC:  309.6577 
## (Intercept)          coeff:  -0.0358793  Pr(>|t|):  0.4554924
## host_c               coeff:  0.0907347   Pr(>|t|):  0.008454989 *
## sex_c                coeff:  -0.0183767  Pr(>|t|):  0.6196153
## thorax_c             coeff:  2.5507765   Pr(>|t|):  8.664498e-54 *
## sym_dist             coeff:  0.0213647   Pr(>|t|):  0.4890866
## host_c:sex_c         coeff:  0.1266983   Pr(>|t|):  0.0006364304 *
## host_c:thorax_c      coeff:  -0.1776139  Pr(>|t|):  0.150416
## sex_c:thorax_c       coeff:  0.1840662   Pr(>|t|):  0.04910075 *
## thorax_c:sym_dist    coeff:  -0.1751373  Pr(>|t|):  0.03733336 *
  • positive effect of host where if from GRT then have longer wings

  • no effect of sex

  • strong positive effect of thorax where the longer the thorax, the longer the wings

  • no effect of sym_dist

  • positive effect of host*sex where if Female and from GRT then have longer wings

  • no effect of host*thorax

  • positive effect of sex*thorax where if F and have longer thorax, then have longer wings

  • negative effect of sex*sym_dist where if F and farther from Homestead, then have shorter wings

Beak Length

data<-data.frame(R=data_tested$beak_c, 
                 A=data_tested$host_c, 
                 B=data_tested$sex_c, 
                 C=data_tested$sym_dist, 
                 D=data_tested$thorax_c)

model_script = paste0(source_path,"generic models-gaussian glmer 4-FF.R")
model_comparisonsAIC(model_script)
##        [,1]     [,2]      [,3]       [,4]       [,5]       [,6]      
## AICs   382.0032 382.745   383.0399   383.3387   383.7315   384.1194  
## models 80       94        69         104        101        109       
## probs  0.145256 0.1002457 0.08650028 0.07449575 0.06121382 0.05042188
## 
## m80  R ~ A * C + B * C + B * D
## m94  R ~ A * B + A * C + B * C + B * D
## m69  R ~ A * B + A * C + B * D
## m104     R ~ A * C + B * C + B * D + C * D
## m101     R ~ A * C + A * D + B * C + B * D
## m109     R ~ A * B + A * C + B * C + B * D + C * D
best.fit.beak <- lm(beak_c ~ host_c * sym_dist + sex_c * sym_dist + sex_c * thorax_c, data=data_tested)
tidy_regression(best.fit.beak, is_color=output_col)
## lm beak_c ~ host_c * sym_dist + sex_c * sym_dist + sex_c * thorax_c data_tested 
## AIC:  382.0032 
## (Intercept)      coeff:  0.0831852   Pr(>|t|):  0.2055459
## host_c           coeff:  -0.3298756  Pr(>|t|):  6.193405e-08 *
## sym_dist         coeff:  -0.3135557  Pr(>|t|):  0.0144288 *
## sex_c            coeff:  0.6204374   Pr(>|t|):  9.224178e-45 *
## thorax_c         coeff:  1.3143121   Pr(>|t|):  5.775058e-30 *
## host_c:sym_dist  coeff:  0.2612436   Pr(>|t|):  0.04043858 *
## sym_dist:sex_c   coeff:  -0.0751405  Pr(>|t|):  0.003302975 *
## sex_c:thorax_c   coeff:  0.4866395   Pr(>|t|):  3.165965e-06 *
  • negative effect of host where if from GRT then have shorter beak

  • negative effect of sym_dist where if farther from Homestead then have shorter beak

  • positive effect of beak length where if Female then have longer beak

  • strong positive effect of thorax where the longer the thorax the longer the beak

  • maringal positive effect of host*sym_dist where if from GRT and farther from Homeasted then have longer beak

  • negative effect of sym_dist*sex where if farther from Homestead and Female then have shorter beak

  • positive effect of sex*thorax where if Female and have larger thorax then have longer beak

All Data Plots

par(mfrow=c(2,3))
plot(thorax_c ~ host_c, data=data_tested, main="data_tested")
plot(thorax_c ~ sym_dist, data=data_tested, main="data_tested")
plot(thorax_c ~ sex_c, data=data_tested, main="data_tested")

plot(thorax_c ~ host_c, data=data_all, main="data_all")
plot(thorax_c ~ sym_dist, data=data_all, main="data_all")
plot(thorax_c ~ sex_c, data=data_all, main="data_all")

gf_point(thorax_c ~ sym_dist, col=~host_c, alpha=~sex_c, data=data_tested)

gf_point(thorax_c ~ sym_dist, col=~host_c, alpha=~sex_c, data=data_all)

Female Data

Reading Data

Comparing Models:

data <- read_flight_data("data/all_flight_data-Winter2020.csv")
data_all <- data[[1]]
data_tested <- data[[2]]

data_tested <- data_tested[data_tested$trial_type=="T1",] # only the unique values pulled for those tested
data_tested <- center_data(data_tested)

data_all <- data_all %>%
  filter(trial_type != "T2")
data_all <- center_data(data_all)

data_fem <- data_tested[data_tested$sex=="F",]
data_fem <- center_data(data_fem)

Comparing Models

Thorax

data<-data.frame(R=data_fem$thorax_c, 
                 A=data_fem$host_c, 
                 B=data_fem$sym_dist)

model_script = paste0(source_path,"generic models-gaussian glmer 2-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]     [,4]     [,5]      
## AICs   35.33117  37.05222  37.21371 38.34189 39.43119  
## models 5         2         1        3        4         
## probs  0.4621622 0.1954669 0.180304 0.102571 0.05949582
## 
## m0   R ~ 1
## m2   R ~ B
## m1   R ~ A
## m3   R ~ A + B
## m4   R ~ A * B
anova(m0, m2, test="Chisq") # Adding B does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ 1
## Model 2: R ~ B
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    118 9.0660                      
## 2    117 9.0448  1  0.021227   0.6003
anova(m0, m1, test="Chisq") # Adding A does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ 1
## Model 2: R ~ A
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    118 9.0660                      
## 2    117 9.0571  1  0.008944   0.7339
best.fem.thorax <- lm(thorax_c ~ 1, data=data_fem)
tidy_regression(best.fem.thorax, is_color=output_col)
## lm thorax_c ~ 1 data_fem 
## AIC:  35.33117

Body

data<-data.frame(R=data_fem$body_c, 
                 A=data_fem$host_c, 
                 B=data_fem$sym_dist)

model_script = paste0(source_path,"generic models-gaussian glmer 2-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]     [,4]      
## AICs   346.0856  347.1209  347.4936 349.0748  
## models 5         2         1        3         
## probs  0.4120384 0.2455344 0.203792 0.09243577
## 
## m0   R ~ 1
## m2   R ~ B
## m1   R ~ A
## m3   R ~ A + B
anova(m0, m2, test="Chisq") # Adding B does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ 1
## Model 2: R ~ B
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    118 123.46                      
## 2    117 122.46  1   0.99675   0.3291
anova(m0, m1, test="Chisq") # Adding A does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ 1
## Model 2: R ~ A
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    118 123.46                      
## 2    117 122.85  1   0.61263    0.445
best.fem.body <- lm(body_c ~ 1, data=data_fem)
tidy_regression(best.fem.body, is_color=output_col)
## lm body_c ~ 1 data_fem 
## AIC:  346.0856

Wing

data<-data.frame(R=data_fem$wing_c, 
                 A=data_fem$host_c, 
                 B=data_fem$sym_dist,
                 C=data_fem$thorax_c)

model_script = paste0(source_path,"generic models-gaussian glmer 3-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      
## AICs   127.2285  127.7045  128.2853  128.6294  128.7533  130.4651  
## models 13        16        15        9         17        12        
## probs  0.2694945 0.2124233 0.1588862 0.1337721 0.1257328 0.05342345
## 
## m13  R ~ B * C + A
## m16  R ~ A * C + B * C
## m15  R ~ A * B + B * C
## m9   R ~ A * C
## m17  R ~ A * B + A * C + B * C
## m12  R ~ A * C + B
anova(m13, m16, test="Chisq") # Adding A*C does not inprove fit
## Analysis of Variance Table
## 
## Model 1: R ~ B * C + A
## Model 2: R ~ A * C + B * C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    114 18.349                      
## 2    113 18.115  1    0.2335   0.2275
best.fem.wing <- lm(wing_c ~ sym_dist * thorax_c + host_c, data=data_fem)
tidy_regression(best.fem.wing, is_color=output_col)
## lm wing_c ~ sym_dist * thorax_c + host_c data_fem 
## AIC:  127.2285 
## (Intercept)          coeff:  0.073353    Pr(>|t|):  0.2572449
## sym_dist             coeff:  0.0072964   Pr(>|t|):  0.8910373
## thorax_c             coeff:  3.0209157   Pr(>|t|):  1.732006e-37 *
## host_c               coeff:  0.1622927   Pr(>|t|):  0.002314201 *
## sym_dist:thorax_c    coeff:  -0.5055494  Pr(>|t|):  0.0009967779 *
  • no effect of sym_dist
  • strong positive effect of thorax where the longer the thorax the longer the wing
  • negative effect of sym_dist*thorax where the longer the thorax and farther from Homestead then the shorter the wing

Beak

data<-data.frame(R=data_fem$beak_c, 
                 A=data_fem$host_c, 
                 B=data_fem$sym_dist,
                 C=data_fem$thorax_c)

model_script = paste0(source_path,"generic models-gaussian glmer 3-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]     [,3]      [,4]      [,5]       [,6]     
## AICs   218.6601  218.6755 219.896   220.1993  220.4824   220.5986 
## models 7         5        11        9         12         13       
## probs  0.2258078 0.22408  0.1217213 0.1045918 0.09078985 0.0856643
## 
## m7   R ~ A + B + C
## m5   R ~ A + C
## m11  R ~ A * B + C
## m9   R ~ A * C
## m12  R ~ A * C + B
## m13  R ~ B * C + A
anova(m5, m7, test="Chisq") # Adding B marginally improves fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + C
## Model 2: R ~ A + B + C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    116 40.920                      
## 2    115 40.233  1   0.68718   0.1611
anova(m7, m11, test="Chisq") # Adding A*B does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + B + C
## Model 2: R ~ A * B + C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    115 40.233                      
## 2    114 39.976  1   0.25751   0.3915
best.fem.beak <- lm(beak_c ~ host_c + sym_dist + thorax_c, data=data_fem)
tidy_regression(best.fem.beak, is_color=output_col)
## lm beak_c ~ host_c + sym_dist + thorax_c data_fem 
## AIC:  218.6601 
## (Intercept)  coeff:  -0.0520728  Pr(>|t|):  0.5845457
## host_c       coeff:  -0.2810951  Pr(>|t|):  0.0003787158 *
## sym_dist     coeff:  -0.1093528  Pr(>|t|):  0.1637574
## thorax_c     coeff:  1.8074116   Pr(>|t|):  2.317886e-15 *
  • negative effect of host where if from GRT then the shorter the beak
  • marginal negative effect of sym_dist where the farther from Homestead the shorter the beak
  • strong positive effect of thorax where the longer the thorax, the longer the beak

Female Plots

plot(thorax ~ host_c, data=data_fem)

plot(thorax ~ sym_dist, data=data_fem)

gf_point(thorax_c ~ sym_dist, col=~host_c, data=data_fem)

Male Data

Reading Data

Comparing Models:

output_col = FALSE #

data <- read_flight_data("data/all_flight_data-Winter2020.csv")
data_all <- data[[1]]
data_tested <- data[[2]]

data_tested <- data_tested[data_tested$trial_type=="T1",] # only the unique values pulled for those tested
data_tested <- center_data(data_tested)

data_all <- data_all %>%
  filter(trial_type != "T2")
data_all <- center_data(data_all)

data_male <- data_tested[data_tested$sex=="M",]
data_male <- center_data(data_male)

Comparing Models

Thorax

data<-data.frame(R=data_male$thorax_c, 
                 A=data_male$host_c, 
                 B=data_male$sym_dist)

model_script = paste0(source_path,"generic models-gaussian glmer 2-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]     
## AICs   -105.2699 -103.276 
## models 3         4        
## probs  0.7304615 0.2695383
## 
## m3   R ~ A + B
## m4   R ~ A * B
anova(m3, m4, test="Chisq") # Adding A*B does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + B
## Model 2: R ~ A * B
##   Res.Df    RSS Df  Sum of Sq Pr(>Chi)
## 1    210 7.3275                       
## 2    209 7.3273  1 0.00020874   0.9385
best.male.thorax <- lm(thorax_c ~ host_c + sym_dist, data=data_male)
tidy_regression(best.male.thorax, is_color=output_col)
## lm thorax_c ~ host_c + sym_dist data_male 
## AIC:  -105.2699 
## (Intercept)  coeff:  -0.1354022  Pr(>|t|):  1.098378e-07 *
## host_c       coeff:  -0.1264809  Pr(>|t|):  3.313508e-09 *
## sym_dist     coeff:  0.0901263   Pr(>|t|):  2.083607e-08 *
  • negative effect of host where if form GRT, the shorter the thorax
  • positve effect of sym_dist where the farther from Homestead, the longer the thorax

Body

data<-data.frame(R=data_male$body_c, 
                 A=data_male$host_c, 
                 B=data_male$sym_dist)

model_script = paste0(source_path,"generic models-gaussian glmer 2-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]     
## AICs   429.3224  430.1409 
## models 3         4        
## probs  0.6008938 0.3990914
## 
## m3   R ~ A + B
## m4   R ~ A * B
anova(m3, m4, test="Chisq") # Adding A*B does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + B
## Model 2: R ~ A * B
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    210 90.148                      
## 2    209 89.649  1   0.49868   0.2809
best.male.body <- lm(body_c ~ host_c + sym_dist, data=data_male)
tidy_regression(best.male.body, is_color=output_col)
## lm body_c ~ host_c + sym_dist data_male 
## AIC:  429.3224 
## (Intercept)  coeff:  -0.4062525  Pr(>|t|):  4.609688e-06 *
## host_c       coeff:  -0.3672157  Pr(>|t|):  7.089933e-07 *
## sym_dist     coeff:  0.2768821   Pr(>|t|):  7.394263e-07 *
  • negative effect of host where if from GRT then smaller body
  • positive effect of sym_dist where if farther from Homestead then larger body

Wing

data<-data.frame(R=data_male$wing_c, 
                 A=data_male$host_c, 
                 B=data_male$sym_dist,
                 C=data_male$thorax_c)

model_script = paste0(source_path,"generic models-gaussian glmer 3-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]      [,4]      [,5]       [,6]       [,7]      
## AICs   178.3127  179.1819  179.6539  179.7537  180.9264   181.1406   181.1816  
## models 3         5         6         10        9          13         7         
## probs  0.2498088 0.1617578 0.1277499 0.1215338 0.06761449 0.06074911 0.05951477
## 
## m3   R ~ C
## m5   R ~ A + C
## m6   R ~ B + C
## m10  R ~ B * C
## m9   R ~ A * C
## m13  R ~ B * C + A
## m7   R ~ A + B + C
anova(m3, m5, test="Chisq") # Adding A does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ C
## Model 2: R ~ A + C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    211 28.005                      
## 2    210 27.857  1   0.14829   0.2904
anova(m3, m6, test="Chisq") # Adding B does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ C
## Model 2: R ~ B + C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    211 28.005                      
## 2    210 27.919  1   0.08648   0.4199
best.male.wing <- lm(wing_c ~ thorax_c, data=data_male)
tidy_regression(best.male.wing, is_color=output_col)
## lm wing_c ~ thorax_c data_male 
## AIC:  178.3127 
## thorax_c     coeff:  2.3197584   Pr(>|t|):  2.956336e-47 *
  • strong positive effect of thorax where the longer the thorax, the longer the wing

Beak

data<-data.frame(R=data_male$beak_c, 
                 A=data_male$host_c, 
                 B=data_male$sym_dist,
                 C=data_male$thorax_c)

model_script = paste0(source_path,"generic models-gaussian glmer 3-FF.R")
model_comparisonsAIC(model_script)
##        [,1]      [,2]      [,3]      [,4]     [,5]       [,6]      [,7]      
## AICs   88.69349  89.96892  90.04939  90.41733 91.72476   91.99779  92.25941  
## models 15        14        11        17       5          9         13        
## probs  0.3008093 0.1589773 0.1527075 0.127047 0.06607811 0.0576462 0.05057785
## 
## m15  R ~ A * B + B * C
## m14  R ~ A * B + A * C
## m11  R ~ A * B + C
## m17  R ~ A * B + A * C + B * C
## m5   R ~ A + C
## m9   R ~ A * C
## m13  R ~ B * C + A
anova(m5, m9, test="Chisq") # adding A*C does not improve fit
## Analysis of Variance Table
## 
## Model 1: R ~ A + C
## Model 2: R ~ A * C
##   Res.Df    RSS Df Sum of Sq Pr(>Chi)
## 1    210 18.476                      
## 2    209 18.327  1    0.1492   0.1921
best.male.beak <- lm(wing_c ~ host_c + thorax_c, data=data_male)
tidy_regression(best.male.beak, is_color=output_col)
## lm wing_c ~ host_c + thorax_c data_male 
## AIC:  179.1819 
## (Intercept)  coeff:  0.0137254   Pr(>|t|):  0.6261128
## host_c       coeff:  0.0301393   Pr(>|t|):  0.2915975
## thorax_c     coeff:  2.3437619   Pr(>|t|):  8.107543e-47 *
  • no effect of hsot
  • strong positive effect of thorax where the larger the thorax, the longer the beak

Male Plots

plot(thorax ~ host_c, data=data_male)

plot(thorax ~ sym_dist, data=data_male)

gf_point(thorax_c ~ sym_dist, col=~host_c, data=data_male)