Input Data

brood <- read_csv("brood.csv")
brood$colony <- as.factor(brood$colony)
brood$treatment <- as.factor(brood$treatment)
brood$block <- as.factor(brood$replicate)


pollen <- read_csv("pollen.csv")
pollen$colony <- as.factor(pollen$colony)
pollen$treatment <- as.factor(pollen$treatment)
pollen$block <- as.factor(pollen$block)

workers <- read_csv("workers.csv")
workers$colony <- as.factor(workers$colony)
workers$treatment <- as.factor(workers$treatment)
workers$block <- as.factor(workers$block)
workers$qro <- as.factor(workers$qro)
workers$inoculate <- as.logical(workers$inoculate)

duration <- read_csv("duration.csv")
duration$treatment <- as.factor(duration$treatment)
duration$block <- as.factor(duration$block)
duration$colony <- as.factor(duration$colony)
duration$qro <- as.factor(duration$qro)

drones <- read_csv("drones.csv")
drones$treatment <- as.factor(drones$treatment)
drones$block <- as.factor(drones$block)
drones$colony <- as.factor(drones$colony)
drones$id <- as.factor(drones$id)
drones$abdomen_post_ethyl <- as.numeric(drones$abdomen_post_ethyl)

drones_rf <- read_csv("drones_rf.csv")
drones_rf$treatment <- as.factor(drones_rf$treatment)
drones_rf$block <- as.factor(drones_rf$block)
drones_rf$colony <- as.factor(drones_rf$colony)
drones_rf$id <- as.factor(drones_rf$id)
drones_rf$abdomen_post_ethyl <- as.numeric(drones_rf$abdomen_post_ethyl)

qro <- read_csv("qro.csv")
qro$colony <- as.factor(qro$colony)
qro$qro <- as.factor(qro$qro)
qro$fungicide <- as.logical(qro$fungicide)
qro$crithidia <- as.logical(qro$crithidia)
qro_simple <- qro[c('colony', 'qro', 'fungicide', 'crithidia')]
qro_pol <- qro[c('colony', 'qro')]

pollen <- merge(pollen, qro_pol, by = "colony", all = FALSE)

brood1 <- merge(brood, duration, by = "colony", all = FALSE)

custom_labels <- c("Control", "Fungicide",  "Fungicide + Crithidia", "Crithidia")

avg.pol <- pollen %>%
  group_by(colony) %>%
  summarise(avg.pol = mean(whole_dif))

duration <- merge(duration, avg.pol, by = "colony", all = FALSE)

new_dataframe <- duration[c('colony', 'days_active')]
brood <- merge(qro_simple, brood, by = "colony", all = FALSE)
workers <- merge(new_dataframe, workers, by = "colony", all = FALSE)

all_bees <- read_csv("qpcr_all_bees_8.1.24.csv", col_types = cols(treatment = col_factor(levels = c("1", 
                                                                                        "2", "3", "4")), replicate = col_factor(levels = c("1", 
                                                                                                                                           "4", "6", "7", "8", "9", "10", "11", 
                                                                                                                                           "12")), start = col_date(format = "%m/%d/%Y"), 
                                                      Innoculation_date = col_date(format = "%m/%d/%Y"), 
                                                      date = col_date(format = "%m/%d/%Y"), censor_status = col_factor(levels = c("1","2"))))
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
all_bees$colony <- as.factor(all_bees$colony)
all_bees$bee_id <- as.factor(all_bees$bee_id)


workers_for_qpcr_merge <- read_csv("workers_for qpcr merge.csv", 
                                   col_types = cols(fungicide = col_logical(), 
                                                    crithidia = col_logical(), inoculate_round = col_factor(levels = c("1", 
                                                                                                                       "2", "3")), inoculate = col_logical(), 
                                                    premature_death = col_logical(), 
                                                    `end date` = col_date(format = "%m/%d/%Y")))

Collinearity

# brood cells
brood.col <- lm(brood_cells~ treatment.x + block.x + workers_alive.x + qro + days_active + avg_pollen, data = brood1)
Anova(brood.col)
## Anova Table (Type II tests)
## 
## Response: brood_cells
##                  Sum Sq Df F value    Pr(>F)    
## treatment.x      246.44  3  2.4069   0.09587 .  
## block.x           30.00  4  0.2198   0.92439    
## workers_alive.x  205.77  1  6.0293   0.02287 *  
## qro                      0                      
## days_active        0.27  1  0.0081   0.92934    
## avg_pollen      1646.55  1 48.2453 7.336e-07 ***
## Residuals        716.70 21                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(brood.col, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ treatment.x + block.x + workers_alive.x + qro + 
##     days_active + avg_pollen
##                 Df Sum of Sq     RSS    AIC  Pr(>Chi)    
## <none>                        716.70 137.68              
## treatment.x      3    246.44  963.14 142.32  0.013845 *  
## block.x          4     30.00  746.71 131.16  0.830804    
## workers_alive.x  1    205.77  922.47 144.77  0.002575 ** 
## qro              0      0.00  716.70 137.68              
## days_active      1      0.27  716.98 135.69  0.906469    
## avg_pollen       1   1646.55 2363.25 178.63 5.608e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
b1 <- update(brood.col, .~. -qro)
vif(b1)
##                     GVIF Df GVIF^(1/(2*Df))
## treatment.x     1.499238  3        1.069823
## block.x         8.025087  8        1.139011
## workers_alive.x 3.569032  1        1.889188
## days_active     2.843844  1        1.686370
## avg_pollen      5.848885  1        2.418447
b2 <- update(b1, .~. -block.x)
anova(brood.col, b1, b2)
## Analysis of Variance Table
## 
## Model 1: brood_cells ~ treatment.x + block.x + workers_alive.x + qro + 
##     days_active + avg_pollen
## Model 2: brood_cells ~ treatment.x + block.x + workers_alive.x + days_active + 
##     avg_pollen
## Model 3: brood_cells ~ treatment.x + workers_alive.x + days_active + avg_pollen
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1     21  716.7                                  
## 2     21  716.7  0       0.0                     
## 3     29 2481.2 -8   -1764.5 6.4627 0.0002814 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(b1, b2)
##    df      AIC
## b1 16 241.8446
## b2  8 270.5508
vif(b2)
##                     GVIF Df GVIF^(1/(2*Df))
## treatment.x     1.249684  3        1.037847
## workers_alive.x 2.319573  1        1.523015
## days_active     1.609306  1        1.268584
## avg_pollen      2.131195  1        1.459861
drop1(b2, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ treatment.x + workers_alive.x + days_active + avg_pollen
##                 Df Sum of Sq    RSS    AIC  Pr(>Chi)    
## <none>                       2481.2 166.39              
## treatment.x      3     329.0 2810.2 164.87   0.21389    
## workers_alive.x  1     232.0 2713.2 167.60   0.07282 .  
## days_active      1     347.1 2828.3 169.10   0.02993 *  
## avg_pollen       1    7456.1 9937.3 214.34 1.576e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(b1, b2)
## Analysis of Variance Table
## 
## Model 1: brood_cells ~ treatment.x + block.x + workers_alive.x + days_active + 
##     avg_pollen
## Model 2: brood_cells ~ treatment.x + workers_alive.x + days_active + avg_pollen
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1     21  716.7                                  
## 2     29 2481.2 -8   -1764.5 6.4627 0.0002814 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(b1, brood.col)
## Analysis of Variance Table
## 
## Model 1: brood_cells ~ treatment.x + block.x + workers_alive.x + days_active + 
##     avg_pollen
## Model 2: brood_cells ~ treatment.x + block.x + workers_alive.x + qro + 
##     days_active + avg_pollen
##   Res.Df   RSS Df Sum of Sq F Pr(>F)
## 1     21 716.7                      
## 2     21 716.7  0         0
drop1(b1, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ treatment.x + block.x + workers_alive.x + days_active + 
##     avg_pollen
##                 Df Sum of Sq     RSS    AIC  Pr(>Chi)    
## <none>                        716.70 137.68              
## treatment.x      3    246.44  963.14 142.32  0.013845 *  
## block.x          8   1764.50 2481.20 166.39 4.183e-07 ***
## workers_alive.x  1    205.77  922.47 144.77  0.002575 ** 
## days_active      1      0.27  716.98 135.69  0.906469    
## avg_pollen       1   1646.55 2363.25 178.63 5.608e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
b2 <- update(b1, .~. -days_active)
vif(b2)
##                     GVIF Df GVIF^(1/(2*Df))
## treatment.x     1.362270  3        1.052876
## block.x         4.541324  8        1.099193
## workers_alive.x 3.361139  1        1.833341
## avg_pollen      5.615940  1        2.369797
AIC(b1, b2)
##    df      AIC
## b1 16 241.8446
## b2 15 239.8584
anova(b1, b2)
## Analysis of Variance Table
## 
## Model 1: brood_cells ~ treatment.x + block.x + workers_alive.x + days_active + 
##     avg_pollen
## Model 2: brood_cells ~ treatment.x + block.x + workers_alive.x + avg_pollen
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1     21 716.70                           
## 2     22 716.98 -1  -0.27488 0.0081 0.9293
drop1(b2, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ treatment.x + block.x + workers_alive.x + avg_pollen
##                 Df Sum of Sq     RSS    AIC  Pr(>Chi)    
## <none>                        716.98 135.69              
## treatment.x      3    246.29  963.26 140.32  0.013902 *  
## block.x          8   2111.28 2828.26 169.10 5.316e-08 ***
## workers_alive.x  1    222.37  939.35 143.42  0.001818 ** 
## avg_pollen       1   1723.70 2440.67 177.79 3.121e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#don't include qro

Average pollen consumed per colony

pol_consum_sum <- pollen %>%
  group_by(colony) %>%
  summarise(mean.pollen = mean(whole_dif))


pol_consum_sum <- as.data.frame(pol_consum_sum)

workers <- merge(workers, pol_consum_sum, by = "colony", all = FALSE)
#brood <- merge(brood, pol_consum_sum, by = "colony", all = FALSE)
duration <- merge(duration, pol_consum_sum, by = "colony", all = FALSE)
all_bees <- merge(all_bees, pol_consum_sum, by="colony", all = FALSE)


#drones <- na.omit(drones)
#brood <- na.omit(brood)

pollen$days <- pollen$`pollen ball id`

new pollen csv

p <- read_csv("pollen.dates.csv", 
    col_types = cols(treatment = col_factor(levels = c("1", 
        "2", "3", "4")), pollen.start = col_date(format = "%m/%d/%Y"), 
        pollen.end = col_date(format = "%m/%d/%Y"), 
        colony.start = col_date(format = "%m/%d/%Y")))

p$colony <- as.factor(p$colony)

p <- p %>%
  mutate(
    fungicide = factor(fungicide),
    crithidia = factor(crithidia),
    block = factor(block),
    qro = factor(qro),
    id = factor(id)
  )

shapiro.test(p$whole_dif)
## 
##  Shapiro-Wilk normality test
## 
## data:  p$whole_dif
## W = 0.76908, p-value < 2.2e-16
hist(p$whole_dif)

p$box <- bcPower(p$whole_dif, -3, gamma=1.1)
shapiro.test(p$box)
## 
##  Shapiro-Wilk normality test
## 
## data:  p$box
## W = 0.92686, p-value < 2.2e-16
hist(p$box)

p$log <- log(p$whole_dif)
shapiro.test(p$log)
## 
##  Shapiro-Wilk normality test
## 
## data:  p$log
## W = 0.9363, p-value < 2.2e-16
hist(p$log)

pol.mod1 <- lmer(box ~ crithidia + fungicide + pollen.time + workers_alive + block + (1|colony), data = p)
pol.mod.int <- lmer(box ~ crithidia*pollen.time + fungicide + workers_alive + block + (1|colony), data = p)
drop1(pol.mod.int, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ crithidia * pollen.time + fungicide + workers_alive + block + 
##     (1 | colony)
##                       npar     AIC    LRT   Pr(Chi)    
## <none>                     -3279.9                     
## fungicide                1 -3279.9  2.047  0.152547    
## workers_alive            1 -3201.3 80.637 < 2.2e-16 ***
## block                    8 -3258.1 37.809 8.164e-06 ***
## crithidia:pollen.time    1 -3274.5  7.432  0.006406 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(pol.mod1)
## Single term deletions
## 
## Model:
## box ~ crithidia + fungicide + pollen.time + workers_alive + block + 
##     (1 | colony)
##               npar     AIC
## <none>             -3274.5
## crithidia        1 -3272.2
## fungicide        1 -3274.4
## pollen.time      1 -3008.9
## workers_alive    1 -3184.7
## block            8 -3252.5
Anova(pol.mod1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                  Chisq Df Pr(>Chisq)    
## crithidia       3.1212  1    0.07728 .  
## fungicide       1.4514  1    0.22830    
## pollen.time   316.6598  1  < 2.2e-16 ***
## workers_alive  93.8142  1  < 2.2e-16 ***
## block          46.6711  8  1.771e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(pol.mod1, pol.mod.int)
## Data: p
## Models:
## pol.mod1: box ~ crithidia + fungicide + pollen.time + workers_alive + block + (1 | colony)
## pol.mod.int: box ~ crithidia * pollen.time + fungicide + workers_alive + block + (1 | colony)
##             npar     AIC     BIC logLik deviance  Chisq Df Pr(>Chisq)   
## pol.mod1      15 -3274.5 -3205.5 1652.2  -3304.5                        
## pol.mod.int   16 -3279.9 -3206.4 1656.0  -3311.9 7.4325  1   0.006406 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(pol.mod1, pol.mod.int)
##             df       AIC
## pol.mod1    15 -3162.535
## pol.mod.int 16 -3152.365
drop1(pol.mod1, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ crithidia + fungicide + pollen.time + workers_alive + block + 
##     (1 | colony)
##               npar     AIC     LRT   Pr(Chi)    
## <none>             -3274.5                      
## crithidia        1 -3272.2   4.246   0.03935 *  
## fungicide        1 -3274.4   2.038   0.15341    
## pollen.time      1 -3008.9 267.550 < 2.2e-16 ***
## workers_alive    1 -3184.7  91.811 < 2.2e-16 ***
## block            8 -3252.5  37.980 7.592e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(pol.mod1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                  Chisq Df Pr(>Chisq)    
## crithidia       3.1212  1    0.07728 .  
## fungicide       1.4514  1    0.22830    
## pollen.time   316.6598  1  < 2.2e-16 ***
## workers_alive  93.8142  1  < 2.2e-16 ***
## block          46.6711  8  1.771e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(pol.mod1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ crithidia + fungicide + pollen.time + workers_alive + block +  
##     (1 | colony)
##    Data: p
## 
## REML criterion at convergence: -3192.5
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.73854 -0.62275 -0.00656  0.60820  2.80163 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  colony   (Intercept) 0.0004096 0.02024 
##  Residual             0.0005774 0.02403 
## Number of obs: 733, groups:  colony, 35
## 
## Fixed effects:
##                 Estimate Std. Error t value
## (Intercept)    1.166e-01  1.476e-02   7.899
## crithidiaTRUE -1.262e-02  7.142e-03  -1.767
## fungicideTRUE -8.572e-03  7.115e-03  -1.205
## pollen.time    1.638e-03  9.207e-05  17.795
## workers_alive  1.532e-02  1.581e-03   9.686
## block4         5.299e-02  1.481e-02   3.577
## block6        -3.580e-02  1.476e-02  -2.425
## block7         1.199e-02  1.483e-02   0.809
## block8         1.873e-02  1.479e-02   1.266
## block9         7.951e-03  1.479e-02   0.538
## block10        3.697e-02  1.608e-02   2.300
## block11       -1.158e-02  1.482e-02  -0.782
## block12        8.919e-03  1.479e-02   0.603
qqnorm(resid(pol.mod1));qqline(resid(pol.mod1))

Anova(pol.mod1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                  Chisq Df Pr(>Chisq)    
## crithidia       3.1212  1    0.07728 .  
## fungicide       1.4514  1    0.22830    
## pollen.time   316.6598  1  < 2.2e-16 ***
## workers_alive  93.8142  1  < 2.2e-16 ***
## block          46.6711  8  1.771e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
residuals <- resid(pol.mod1)
plot(residuals)

ps <- p[p$days >= 4 & p$days <=25, ]

range(ps$pollen.time)
## [1]  6 48
shapiro.test(ps$log)
## 
##  Shapiro-Wilk normality test
## 
## data:  ps$log
## W = 0.93269, p-value < 2.2e-16
hist(ps$log)

ps1 <- lmer(whole_dif ~ crithidia + fungicide + days + workers_alive + block +  (1|colony), data = ps)
Anova(ps1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: whole_dif
##                  Chisq Df Pr(>Chisq)    
## crithidia       2.9151  1    0.08775 .  
## fungicide       1.0140  1    0.31394    
## days          166.7600  1  < 2.2e-16 ***
## workers_alive  57.9176  1  2.733e-14 ***
## block          45.9379  8  2.443e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pe <- emmeans(ps1, pairwise ~ crithidia, type = "response")
pe
## $emmeans
##  crithidia emmean     SE   df lower.CL upper.CL
##  FALSE      0.475 0.0346 24.3    0.404    0.547
##  TRUE       0.390 0.0359 24.0    0.316    0.464
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast     estimate     SE   df t.ratio p.value
##  FALSE - TRUE   0.0855 0.0501 24.4   1.707  0.1004
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger
qqnorm(resid(ps1));qqline(resid(ps1))

ps_sum <- ps %>%
  group_by(treatment) %>%
  summarise(mean = mean(whole_dif),
            sd = sd(whole_dif),
            n = length(whole_dif)) %>%
  mutate(se = sd/sqrt(n))
ps_sum
## # A tibble: 4 × 5
##   treatment  mean    sd     n     se
##   <fct>     <dbl> <dbl> <int>  <dbl>
## 1 1         0.514 0.341   167 0.0264
## 2 2         0.442 0.322   170 0.0247
## 3 3         0.337 0.257   177 0.0193
## 4 4         0.363 0.270   149 0.0221
ggplot(data = p, aes(x = pollen.time, y = whole_dif, fill = treatment)) +
  geom_smooth() +
  labs(x = "Time", y = "Mean Pollen Consumed (g)") +
  theme_cowplot()+
  scale_x_continuous(breaks = seq(min(p$pollen.time), max(ps$pollen.time), by = 1))

ggplot(data = ps_sum, aes(x = treatment, y = mean, fill = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 0.65)) +
  geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Pollen Consumed (g)") +
  annotate(
    geom = "text",
    x = 3,
    y = 0.6,
    label = "P = 0.05",
    size = 8
  ) + 
  theme_classic(base_size = 20) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
  geom_segment(x = 1, xend = 2, y = 0.65, yend = 0.65, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 0.64, yend = 0.66, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 0.64, yend = 0.66, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 4, y = 0.47, yend = 0.47, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 0.46, yend = 0.48, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 0.46, yend = 0.48, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 1.5, y = 0.65, label = "a", size = 6, vjust = -0.5) +
  geom_text(x = 3.5, y = 0.48, label = "b", size = 6, vjust = -0.5)

Pollen Consumption

shapiro.test(pollen$whole_dif)
## 
##  Shapiro-Wilk normality test
## 
## data:  pollen$whole_dif
## W = 0.77483, p-value < 2.2e-16
hist(pollen$whole_dif)

range(pollen$whole_dif)
## [1] 0.03316 1.39545
pollen$box <- bcPower(pollen$whole_dif, -5, gamma=1)
shapiro.test(pollen$box)
## 
##  Shapiro-Wilk normality test
## 
## data:  pollen$box
## W = 0.95648, p-value = 3.679e-14
hist(pollen$box)

pollen$log <- log(pollen$whole_dif)
shapiro.test(pollen$log)
## 
##  Shapiro-Wilk normality test
## 
## data:  pollen$log
## W = 0.93499, p-value < 2.2e-16
hist(pollen$log)

pollen$square <- pollen$whole_dif^2
shapiro.test(pollen$square)
## 
##  Shapiro-Wilk normality test
## 
## data:  pollen$square
## W = 0.62065, p-value < 2.2e-16
hist(pollen$square)

pollen$root <- sqrt(pollen$whole_dif)
shapiro.test(pollen$root)
## 
##  Shapiro-Wilk normality test
## 
## data:  pollen$root
## W = 0.86233, p-value < 2.2e-16
hist(pollen$root)

descdist(pollen$whole_dif, discrete = FALSE)

## summary statistics
## ------
## min:  0.03316   max:  1.39545 
## median:  0.27686 
## mean:  0.4042769 
## estimated sd:  0.3016975 
## estimated skewness:  1.532669 
## estimated kurtosis:  4.289505
ggplot(pollen, aes(x = log, fill = treatment)) +
  geom_histogram(position = "identity", binwidth = 0.1, col = I("black")) +
  scale_fill_viridis_d() +  # Use viridis_d() for the color-blind friendly palette
  ggtitle("Pollen Consumption(g)") +
  labs(y = "Count", x = "Pollen (g)")

pol.mod <- lmer(box ~ fungicide*crithidia + block + days + workers_alive + (1|colony), data = pollen)
drop1(pol.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ fungicide * crithidia + block + days + workers_alive + 
##     (1 | colony)
##                     npar     AIC     LRT   Pr(Chi)    
## <none>                   -3905.8                      
## block                  8 -3881.2  40.572 2.506e-06 ***
## days                   1 -3658.3 249.500 < 2.2e-16 ***
## workers_alive          1 -3833.8  74.012 < 2.2e-16 ***
## fungicide:crithidia    1 -3907.7   0.073    0.7876    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pm1 <- update(pol.mod, .~. -days)
drop1(pm1, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ fungicide + crithidia + block + workers_alive + (1 | colony) + 
##     fungicide:crithidia
##                     npar     AIC    LRT   Pr(Chi)    
## <none>                   -3658.3                     
## block                  8 -3641.0 33.257 5.534e-05 ***
## workers_alive          1 -3656.2  4.128   0.04218 *  
## fungicide:crithidia    1 -3660.3  0.033   0.85554    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pol.mod1 <- lmer(box ~ crithidia + fungicide + days + workers_alive + block + (1|colony), data = pollen)
pol.mod.int <- lmer(box ~ crithidia*days + fungicide + workers_alive + block + (1|colony), data = pollen)
anova(pol.mod1, pol.mod.int)
## Data: pollen
## Models:
## pol.mod1: box ~ crithidia + fungicide + days + workers_alive + block + (1 | colony)
## pol.mod.int: box ~ crithidia * days + fungicide + workers_alive + block + (1 | colony)
##             npar     AIC     BIC logLik deviance  Chisq Df Pr(>Chisq)  
## pol.mod1      15 -3907.7 -3838.3 1968.9  -3937.7                       
## pol.mod.int   16 -3911.0 -3837.0 1971.5  -3943.0 5.2815  1    0.02155 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(pol.mod1, pol.mod.int)
##             df       AIC
## pol.mod1    15 -3787.219
## pol.mod.int 16 -3775.598
drop1(pol.mod1, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ crithidia + fungicide + days + workers_alive + block + 
##     (1 | colony)
##               npar     AIC     LRT   Pr(Chi)    
## <none>             -3907.7                      
## crithidia        1 -3905.5   4.261    0.0390 *  
## fungicide        1 -3907.2   2.473    0.1158    
## days             1 -3660.3 249.461 < 2.2e-16 ***
## workers_alive    1 -3835.8  73.943 < 2.2e-16 ***
## block            8 -3883.2  40.521 2.562e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(pm1, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ fungicide + crithidia + block + workers_alive + (1 | colony) + 
##     fungicide:crithidia
##                     npar     AIC    LRT   Pr(Chi)    
## <none>                   -3658.3                     
## block                  8 -3641.0 33.257 5.534e-05 ***
## workers_alive          1 -3656.2  4.128   0.04218 *  
## fungicide:crithidia    1 -3660.3  0.033   0.85554    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(pm1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                       Chisq Df Pr(>Chisq)    
## fungicide            1.6293  1    0.20179    
## crithidia            4.3682  1    0.03662 *  
## block               36.0573  8  1.714e-05 ***
## workers_alive        5.7953  1    0.01607 *  
## fungicide:crithidia  0.0233  1    0.87870    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(pm1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ fungicide + crithidia + block + workers_alive + (1 | colony) +  
##     fungicide:crithidia
##    Data: pollen
## 
## REML criterion at convergence: -3582.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9271 -0.5947  0.0905  0.7533  1.9758 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  colony   (Intercept) 0.0003295 0.01815 
##  Residual             0.0003931 0.01983 
## Number of obs: 755, groups:  colony, 36
## 
## Fixed effects:
##                      Estimate Std. Error t value
## (Intercept)          0.168149   0.011863  14.174
## fungicide           -0.008899   0.008810  -1.010
## crithidia           -0.013991   0.008822  -1.586
## block4               0.032649   0.013218   2.470
## block6              -0.033742   0.013172  -2.562
## block7              -0.003422   0.013215  -0.259
## block8               0.007327   0.013203   0.555
## block9               0.005102   0.013203   0.386
## block10              0.020309   0.013205   1.538
## block11             -0.021104   0.013204  -1.598
## block12             -0.001972   0.013193  -0.149
## workers_alive       -0.002431   0.001010  -2.407
## fungicide:crithidia  0.001900   0.012447   0.153
pm2 <- update(pm1, .~. -days)
drop1(pm2, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ fungicide + crithidia + block + workers_alive + (1 | colony) + 
##     fungicide:crithidia
##                     npar     AIC    LRT   Pr(Chi)    
## <none>                   -3658.3                     
## block                  8 -3641.0 33.257 5.534e-05 ***
## workers_alive          1 -3656.2  4.128   0.04218 *  
## fungicide:crithidia    1 -3660.3  0.033   0.85554    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(pm2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                       Chisq Df Pr(>Chisq)    
## fungicide            1.6293  1    0.20179    
## crithidia            4.3682  1    0.03662 *  
## block               36.0573  8  1.714e-05 ***
## workers_alive        5.7953  1    0.01607 *  
## fungicide:crithidia  0.0233  1    0.87870    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(pm2));qqline(resid(pm2))

Anova(pm2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                       Chisq Df Pr(>Chisq)    
## fungicide            1.6293  1    0.20179    
## crithidia            4.3682  1    0.03662 *  
## block               36.0573  8  1.714e-05 ***
## workers_alive        5.7953  1    0.01607 *  
## fungicide:crithidia  0.0233  1    0.87870    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
residuals <- resid(pm1)
summary(pm1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ fungicide + crithidia + block + workers_alive + (1 | colony) +  
##     fungicide:crithidia
##    Data: pollen
## 
## REML criterion at convergence: -3582.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9271 -0.5947  0.0905  0.7533  1.9758 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  colony   (Intercept) 0.0003295 0.01815 
##  Residual             0.0003931 0.01983 
## Number of obs: 755, groups:  colony, 36
## 
## Fixed effects:
##                      Estimate Std. Error t value
## (Intercept)          0.168149   0.011863  14.174
## fungicide           -0.008899   0.008810  -1.010
## crithidia           -0.013991   0.008822  -1.586
## block4               0.032649   0.013218   2.470
## block6              -0.033742   0.013172  -2.562
## block7              -0.003422   0.013215  -0.259
## block8               0.007327   0.013203   0.555
## block9               0.005102   0.013203   0.386
## block10              0.020309   0.013205   1.538
## block11             -0.021104   0.013204  -1.598
## block12             -0.001972   0.013193  -0.149
## workers_alive       -0.002431   0.001010  -2.407
## fungicide:crithidia  0.001900   0.012447   0.153
plot(residuals)

wilcox.test(residuals ~ pollen$fungicide)
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  residuals by pollen$fungicide
## W = 71544, p-value = 0.9188
## alternative hypothesis: true location shift is not equal to 0
range(pollen$days)
## [1]  2 26
pollen_subset <- pollen[pollen$days >= 7 & pollen$days <=20, ]
pol.mod1 <- lmer(box ~ block + crithidia + fungicide + workers_alive + days + (1|colony), data = pollen_subset)
drop1(pol.mod1, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ block + crithidia + fungicide + workers_alive + days + 
##     (1 | colony)
##               npar     AIC    LRT   Pr(Chi)    
## <none>             -2712.4                     
## block            8 -2687.2 41.260 1.864e-06 ***
## crithidia        1 -2709.1  5.358   0.02062 *  
## fungicide        1 -2711.7  2.790   0.09485 .  
## workers_alive    1 -2681.1 33.356 7.675e-09 ***
## days             1 -2621.2 93.255 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(pm1, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ fungicide + crithidia + block + workers_alive + (1 | colony) + 
##     fungicide:crithidia
##                     npar     AIC    LRT   Pr(Chi)    
## <none>                   -3658.3                     
## block                  8 -3641.0 33.257 5.534e-05 ***
## workers_alive          1 -3656.2  4.128   0.04218 *  
## fungicide:crithidia    1 -3660.3  0.033   0.85554    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pm1 <- update(pol.mod1, .~. -days)
drop1(pm2, test = "Chisq")
## Single term deletions
## 
## Model:
## box ~ fungicide + crithidia + block + workers_alive + (1 | colony) + 
##     fungicide:crithidia
##                     npar     AIC    LRT   Pr(Chi)    
## <none>                   -3658.3                     
## block                  8 -3641.0 33.257 5.534e-05 ***
## workers_alive          1 -3656.2  4.128   0.04218 *  
## fungicide:crithidia    1 -3660.3  0.033   0.85554    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(pm1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                 Chisq Df Pr(>Chisq)    
## block         44.0890  8  5.474e-07 ***
## crithidia      5.1193  1    0.02366 *  
## fungicide      2.5169  1    0.11263    
## workers_alive  0.2880  1    0.59149    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(pm1));qqline(resid(pm1))

Anova(pm2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: box
##                       Chisq Df Pr(>Chisq)    
## fungicide            1.6293  1    0.20179    
## crithidia            4.3682  1    0.03662 *  
## block               36.0573  8  1.714e-05 ***
## workers_alive        5.7953  1    0.01607 *  
## fungicide:crithidia  0.0233  1    0.87870    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
residuals <- resid(pm2)
summary(pm1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ block + crithidia + fungicide + workers_alive + (1 | colony)
##    Data: pollen_subset
## 
## REML criterion at convergence: -2550.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.5762 -0.4671  0.1651  0.6295  2.1554 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  colony   (Intercept) 0.0003166 0.01779 
##  Residual             0.0002581 0.01606 
## Number of obs: 505, groups:  colony, 36
## 
## Fixed effects:
##                 Estimate Std. Error t value
## (Intercept)    0.1590119  0.0123539  12.871
## block4         0.0365948  0.0129578   2.824
## block6        -0.0339113  0.0129403  -2.621
## block7        -0.0010390  0.0129890  -0.080
## block8         0.0098421  0.0129435   0.760
## block9         0.0108862  0.0129439   0.841
## block10        0.0266132  0.0129455   2.056
## block11       -0.0199890  0.0129890  -1.539
## block12       -0.0005906  0.0129492  -0.046
## crithidia     -0.0138796  0.0061344  -2.263
## fungicide     -0.0097021  0.0061155  -1.586
## workers_alive  0.0007725  0.0014394   0.537
## 
## Correlation of Fixed Effects:
##             (Intr) block4 block6 block7 block8 block9 blck10 blck11 blck12
## block4      -0.495                                                        
## block6      -0.532  0.499                                                 
## block7      -0.571  0.493  0.499                                          
## block8      -0.533  0.499  0.500  0.499                                   
## block9      -0.513  0.500  0.500  0.497  0.500                            
## block10     -0.537  0.498  0.500  0.500  0.500  0.499                     
## block11     -0.571  0.493  0.499  0.504  0.499  0.497  0.500              
## block12     -0.543  0.497  0.500  0.501  0.500  0.499  0.500  0.501       
## crithidia   -0.306 -0.005  0.002  0.009  0.002 -0.002  0.003  0.009  0.004
## fungicide   -0.286 -0.003  0.001  0.006  0.001 -0.001  0.002  0.006  0.002
## workers_alv -0.574 -0.050  0.014  0.085  0.016 -0.018  0.024  0.085  0.034
##             crithd fungcd
## block4                   
## block6                   
## block7                   
## block8                   
## block9                   
## block10                  
## block11                  
## block12                  
## crithidia                
## fungicide    0.007       
## workers_alv  0.105  0.070
plot(pm1)

pollen %>%
  wilcox.test(whole_dif ~ crithidia, data = .)
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  whole_dif by crithidia
## W = 88668, p-value = 5.97e-09
## alternative hypothesis: true location shift is not equal to 0
pollen %>% 
  ggplot(aes(x = factor(crithidia),
             y = whole_dif)) +
  geom_boxplot(aes(fill = factor(crithidia))) +
  geom_jitter(alpha = 0.4) +               # add data points
  theme(legend.position = "none")   

#this model says: average pollen consumed ~ yes/no Fung + yes/no Crit. + workers surviving when colony was frozen + time (id is pollen ball id, meaning it is the pollen ball number) + block + random effect of colony) 

pe <- emmeans(pol.mod1, pairwise ~ crithidia, type = "response")
pe
## $emmeans
##  crithidia emmean      SE   df lower.CL upper.CL
##          0  0.159 0.00368 25.1    0.151    0.167
##          1  0.148 0.00368 25.1    0.141    0.156
## 
## Results are averaged over the levels of: block, fungicide 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate      SE   df t.ratio p.value
##  crithidia0 - crithidia1   0.0105 0.00522 25.5   2.011  0.0550
## 
## Results are averaged over the levels of: block, fungicide 
## Degrees-of-freedom method: kenward-roger
kruskal.test(whole_dif ~ crithidia, data = pollen)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  whole_dif by crithidia
## Kruskal-Wallis chi-squared = 33.846, df = 1, p-value = 5.964e-09
kruskal.test(whole_dif ~ treatment, data = pollen)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  whole_dif by treatment
## Kruskal-Wallis chi-squared = 43.371, df = 3, p-value = 2.053e-09
library(dunn.test)
## Warning: package 'dunn.test' was built under R version 4.2.3
dunn_test <- dunn.test(pollen$whole_dif, pollen$treatment, method = "bonferroni")
##   Kruskal-Wallis rank sum test
## 
## data: x and group
## Kruskal-Wallis chi-squared = 43.371, df = 3, p-value = 0
## 
## 
##                            Comparison of x by group                            
##                                  (Bonferroni)                                  
## Col Mean-|
## Row Mean |          1          2          3
## ---------+---------------------------------
##        2 |   2.712047
##          |    0.0201*
##          |
##        3 |   6.222593   3.505382
##          |    0.0000*    0.0014*
##          |
##        4 |   4.715377   2.014187  -1.472871
##          |    0.0000*     0.1320     0.4224
## 
## alpha = 0.05
## Reject Ho if p <= alpha/2
# Output the result of Dunn test
print(dunn_test)
## $chi2
## [1] 43.37096
## 
## $Z
## [1]  2.712048  6.222593  3.505383  4.715377  2.014188 -1.472871
## 
## $P
## [1] 3.343448e-03 2.445020e-10 2.279758e-04 1.206315e-06 2.199490e-02
## [6] 7.039285e-02
## 
## $P.adjusted
## [1] 2.006069e-02 1.467012e-09 1.367855e-03 7.237892e-06 1.319694e-01
## [6] 4.223571e-01
## 
## $comparisons
## [1] "1 - 2" "1 - 3" "2 - 3" "1 - 4" "2 - 4" "3 - 4"
pairwise.wilcox.test(pollen$whole_dif, pollen$crithidia,
                     p.adjust.method = "BH")
## 
##  Pairwise comparisons using Wilcoxon rank sum test with continuity correction 
## 
## data:  pollen$whole_dif and pollen$crithidia 
## 
##   0    
## 1 6e-09
## 
## P value adjustment method: BH
ggplot(data = pollen_subset, aes(x = days, y = whole_dif, fill = treatment)) +
  geom_smooth() +
  labs(x = "Time", y = "Mean Pollen Consumed (g)")

pollen_sum <- pollen %>%
  group_by(treatment) %>%
  summarise(mean = mean(whole_dif),
            sd = sd(whole_dif),
            n = length(whole_dif)) %>%
  mutate(se = sd/sqrt(n))

pollen_box_sum <- pollen %>%
  group_by(treatment) %>%
  summarise(mean = mean(box),
            sd = sd(box),
            n = length(box)) %>%
  mutate(se = sd/sqrt(n))

pollen_sum 
## # A tibble: 4 × 5
##   treatment  mean    sd     n     se
##   <fct>     <dbl> <dbl> <int>  <dbl>
## 1 1         0.493 0.333   184 0.0245
## 2 2         0.426 0.317   188 0.0231
## 3 3         0.327 0.250   195 0.0179
## 4 4         0.376 0.280   188 0.0204
ggplot(data = pollen_sum, aes(x = treatment, y = mean, fill = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 0.55)) +
  geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Pollen Consumed (g)") +
  annotate(
    geom = "text",
    x = 3,
    y = 0.55,
    label = "P = ?",
    size = 8
  ) + 
  theme_classic(base_size = 20) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
  geom_segment(x = 1, xend = 2, y = 0.54, yend = 0.54, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 0.54, yend = 0.53, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 0.54, yend = 0.53, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 4, y = 0.42, yend = 0.42, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 0.42, yend = 0.41, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 0.42, yend = 0.41, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 1.5, y = 0.55, label = "a", size = 6, vjust = -0.5) +
  geom_text(x = 3.5, y = 0.43, label = "b", size = 6, vjust = -0.5)

ggplot(data = pollen_sum, aes(x = treatment, y = mean, fill = treatment)) +
   geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
   coord_cartesian(ylim = c(0, 0.55)) +
  geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Pollen Consumed (g)") +
  annotate(
    geom = "text",
    x = 3,
    y = 0.55,
    label = "P = 0.07",
    size = 8
  ) + 
  theme_classic(base_size = 20) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
   theme(legend.position = "none")

Worker Survival

duration$fungicide <- as.logical(duration$fungicide)
duration$crithidia <- as.logical(duration$crithidia)

cbw1 <- glm(cbind(workers_alive, workers_dead) ~ fungicide*crithidia + mean.pollen + block + days_active, data = duration, family = binomial("logit"))
Anova(cbw1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(workers_alive, workers_dead)
##                     LR Chisq Df Pr(>Chisq)    
## fungicide             0.8742  1    0.34980    
## crithidia             3.4505  1    0.06323 .  
## mean.pollen          20.4002  1  6.282e-06 ***
## block                19.4531  8    0.01262 *  
## days_active           0.6021  1    0.43779    
## fungicide:crithidia   1.1590  1    0.28168    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(cbw1, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(workers_alive, workers_dead) ~ fungicide * crithidia + 
##     mean.pollen + block + days_active
##                     Df Deviance     AIC     LRT  Pr(>Chi)    
## <none>                   24.949  92.390                      
## mean.pollen          1   45.349 110.790 20.4002 6.282e-06 ***
## block                8   44.402  95.843 19.4531   0.01262 *  
## days_active          1   25.551  90.992  0.6021   0.43779    
## fungicide:crithidia  1   26.108  91.549  1.1590   0.28168    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
cbw1 <- glm(cbind(workers_alive, workers_dead) ~ fungicide + crithidia + mean.pollen + block + days_active, data = duration, family = binomial("logit"))
Anova(cbw1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(workers_alive, workers_dead)
##             LR Chisq Df Pr(>Chisq)    
## fungicide     0.8742  1    0.34980    
## crithidia     3.4505  1    0.06323 .  
## mean.pollen  20.9469  1  4.722e-06 ***
## block        20.1480  8    0.00979 ** 
## days_active   0.2346  1    0.62810    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(cbw1, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(workers_alive, workers_dead) ~ fungicide + crithidia + 
##     mean.pollen + block + days_active
##             Df Deviance     AIC     LRT  Pr(>Chi)    
## <none>           26.108  91.549                      
## fungicide    1   26.982  90.423  0.8742   0.34980    
## crithidia    1   29.559  92.999  3.4505   0.06323 .  
## mean.pollen  1   47.055 110.496 20.9469 4.722e-06 ***
## block        8   46.256  95.697 20.1480   0.00979 ** 
## days_active  1   26.343  89.784  0.2346   0.62810    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
cbw3 <- update(cbw1, .~. -days_active)


qqnorm(resid(cbw3));qqline(resid(cbw3))

Anova(cbw3)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(workers_alive, workers_dead)
##             LR Chisq Df Pr(>Chisq)    
## fungicide     0.9395  1   0.332394    
## crithidia     3.8291  1   0.050370 .  
## mean.pollen  26.4903  1  2.649e-07 ***
## block        21.1782  8   0.006689 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(cbw3)
## 
## Call:
## glm(formula = cbind(workers_alive, workers_dead) ~ fungicide + 
##     crithidia + mean.pollen + block, family = binomial("logit"), 
##     data = duration)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9252  -0.5366   0.1348   0.6577   1.5162  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)     -2.1264     1.0823  -1.965   0.0495 *  
## fungicideTRUE    0.4218     0.4386   0.962   0.3362    
## crithidiaTRUE   -0.8727     0.4483  -1.947   0.0516 .  
## mean.pollen     10.4521     2.5014   4.179 2.93e-05 ***
## block4          14.8345  3600.7582   0.004   0.9967    
## block6           0.3860     0.7888   0.489   0.6246    
## block7          -1.1692     0.7926  -1.475   0.1402    
## block8           0.6117     0.8994   0.680   0.4965    
## block9           0.9506     0.9531   0.997   0.3186    
## block10         -2.3981     0.9979  -2.403   0.0163 *  
## block11         -0.1471     0.7723  -0.191   0.8489    
## block12         -1.9234     0.9288  -2.071   0.0384 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 104.128  on 35  degrees of freedom
## Residual deviance:  26.343  on 24  degrees of freedom
## AIC: 89.784
## 
## Number of Fisher Scoring iterations: 18
worker_sum <-duration %>%
  group_by(treatment) %>%
  summarise(m = mean(workers_alive),
            sd = sd(workers_alive))

worker_sum
## # A tibble: 4 × 3
##   treatment     m    sd
##   <fct>     <dbl> <dbl>
## 1 1          4.33 0.866
## 2 2          3.78 1.20 
## 3 3          2.78 1.86 
## 4 4          2.89 1.96
worker_sum <-duration %>%
  group_by(treatment) %>%
  summarise(m = mean(workers_alive),
            sd = sd(workers_alive),
            l = length(workers_alive)) %>%
  mutate(se = sd/sqrt(l))


worker_sum
## # A tibble: 4 × 5
##   treatment     m    sd     l    se
##   <fct>     <dbl> <dbl> <int> <dbl>
## 1 1          4.33 0.866     9 0.289
## 2 2          3.78 1.20      9 0.401
## 3 3          2.78 1.86      9 0.619
## 4 4          2.89 1.96      9 0.655
workers$prob <- workers$days_alive / workers$days_active

worker_prob_sum <-workers %>%
  group_by(treatment) %>%
  summarise(m = mean(prob),
            sd = sd(prob),
            l = length(prob)) %>%
  mutate(se = sd/sqrt(l))

worker_prob_sum$plot <- worker_prob_sum$m + worker_prob_sum$se

worker_prob_sum$treatment <- as.factor(worker_prob_sum$treatment)
ggplot(data = worker_prob_sum, aes(x = treatment, y = m, fill = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)) +
  coord_cartesian(ylim = c(0.5, 1.05)) +
  geom_errorbar(aes(ymin = m - se, ymax = m + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Probability") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 3.5,
    y = 1.05,
    label = "P = 0.05",
    size = 7
  ) +  # Add stripes to the fourth column
  scale_fill_manual(values = c("lightgreen", "lightblue", "grey", "lightblue")) +
  scale_pattern_manual(values = c("none", "none", "none", "stripe")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
  geom_segment(x = 1, xend = 2, y = 1, yend = 1, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 0.98, yend = 1.02, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 0.98, yend = 1.02, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 4, y = 0.9, yend = 0.9, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 0.88, yend = 0.92, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 0.88, yend = 0.92, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 1.5, y = 1.01, label = "a", size = 6, vjust = -0.5) +
  geom_text(x = 3.5, y = 0.93, label = "b", size = 6, vjust = -0.5)

COX PH Workers

library(survival)
library(coxme)
## Warning: package 'coxme' was built under R version 4.2.3
library(survminer)
## Warning: package 'survminer' was built under R version 4.2.3
workers$censor_status <- ifelse(workers$premature_death == 0, 1, 2)
workers$fungicide <- as.factor(workers$fungicide)
workers$crithidia <- as.factor(workers$crithidia)

all_bees$bee_id <-as.factor(all_bees$bee_id)
all_bees$fungicide <- as.factor(all_bees$fungicide)
all_bees$crithidia <- as.factor(all_bees$crithidia)
all_bees$round <- as.factor(all_bees$round)
workers$inoculate_round <- as.factor(workers$inoculate_round)

library(survminer)

all_bees$censor_status <- as.double(all_bees$censor_status)

res.cox <- coxme(Surv(days_since_innoculation, alive_dead) ~ fungicide + crithidia + (1|bee_id), data = all_bees)
res.cox
## Cox mixed-effects model fit by maximum likelihood
##   Data: all_bees
##   events, n = 2218, 2366
##   Iterations= 8 34 
##                     NULL Integrated    Fitted
## Log-likelihood -15132.84  -15130.55 -15130.51
## 
##                   Chisq   df       p   AIC    BIC
## Integrated loglik  4.57 3.00 0.20589 -1.43 -18.54
##  Penalized loglik  4.65 2.04 0.10115  0.57 -11.07
## 
## Model:  Surv(days_since_innoculation, alive_dead) ~ fungicide + crithidia +      (1 | bee_id) 
## Fixed coefficients
##                      coef exp(coef)   se(coef)     z    p
## fungicideTRUE -0.05497704 0.9465069 0.04249175 -1.29 0.20
## crithidiaTRUE -0.07242452 0.9301360 0.04267251 -1.70 0.09
## 
## Random effects
##  Group  Variable  Std Dev      Variance    
##  bee_id Intercept 4.318341e-03 1.864807e-05
Anova(res.cox)
## Analysis of Deviance Table (Type II tests)
## 
## Response: Surv(days_since_innoculation, alive_dead)
##           Df  Chisq Pr(>Chisq)  
## fungicide  1 1.6740    0.19572  
## crithidia  1 2.8805    0.08966 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emm.cox <- emmeans(res.cox, pairwise ~ crithidia, type = "response")
pairs(emm.cox)
##  contrast     ratio     SE  df null z.ratio p.value
##  FALSE / TRUE  1.08 0.0459 Inf    1   1.697  0.0897
## 
## Results are averaged over the levels of: fungicide 
## Tests are performed on the log scale
emmdf <- as.data.frame(emm.cox$contrasts)
emmdf
##  contrast        ratio         SE  df null z.ratio p.value
##  FALSE / TRUE 1.075112 0.04587772 Inf    1   1.697  0.0897
## 
## Results are averaged over the levels of: fungicide 
## Tests are performed on the log scale
emmdf <- setDT(emmdf)

workcld <- cld(object = emm.cox,
               adjust = "Tukey",
               alpha = 0.05,
               Letters = letters)
workcld
##  crithidia response     SE  df asymp.LCL asymp.UCL .group
##  TRUE         0.962 0.0219 Inf     0.915      1.01  a    
##  FALSE        1.035 0.0206 Inf     0.989      1.08  a    
## 
## Results are averaged over the levels of: fungicide 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 2 estimates 
## Intervals are back-transformed from the log scale 
## Tests are performed on the log scale 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
require("survival")

ggsurvplot(survfit(Surv(days_since_innoculation, alive_dead) ~ treatment, data = all_bees),
           legend.title = "",
           censor.shape = 124, 
           censor.size = 2.5)

ggsurvplot(
  survfit(Surv(days_since_innoculation, alive_dead) ~ treatment, data = all_bees),
  legend.title = "",
  censor.shape = 124, 
  censor.size = 2.5,
  ylim = c(0.7, 1),
   palette = c("green", "lightblue", "darkblue", "orange")
)
## Warning: Removed 40 rows containing missing values (`geom_step()`).
## Warning: Removed 36 rows containing missing values (`geom_point()`).
## Warning: Removed 40 rows containing missing values (`geom_step()`).
## Warning: Removed 36 rows containing missing values (`geom_point()`).

dfcox <- read_csv("data for cox ph.csv")

dfcox$bee_id <- as.factor(dfcox$bee_id)
dfcox$fungicide <- as.factor(dfcox$fungicide)
dfcox$crithidia <- as.factor(dfcox$crithidia)
dfcox$qro <- as.factor(dfcox$qro)
dfcox$inoculate_round <- as.factor(dfcox$inoculate_round)
dfcox$inoculate <- as.factor(dfcox$inoculate)
dfcox$inoculate_01 <- as.factor(dfcox$inoculate_01)
dfcox$premature_death <- as.factor(dfcox$premature_death)
dfcox$treatment <- as.factor(dfcox$treatment)
dfcox$replicate <- as.factor(dfcox$replicate)
dfcox$colony <- as.factor(dfcox$colony)


cox <- coxph(Surv(days_alive, censor_status) ~ crithidia, data = dfcox)

drop1(cox, test = "Chisq")
## Single term deletions
## 
## Model:
## Surv(days_alive, censor_status) ~ crithidia
##           Df    AIC   LRT Pr(>Chi)   
## <none>       567.54                  
## crithidia  1 573.62 8.081 0.004473 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(cox)
## Analysis of Deviance Table
##  Cox model: response is Surv(days_alive, censor_status)
## Terms added sequentially (first to last)
## 
##            loglik Chisq Df Pr(>|Chi|)   
## NULL      -286.81                       
## crithidia -282.77 8.081  1   0.004473 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aa_fit <- aareg(Surv(days_alive, censor_status) ~ fungicide + crithidia + replicate, data = dfcox )

library(ggfortify)
## Warning: package 'ggfortify' was built under R version 4.2.3
autoplot(aa_fit) # this is in ggfortify

ggsurvplot(
  survfit(Surv(days_alive, censor_status)~treatment, data =dfcox),
  legend.title = "",
  censor.shape = 124, 
  censor.size = 2.5,
  ylim = c(0.7, 1),
  legend.labs=c("Control", "Fungicide", "Fungicide & Parasite", "Parasite"),
   palette = c("darkgreen", "lightblue", "darkblue", "orange")
) +
  labs(
    x = "Days",                      # X-axis label
    y = "Probability of Survival",  # Y-axis label          # Legend title
    fill = "Treatments")
## Warning: Removed 20 rows containing missing values (`geom_step()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 20 rows containing missing values (`geom_step()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).

ggsurvplot(
  survfit(Surv(days_alive, censor_status)~crithidia, data =dfcox),
  legend.title = "",
  censor.shape = 124, 
  censor.size = 2.5,
  ylim = c(0.7, 1),
  legend.labs=c("No Crithidia", "Crithidia"),
   palette = c("darkgreen", "lightblue")
) +
  labs(
    x = "Days",                      # X-axis label
    y = "Probability of Survival",  # Y-axis label          # Legend title
    fill = "Treatments")
## Warning: Removed 11 rows containing missing values (`geom_step()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).
## Warning: Removed 11 rows containing missing values (`geom_step()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

Days workers survive

dayswrk <- glmer.nb(days_alive ~ fungicide*crithidia + avg_pollen + inoculate + block + (1|colony), data = workers)
drop1(dayswrk, test = "Chisq")
## Single term deletions
## 
## Model:
## days_alive ~ fungicide * crithidia + avg_pollen + inoculate + 
##     block + (1 | colony)
##                     npar    AIC     LRT Pr(Chi)
## <none>                   1391.6                
## avg_pollen             1 1390.4  0.7603  0.3832
## inoculate              1 1389.7  0.1376  0.7107
## block                  8 1387.7 12.0839  0.1475
## fungicide:crithidia    1 1390.0  0.4238  0.5151
dayswrk <- glmer(days_alive ~ fungicide + crithidia + block + inoculate + avg_pollen + (1|colony), data = workers, family = "poisson")
summary(dayswrk)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: poisson  ( log )
## Formula: days_alive ~ fungicide + crithidia + block + inoculate + avg_pollen +  
##     (1 | colony)
##    Data: workers
## 
##      AIC      BIC   logLik deviance df.resid 
##   1468.6   1513.2   -720.3   1440.6      165 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.3900 -0.1200  0.2025  0.6255  2.7461 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  colony (Intercept) 0.003402 0.05832 
## Number of obs: 179, groups:  colony, 36
## 
## Fixed effects:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    3.74344    0.07268  51.509  < 2e-16 ***
## fungicide1    -0.01336    0.03173  -0.421  0.67366    
## crithidia1    -0.04279    0.03353  -1.276  0.20188    
## block4        -0.12151    0.08524  -1.426  0.15400    
## block6         0.02322    0.06673   0.348  0.72785    
## block7        -0.20904    0.06574  -3.180  0.00147 ** 
## block8        -0.12208    0.06704  -1.821  0.06861 .  
## block9        -0.06014    0.06424  -0.936  0.34917    
## block10       -0.17444    0.07153  -2.439  0.01474 *  
## block11       -0.14699    0.06612  -2.223  0.02622 *  
## block12       -0.09583    0.06495  -1.475  0.14009    
## inoculateTRUE -0.02337    0.02997  -0.780  0.43555    
## avg_pollen     0.13265    0.12457   1.065  0.28694    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dayswrk <- glmer.nb(days_alive ~ fungicide + crithidia + block + inoculate + avg_pollen + (1|colony), data = workers)
drop1(dayswrk, test = "Chisq")
## Single term deletions
## 
## Model:
## days_alive ~ fungicide + crithidia + block + inoculate + avg_pollen + 
##     (1 | colony)
##            npar    AIC     LRT Pr(Chi)
## <none>          1390.0                
## fungicide     1 1388.2  0.1331  0.7153
## crithidia     1 1389.0  0.9367  0.3331
## block         8 1386.2 12.1287  0.1456
## inoculate     1 1388.2  0.1353  0.7130
## avg_pollen    1 1388.8  0.7619  0.3827
dayswrk1 <- update(dayswrk, .~. -inoculate)
drop1(dayswrk1, test = "Chisq")
## Single term deletions
## 
## Model:
## days_alive ~ fungicide + crithidia + block + avg_pollen + (1 | 
##     colony)
##            npar    AIC     LRT Pr(Chi)
## <none>          1388.2                
## fungicide     1 1386.3  0.1346  0.7137
## crithidia     1 1387.1  0.9478  0.3303
## block         8 1384.3 12.1823  0.1433
## avg_pollen    1 1386.9  0.7709  0.3799
dayswrk2 <- update(dayswrk1, .~. -avg_pollen)
drop1(dayswrk2, test = "Chisq")
## Single term deletions
## 
## Model:
## days_alive ~ fungicide + crithidia + block + (1 | colony)
##           npar    AIC     LRT Pr(Chi)
## <none>         1386.9                
## fungicide    1 1385.3  0.3485  0.5549
## crithidia    1 1387.0  2.0286  0.1544
## block        8 1382.4 11.4313  0.1784
dayswrk4 <- update(dayswrk2, .~. -fungicide)
drop1(dayswrk4, test = "Chisq")
## Single term deletions
## 
## Model:
## days_alive ~ crithidia + block + (1 | colony)
##           npar    AIC     LRT Pr(Chi)
## <none>         1385.3                
## crithidia    1 1385.3  2.0542  0.1518
## block        8 1380.6 11.3002  0.1853
Anova(dayswrk1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: days_alive
##              Chisq Df Pr(>Chisq)
## fungicide   0.1346  1     0.7137
## crithidia   0.9478  1     0.3303
## block      12.1786  8     0.1434
## avg_pollen  0.7699  1     0.3803
worker_days_sum <-workers %>%
  group_by(treatment) %>%
  summarise(m = mean(days_alive),
            sd = sd(days_alive),
            l = length(days_alive)) %>%
  mutate(se = sd/sqrt(l))

worker_days_sum$plot <- worker_days_sum$m + worker_days_sum$se

worker_days_sum$treatment <- as.factor(worker_days_sum$treatment)
ggplot(data = worker_days_sum, aes(x = treatment, y = m, fill = treatment, pattern = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(20, 45)) +
  geom_errorbar(aes(ymin = m - se, ymax = m + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Days") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 1,
    y = 45,
    label = "P > 0.05",
    size = 7
  ) + scale_fill_manual(values = c("lightgreen", "lightblue", "grey", "lightblue")) +
  scale_pattern_manual(values = c("none", "none", "none", "stripe")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none")

durmod <- glm.nb(days_active ~ fungicide + crithidia + mean.pollen + days_first_ov, data = duration)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(durmod, test = "Chisq")
## Single term deletions
## 
## Model:
## days_active ~ fungicide + crithidia + mean.pollen + days_first_ov
##               Df Deviance    AIC     LRT Pr(>Chi)
## <none>             11.595 218.93                 
## fungicide      1   11.636 216.97 0.04072   0.8401
## crithidia      1   12.041 217.38 0.44567   0.5044
## mean.pollen    1   12.632 217.97 1.03675   0.3086
## days_first_ov  1   12.261 217.60 0.66545   0.4146
durmod <- glm.nb(days_active ~ fungicide + crithidia + mean.pollen, data = duration)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(durmod, test = "Chisq")
## Single term deletions
## 
## Model:
## days_active ~ fungicide + crithidia + mean.pollen
##             Df Deviance    AIC    LRT Pr(>Chi)  
## <none>           12.371 223.46                  
## fungicide    1   12.379 221.47 0.0079  0.92916  
## crithidia    1   12.748 221.84 0.3771  0.53917  
## mean.pollen  1   16.304 225.40 3.9330  0.04735 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dm2 <- update(durmod, .~. -fungicide)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(dm2, test = "Chisq")
## Single term deletions
## 
## Model:
## days_active ~ crithidia + mean.pollen
##             Df Deviance    AIC    LRT Pr(>Chi)  
## <none>           12.379 221.47                  
## crithidia    1   12.752 219.84 0.3734  0.54115  
## mean.pollen  1   16.462 223.55 4.0834  0.04331 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(durmod)
## 
## Call:
## glm.nb(formula = days_active ~ fungicide + crithidia + mean.pollen, 
##     data = duration, init.theta = 2513306.23, link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -2.23370  -0.31100   0.04984   0.36315   1.08001  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    3.885269   0.073759  52.675   <2e-16 ***
## fungicideTRUE  0.004474   0.050325   0.089   0.9292    
## crithidiaTRUE  0.031525   0.051345   0.614   0.5392    
## mean.pollen   -0.237193   0.120287  -1.972   0.0486 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(2513306) family taken to be 1)
## 
##     Null deviance: 17.770  on 35  degrees of freedom
## Residual deviance: 12.371  on 32  degrees of freedom
## AIC: 225.46
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  2513306 
##           Std. Err.:  66077581 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -215.463
Anova(durmod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: days_active
##             LR Chisq Df Pr(>Chisq)  
## fungicide     0.0079  1    0.92916  
## crithidia     0.3771  1    0.53917  
## mean.pollen   3.9330  1    0.04735 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(duration$treatment, duration$days_active)

Worker dry weight

workers$dry <- as.double(workers$dry)
## Warning: NAs introduced by coercion
hist(workers$dry)

shapiro.test(workers$dry)
## 
##  Shapiro-Wilk normality test
## 
## data:  workers$dry
## W = 0.96362, p-value = 0.0001443
workers$logdry <- log(workers$dry)


shapiro.test(workers$logdry)
## 
##  Shapiro-Wilk normality test
## 
## data:  workers$logdry
## W = 0.98991, p-value = 0.2444
hist(workers$logdry)

wrkdry <- lmer(logdry ~ fungicide*crithidia + avg_pollen + inoculate +block + (1|colony), data = workers)
drop1(wrkdry, test = "Chisq")
## Single term deletions
## 
## Model:
## logdry ~ fungicide * crithidia + avg_pollen + inoculate + block + 
##     (1 | colony)
##                     npar    AIC    LRT   Pr(Chi)    
## <none>                   66.985                     
## avg_pollen             1 85.038 20.052 7.535e-06 ***
## inoculate              1 64.992  0.007    0.9349    
## block                  8 87.068 36.083 1.696e-05 ***
## fungicide:crithidia    1 65.393  0.408    0.5231    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wrkdry <- lmer(logdry ~ fungicide + crithidia + avg_pollen + inoculate +block + (1|colony), data = workers)
drop1(wrkdry, test = "Chisq")
## Single term deletions
## 
## Model:
## logdry ~ fungicide + crithidia + avg_pollen + inoculate + block + 
##     (1 | colony)
##            npar    AIC    LRT   Pr(Chi)    
## <none>          65.393                     
## fungicide     1 66.158  2.765  0.096355 .  
## crithidia     1 71.006  7.613  0.005795 ** 
## avg_pollen    1 83.162 19.768 8.742e-06 ***
## inoculate     1 63.400  0.007  0.932656    
## block         8 85.142 35.749 1.952e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wrkdry1 <- update(wrkdry, .~. -inoculate)
drop1(wrkdry1, test = "Chisq")
## Single term deletions
## 
## Model:
## logdry ~ fungicide + crithidia + avg_pollen + block + (1 | colony)
##            npar    AIC    LRT   Pr(Chi)    
## <none>          63.400                     
## fungicide     1 64.165  2.765  0.096363 .  
## crithidia     1 69.016  7.616  0.005786 ** 
## avg_pollen    1 81.172 19.772 8.725e-06 ***
## block         8 83.155 35.754 1.947e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wm2 <- update(wrkdry1, .~. -fungicide)
drop1(wm2, test = "Chisq")
## Single term deletions
## 
## Model:
## logdry ~ crithidia + avg_pollen + block + (1 | colony)
##            npar    AIC    LRT   Pr(Chi)    
## <none>          64.165                     
## crithidia     1 68.571  6.406   0.01137 *  
## avg_pollen    1 84.273 22.108 2.578e-06 ***
## block         8 82.775 34.610 3.149e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(wrkdry, wm2, test = "Chisq")
## Data: workers
## Models:
## wm2: logdry ~ crithidia + avg_pollen + block + (1 | colony)
## wrkdry: logdry ~ fungicide + crithidia + avg_pollen + inoculate + block + (1 | colony)
##        npar    AIC    BIC  logLik deviance  Chisq Df Pr(>Chisq)
## wm2      13 64.165 105.45 -19.082   38.165                     
## wrkdry   15 65.393 113.03 -17.697   35.393 2.7719  2     0.2501
summary(wrkdry1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: logdry ~ fungicide + crithidia + avg_pollen + block + (1 | colony)
##    Data: workers
## 
## REML criterion at convergence: 77.6
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.02299 -0.56652 -0.04535  0.61291  2.16906 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  colony   (Intercept) 0.008674 0.09313 
##  Residual             0.070615 0.26574 
## Number of obs: 177, groups:  colony, 36
## 
## Fixed effects:
##              Estimate Std. Error t value
## (Intercept) -3.133210   0.120772 -25.943
## fungicide1  -0.072102   0.052330  -1.378
## crithidia1  -0.130746   0.055229  -2.367
## avg_pollen   0.849884   0.203664   4.173
## block4      -0.293828   0.140549  -2.091
## block6       0.122021   0.112098   1.089
## block7      -0.126237   0.107821  -1.171
## block8       0.004312   0.110376   0.039
## block9      -0.418020   0.107027  -3.906
## block10     -0.329383   0.117314  -2.808
## block11     -0.297229   0.109508  -2.714
## block12     -0.212682   0.107617  -1.976
## 
## Correlation of Fixed Effects:
##            (Intr) fngcd1 crthd1 avg_pl block4 block6 block7 block8 block9
## fungicide1 -0.386                                                        
## crithidia1 -0.481  0.105                                                 
## avg_pollen -0.722  0.253  0.400                                          
## block4      0.134 -0.165 -0.260 -0.650                                   
## block6     -0.621  0.063  0.118  0.278  0.181                            
## block7     -0.399 -0.020 -0.027 -0.049  0.408  0.458                     
## block8     -0.244 -0.064 -0.101 -0.254  0.532  0.390  0.491              
## block9     -0.390 -0.018 -0.028 -0.070  0.424  0.456  0.497  0.500       
## block10    -0.103 -0.105 -0.166 -0.414  0.615  0.318  0.471  0.545  0.483
## block11    -0.565  0.054  0.080  0.181  0.252  0.515  0.474  0.425  0.474
## block12    -0.348 -0.032 -0.050 -0.126  0.459  0.438  0.497  0.512  0.504
##            blck10 blck11
## fungicide1              
## crithidia1              
## avg_pollen              
## block4                  
## block6                  
## block7                  
## block8                  
## block9                  
## block10                 
## block11     0.368       
## block12     0.504  0.461
Anova(wrkdry1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: logdry
##              Chisq Df Pr(>Chisq)    
## fungicide   1.8984  1    0.16825    
## crithidia   5.6043  1    0.01792 *  
## avg_pollen 17.4136  1  3.007e-05 ***
## block      40.8700  8  2.205e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(wrkdry1));qqline(resid(wrkdry1))

pe <- emmeans(wrkdry1, pairwise ~ crithidia, type = "response")
pe
## $emmeans
##  crithidia emmean     SE   df lower.CL upper.CL
##  0          -2.98 0.0372 23.8    -3.06    -2.91
##  1          -3.11 0.0377 24.1    -3.19    -3.04
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate     SE   df t.ratio p.value
##  crithidia0 - crithidia1    0.131 0.0552 23.9   2.367  0.0264
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger
pairs(pe)
##  contrast                estimate     SE   df t.ratio p.value
##  crithidia0 - crithidia1    0.131 0.0552 23.9   2.367  0.0264
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger
wrkdry.df <- na.omit(workers)

wrkdrysum <- wrkdry.df %>%
  group_by(treatment) %>%
  summarise(m = mean(dry),
            sd = sd(dry),
            n = length(dry)) %>%
  mutate(se = sd/sqrt(n))

wrkdrysum
## # A tibble: 4 × 5
##   treatment      m     sd     n      se
##   <fct>      <dbl>  <dbl> <int>   <dbl>
## 1 1         0.0586 0.0186    44 0.00280
## 2 2         0.0528 0.0169    45 0.00252
## 3 3         0.0416 0.0132    44 0.00199
## 4 4         0.0487 0.0182    44 0.00275
wtuk.means <- emmeans(object = wrkdry1,
                      specs = "crithidia",
                      adjust = "Tukey",
                      type = "response")

wtuk.means
##  crithidia emmean     SE   df lower.CL upper.CL
##  0          -2.98 0.0372 23.8    -3.07    -2.89
##  1          -3.11 0.0377 24.1    -3.20    -3.02
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 2 estimates
w.cld.model <- cld(object = wtuk.means,
                   adjust = "Tukey",
                   Letters = letters,
                   alpha = 0.05)
w.cld.model
##  crithidia emmean     SE   df lower.CL upper.CL .group
##  1          -3.11 0.0377 24.1    -3.20    -3.02  a    
##  0          -2.98 0.0372 23.8    -3.07    -2.89   b   
## 
## Results are averaged over the levels of: fungicide, block 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 2 estimates 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
ggplot(data = wrkdrysum, aes(x = treatment, y = m, fill = treatment)) +
  geom_col(col = "black") +
  coord_cartesian(ylim = c(0, 0.08)) +
  scale_fill_viridis_d() +
  labs(x = "Treatment", y = "Worker Dry Weight (g)") +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) + 
  geom_errorbar(aes(ymin = m - se, ymax = m + se), width = 0.2, position = position_dodge(0.9))  + 
  theme_classic(base_size = 20) +
  theme(legend.position = "none") +
  annotate(
    geom = "text",
    x = 4,
    y = 0.079,
    label = "P = 0.02",
    size = 7
  ) +
  theme(legend.position = "none")  +
  scale_x_discrete(labels = custom_labels) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) + 
  geom_segment(x = 1, xend = 2, y = 0.07, yend = 0.07, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 0.07, yend = 0.069, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 0.07, yend = 0.069, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 4, y = 0.06, yend = 0.06, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 0.06, yend = 0.059, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 0.06, yend = 0.059, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 1.5, y = 0.071, label = "a", size = 6, vjust = -0.5) +
  geom_text(x = 3.5, y = 0.061, label = "b", size = 6, vjust = -0.5)

ggplot(data = wrkdrysum, aes(x = treatment, y = m, fill = treatment, pattern = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 0.07)) +
  geom_errorbar(aes(ymin = m - se, ymax = m + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Worker Dry Weight (g)") +
  annotate(
    geom = "text",
    x = c(1, 2, 3, 4),
    y = wrkdrysum$m + wrkdrysum$se + 0.01,  # Adjust the y-position as needed
    label = c("a", "a", "b", "ab"),
    size = 8
  ) +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 4,
    y = 0.07,
    label = "P = 0.05",
    size = 7
  ) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "grey", "lightblue")) +
  scale_pattern_manual(values = c("none", "none", "none", "stripe")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none")

First Oviposition

duration$fungicide <- as.logical(duration$fungicide)
duration$crithidia <- as.logical(duration$crithidia)

ov <- glm.nb(days_first_ov ~ fungicide*crithidia + avg.pol + workers_alive + block, data = duration)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(ov, test = "Chisq")
## Single term deletions
## 
## Model:
## days_first_ov ~ fungicide * crithidia + avg.pol + workers_alive + 
##     block
##                     Df Deviance    AIC    LRT Pr(>Chi)  
## <none>                   17.299 193.75                  
## avg.pol              1   20.216 194.67 2.9167  0.08767 .
## workers_alive        1   18.139 192.59 0.8399  0.35944  
## block                8   26.334 186.79 9.0353  0.33933  
## fungicide:crithidia  1   17.727 192.18 0.4283  0.51283  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ov.pois <- glm(days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive + block, data = duration, family = "poisson")
summary(ov.pois)
## 
## Call:
## glm(formula = days_first_ov ~ fungicide + crithidia + avg.pol + 
##     workers_alive + block, family = "poisson", data = duration)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.6936  -0.3927  -0.1427   0.5417   1.3279  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    2.85680    0.28194  10.133   <2e-16 ***
## fungicideTRUE -0.03515    0.10714  -0.328   0.7428    
## crithidiaTRUE -0.14256    0.11684  -1.220   0.2224    
## avg.pol       -0.97454    0.60683  -1.606   0.1083    
## workers_alive -0.05975    0.05775  -1.035   0.3008    
## block4         0.49446    0.33514   1.475   0.1401    
## block6         0.48118    0.21249   2.264   0.0235 *  
## block7         0.22272    0.23082   0.965   0.3346    
## block8         0.26521    0.27207   0.975   0.3297    
## block9         0.19574    0.23070   0.848   0.3962    
## block10        0.34408    0.27195   1.265   0.2058    
## block11        0.21287    0.22151   0.961   0.3365    
## block12        0.13061    0.24776   0.527   0.5981    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 50.163  on 34  degrees of freedom
## Residual deviance: 17.728  on 22  degrees of freedom
##   (1 observation deleted due to missingness)
## AIC: 192.18
## 
## Number of Fisher Scoring iterations: 4
qqnorm(resid(ov.pois));qqline(resid(ov.pois))

ov <- glm.nb(days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive + block, data = duration)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(ov, test = "Chisq")
## Single term deletions
## 
## Model:
## days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive + 
##     block
##               Df Deviance    AIC    LRT Pr(>Chi)
## <none>             17.727 192.18                
## fungicide      1   17.835 190.29 0.1076   0.7429
## crithidia      1   19.227 191.68 1.4995   0.2208
## avg.pol        1   20.392 192.84 2.6647   0.1026
## workers_alive  1   18.797 191.25 1.0696   0.3010
## block          8   26.773 185.23 9.0457   0.3385
anova(ov.pois, ov, test = "Chisq")
## Analysis of Deviance Table
## 
## Model 1: days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive + 
##     block
## Model 2: days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive + 
##     block
##   Resid. Df Resid. Dev Df   Deviance Pr(>Chi)
## 1        22     17.728                       
## 2        22     17.727  0 0.00054378
qqnorm(resid(ov));qqline(resid(ov))

AIC(ov.pois, ov)
##         df      AIC
## ov.pois 13 192.1801
## ov      14 194.1806
drop1(ov.pois, test = "Chisq")
## Single term deletions
## 
## Model:
## days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive + 
##     block
##               Df Deviance    AIC    LRT Pr(>Chi)
## <none>             17.728 192.18                
## fungicide      1   17.836 190.29 0.1076   0.7429
## crithidia      1   19.227 191.68 1.4995   0.2207
## avg.pol        1   20.393 192.84 2.6648   0.1026
## workers_alive  1   18.798 191.25 1.0696   0.3010
## block          8   26.774 185.23 9.0460   0.3384
ov1 <- update(ov, .~. -block)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(ov1, test = "Chisq")
## Single term deletions
## 
## Model:
## days_first_ov ~ fungicide + crithidia + avg.pol + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             26.772 185.23                  
## fungicide      1   26.878 183.33 0.1053  0.74551  
## crithidia      1   28.305 184.76 1.5327  0.21571  
## avg.pol        1   32.704 189.16 5.9317  0.01487 *
## workers_alive  1   28.931 185.38 2.1591  0.14173  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ov2 <- update(ov1, .~. -workers_alive)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(ov2, test = "Chisq")
## Single term deletions
## 
## Model:
## days_first_ov ~ fungicide + crithidia + avg.pol
##           Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>         28.931 185.39                      
## fungicide  1   29.045 183.50  0.1146    0.7350    
## crithidia  1   29.519 183.97  0.5882    0.4431    
## avg.pol    1   49.820 204.27 20.8889 4.867e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(ov2)
## Analysis of Deviance Table (Type II tests)
## 
## Response: days_first_ov
##           LR Chisq Df Pr(>Chisq)    
## fungicide   0.1146  1     0.7350    
## crithidia   0.5882  1     0.4431    
## avg.pol    20.8889  1  4.867e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ov2)
## 
## Call:
## glm.nb(formula = days_first_ov ~ fungicide + crithidia + avg.pol, 
##     data = duration, init.theta = 151930.6281, link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -1.71248  -0.65163  -0.07036   0.53669   1.82330  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    2.95946    0.14611  20.255  < 2e-16 ***
## fungicideTRUE -0.03434    0.10142  -0.339    0.735    
## crithidiaTRUE -0.07821    0.10197  -0.767    0.443    
## avg.pol       -1.14088    0.25754  -4.430 9.43e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(151930.6) family taken to be 1)
## 
##     Null deviance: 50.159  on 34  degrees of freedom
## Residual deviance: 28.931  on 31  degrees of freedom
##   (1 observation deleted due to missingness)
## AIC: 187.39
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  151931 
##           Std. Err.:  5542697 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -177.386
plot(duration$treatment, duration$days_first_ov)

Duration

duration$fungicide <- as.factor(duration$fungicide)
duration$crithidia <- as.factor(duration$crithidia)

dm1 <- glm.nb(days_active ~ fungicide + crithidia + avg.pol, data = duration)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(dm1, test = "Chisq")
## Single term deletions
## 
## Model:
## days_active ~ fungicide + crithidia + avg.pol
##           Df Deviance    AIC    LRT Pr(>Chi)  
## <none>         12.371 223.46                  
## fungicide  1   12.379 221.47 0.0079  0.92916  
## crithidia  1   12.748 221.84 0.3771  0.53917  
## avg.pol    1   16.304 225.40 3.9330  0.04735 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(dm1)
## 
## Call:
## glm.nb(formula = days_active ~ fungicide + crithidia + avg.pol, 
##     data = duration, init.theta = 2513306.23, link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -2.23370  -0.31100   0.04984   0.36315   1.08001  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    3.885269   0.073759  52.675   <2e-16 ***
## fungicideTRUE  0.004474   0.050325   0.089   0.9292    
## crithidiaTRUE  0.031525   0.051345   0.614   0.5392    
## avg.pol       -0.237193   0.120287  -1.972   0.0486 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(2513306) family taken to be 1)
## 
##     Null deviance: 17.770  on 35  degrees of freedom
## Residual deviance: 12.371  on 32  degrees of freedom
## AIC: 225.46
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  2513306 
##           Std. Err.:  66077581 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -215.463
Anova(dm1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: days_active
##           LR Chisq Df Pr(>Chisq)  
## fungicide   0.0079  1    0.92916  
## crithidia   0.3771  1    0.53917  
## avg.pol     3.9330  1    0.04735 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Brood cells

brood$fungicide <- as.factor(brood$fungicide)
brood$crithidia <- as.factor(brood$crithidia)

plot(brood$treatment, brood$brood_cells)

brood.mod <- glm.nb(brood_cells ~ fungicide*crithidia + block + workers_alive + duration + avg_pollen, data = brood)
## Warning in glm.nb(brood_cells ~ fungicide * crithidia + block + workers_alive +
## : alternation limit reached
Anova(brood.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: brood_cells
##                     LR Chisq Df Pr(>Chisq)    
## fungicide              9.473  1   0.002085 ** 
## crithidia              0.483  1   0.487155    
## block                 87.471  8  1.515e-15 ***
## workers_alive         35.058  1  3.200e-09 ***
## duration               0.253  1   0.615167    
## avg_pollen            19.007  1  1.302e-05 ***
## fungicide:crithidia    0.286  1   0.592710    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(brood.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ fungicide * crithidia + block + workers_alive + 
##     duration + avg_pollen
##                     Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>                   49.836 249.43                     
## block                8  137.307 320.90 87.471 1.515e-15 ***
## workers_alive        1   84.894 282.48 35.058 3.200e-09 ***
## duration             1   50.089 247.68  0.253    0.6152    
## avg_pollen           1   68.843 266.43 19.007 1.302e-05 ***
## fungicide:crithidia  1   50.122 247.71  0.286    0.5927    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
brood.mod <- glm(brood_cells ~ fungicide + crithidia + block + workers_alive + duration + avg_pollen, data = brood, family = "poisson")
Anova(brood.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: brood_cells
##               LR Chisq Df Pr(>Chisq)    
## fungicide       17.065  1  3.613e-05 ***
## crithidia        1.142  1     0.2853    
## block          144.440  8  < 2.2e-16 ***
## workers_alive   46.697  1  8.284e-12 ***
## duration         0.051  1     0.8209    
## avg_pollen      37.618  1  8.604e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(brood.mod)
## 
## Call:
## glm(formula = brood_cells ~ fungicide + crithidia + block + workers_alive + 
##     duration + avg_pollen, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.2715  -1.3129  -0.0113   0.7457   2.6676  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    1.22582    0.83780   1.463   0.1434    
## fungicideTRUE  0.30506    0.07459   4.090 4.31e-05 ***
## crithidiaTRUE  0.07661    0.07171   1.068   0.2854    
## block4        -0.80926    0.17507  -4.622 3.79e-06 ***
## block6        -1.53435    0.30258  -5.071 3.96e-07 ***
## block7        -0.70856    0.16548  -4.282 1.85e-05 ***
## block8        -1.18429    0.17252  -6.865 6.67e-12 ***
## block9        -0.85542    0.15096  -5.666 1.46e-08 ***
## block10        0.01133    0.15394   0.074   0.9413    
## block11       -1.30993    0.23389  -5.601 2.13e-08 ***
## block12       -0.36818    0.17402  -2.116   0.0344 *  
## workers_alive  0.36984    0.05497   6.728 1.72e-11 ***
## duration      -0.00368    0.01623  -0.227   0.8206    
## avg_pollen     2.25736    0.37273   6.056 1.39e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 835.183  on 35  degrees of freedom
## Residual deviance:  75.399  on 22  degrees of freedom
## AIC: 253.42
## 
## Number of Fisher Scoring iterations: 5
brood.mod <- glm.nb(brood_cells ~ fungicide + crithidia + block + workers_alive + duration + avg_pollen, data = brood)
## Warning in glm.nb(brood_cells ~ fungicide + crithidia + block + workers_alive +
## : alternation limit reached
Anova(brood.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: brood_cells
##               LR Chisq Df Pr(>Chisq)    
## fungicide        9.657  1   0.001886 ** 
## crithidia        0.493  1   0.482703    
## block           89.641  8  5.500e-16 ***
## workers_alive   35.570  1  2.461e-09 ***
## duration         0.137  1   0.710886    
## avg_pollen      19.689  1  9.112e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(brood.mod)
## 
## Call:
## glm.nb(formula = brood_cells ~ fungicide + crithidia + block + 
##     workers_alive + duration + avg_pollen, data = brood, init.theta = 31.99881983, 
##     link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -2.95923  -0.92806  -0.01616   0.51861   2.10120  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    1.15461    1.11942   1.031 0.302338    
## fungicideTRUE  0.33381    0.10757   3.103 0.001915 ** 
## crithidiaTRUE  0.07651    0.10781   0.710 0.477905    
## block4        -0.92307    0.25751  -3.585 0.000338 ***
## block6        -1.48097    0.34083  -4.345 1.39e-05 ***
## block7        -0.78255    0.23518  -3.327 0.000877 ***
## block8        -1.30078    0.23444  -5.548 2.88e-08 ***
## block9        -0.91597    0.20677  -4.430 9.43e-06 ***
## block10        0.02685    0.21927   0.122 0.902542    
## block11       -1.38420    0.28411  -4.872 1.10e-06 ***
## block12       -0.37987    0.24030  -1.581 0.113916    
## workers_alive  0.43251    0.07442   5.812 6.18e-09 ***
## duration      -0.00802    0.02155  -0.372 0.709811    
## avg_pollen     2.32869    0.53039   4.390 1.13e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(31.9988) family taken to be 1)
## 
##     Null deviance: 515.429  on 35  degrees of freedom
## Residual deviance:  50.724  on 22  degrees of freedom
## AIC: 249.71
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  32.0 
##           Std. Err.:  18.8 
## Warning while fitting theta: alternation limit reached 
## 
##  2 x log-likelihood:  -219.708
drop1(brood.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ fungicide + crithidia + block + workers_alive + 
##     duration + avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             50.724 247.71                     
## fungicide      1   60.381 255.37  9.657  0.001886 ** 
## crithidia      1   51.216 246.20  0.493  0.482703    
## block          8  140.365 321.35 89.641 5.500e-16 ***
## workers_alive  1   86.294 281.28 35.570 2.461e-09 ***
## duration       1   50.861 245.85  0.137  0.710886    
## avg_pollen     1   70.413 265.40 19.689 9.112e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bm1 <- update(brood.mod, .~. -duration)
## Warning in glm.nb(formula = brood_cells ~ fungicide + crithidia + block + :
## alternation limit reached
drop1(bm1, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ fungicide + crithidia + block + workers_alive + 
##     avg_pollen
##               Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>             51.222 245.84                      
## fungicide      1   60.858 253.48   9.635  0.001909 ** 
## crithidia      1   51.658 244.28   0.436  0.509110    
## block          8  153.184 331.81 101.962 < 2.2e-16 ***
## workers_alive  1   92.733 285.35  41.511 1.172e-10 ***
## avg_pollen     1   71.821 264.44  20.599 5.663e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bm3 <- update(bm1, .~. -crithidia)
## Warning in glm.nb(formula = brood_cells ~ fungicide + block + workers_alive + :
## alternation limit reached
drop1(bm3, test = "Chisq")
## Single term deletions
## 
## Model:
## brood_cells ~ fungicide + block + workers_alive + avg_pollen
##               Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>             50.907 244.27                      
## fungicide      1   59.994 251.36   9.087  0.002574 ** 
## block          8  152.195 329.56 101.289 < 2.2e-16 ***
## workers_alive  1   91.526 282.89  40.619 1.850e-10 ***
## avg_pollen     1   70.579 261.94  19.672 9.192e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(bm1, bm3)
##     df      AIC
## bm1 14 247.8438
## bm3 13 246.2726
Anova(bm3)
## Analysis of Deviance Table (Type II tests)
## 
## Response: brood_cells
##               LR Chisq Df Pr(>Chisq)    
## fungicide        9.087  1   0.002574 ** 
## block          101.289  8  < 2.2e-16 ***
## workers_alive   40.619  1  1.850e-10 ***
## avg_pollen      19.672  1  9.192e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(bm3));qqline(resid(bm3))

broodem <- emmeans(bm1, pairwise ~ fungicide*crithidia, type = "response")
broodem
## $emmeans
##  fungicide crithidia response   SE  df asymp.LCL asymp.UCL
##  FALSE     FALSE         11.7 1.27 Inf      9.48      14.5
##  TRUE      FALSE         16.3 1.50 Inf     13.59      19.5
##  FALSE     TRUE          12.6 1.33 Inf     10.23      15.5
##  TRUE      TRUE          17.5 1.75 Inf     14.36      21.3
## 
## Results are averaged over the levels of: block 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale 
## 
## $contrasts
##  contrast                 ratio     SE  df null z.ratio p.value
##  FALSE FALSE / TRUE FALSE 0.720 0.0764 Inf    1  -3.096  0.0106
##  FALSE FALSE / FALSE TRUE 0.932 0.0989 Inf    1  -0.666  0.9099
##  FALSE FALSE / TRUE TRUE  0.671 0.1055 Inf    1  -2.541  0.0539
##  TRUE FALSE / FALSE TRUE  1.295 0.1847 Inf    1   1.809  0.2691
##  TRUE FALSE / TRUE TRUE   0.932 0.0989 Inf    1  -0.666  0.9099
##  FALSE TRUE / TRUE TRUE   0.720 0.0764 Inf    1  -3.096  0.0106
## 
## Results are averaged over the levels of: block 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## Tests are performed on the log scale
broodem.df <- as.data.frame(broodem$emmeans)
broodem.df
##  fungicide crithidia response       SE  df asymp.LCL asymp.UCL
##  FALSE     FALSE     11.71797 1.270220 Inf  9.475078  14.49179
##  TRUE      FALSE     16.28037 1.498668 Inf 13.592773  19.49937
##  FALSE     TRUE      12.57647 1.325379 Inf 10.229498  15.46191
##  TRUE      TRUE      17.47312 1.748343 Inf 14.361512  21.25890
## 
## Results are averaged over the levels of: block 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale
broodem.df$treatment <- c(1, 2, 4, 3)
broodem.df$treatment <-as.factor(broodem.df$treatment)

broodcld <-  cld(object = broodem,
                 adjust = "Tukey",
                 Letters = letters,
                 alpha = 0.05)
broodcld
##  fungicide crithidia response   SE  df asymp.LCL asymp.UCL .group
##  FALSE     FALSE         11.7 1.27 Inf      8.95      15.4  ab   
##  FALSE     TRUE          12.6 1.33 Inf      9.67      16.4  a c  
##  TRUE      FALSE         16.3 1.50 Inf     12.94      20.5    cd 
##  TRUE      TRUE          17.5 1.75 Inf     13.62      22.4   b d 
## 
## Results are averaged over the levels of: block 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 4 estimates 
## Intervals are back-transformed from the log scale 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## Tests are performed on the log scale 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
brood_sum <- brood %>%
  group_by(fungicide) %>%
  summarise(mb = mean(brood_cells),
            nb = length(brood_cells), 
            sdb = sd(brood_cells)) %>%
  mutate(seb = (sdb/sqrt(nb)))

brood_sum
## # A tibble: 2 × 5
##   fungicide    mb    nb   sdb   seb
##   <fct>     <dbl> <int> <dbl> <dbl>
## 1 FALSE      27.3    18  24.3  5.72
## 2 TRUE       25.7    18  22.8  5.37
ggplot(data = broodem.df, aes(x = treatment, y = response, fill = treatment)) +
  geom_col_pattern(
    aes(pattern_density = treatment),
    pattern = "stripe",   # Set a common pattern type, but differentiate density
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 25)) +
  geom_errorbar(aes(ymin = response - SE, ymax = response + SE), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Brood Cells") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 1,
    y = 20,
    label = "P < 0.001",
    size = 7
  ) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_density_manual(values = c("none", "none", "stripe", "none")) +
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
  geom_segment(x = 2, xend = 3, y = 21, yend = 21, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 20.5, yend = 21.5, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 20.5, yend = 21.5, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 4, y = 23, yend = 23, 
               lineend = "round", linejoin = "round") +
  geom_segment(x =1, xend = 1, y = 22.5, yend = 23.5, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 22.5, yend = 23.5, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 2.5, y = 21.5, label = "a", size = 6, vjust = -0.5) +
  geom_text(x = 2.5, y = 23.5, label = "b", size = 6, vjust = -0.5)

ggplot(data = broodem.df, aes(x = treatment, y = response, fill = treatment)) +
  geom_col_pattern(
    aes(pattern_density = treatment),
    pattern = "stripe",   # Set a common pattern type, but differentiate density
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the third column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 25)) +
  geom_errorbar(aes(ymin = response - SE, ymax = response + SE), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Brood Cells") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 1,
    y = 20,
    label = "P < 0.001",
    size = 7
  ) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_density_manual(values = c(0, 0, 0, 0.4)) +
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
  geom_segment(x = 2, xend = 3, y = 21, yend = 21, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 20.5, yend = 21.5, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 20.5, yend = 21.5, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 4, y = 23, yend = 23, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 22.5, yend = 23.5, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 22.5, yend = 23.5, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 2.5, y = 21.5, label = "b", size = 6, vjust = -0.5) +
  geom_text(x = 2.5, y = 23.5, label = "a", size = 6, vjust = -0.5)

Live pupae

plot(brood$treatment, brood$live_pupae)

livepup.mod.int <- glm(live_pupae ~ fungicide +crithidia + workers_alive + duration + avg_pollen, data = brood, family = "poisson")
drop1(livepup.mod.int, test = "Chisq")
## Single term deletions
## 
## Model:
## live_pupae ~ fungicide + crithidia + workers_alive + duration + 
##     avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             46.667 147.33                     
## fungicide      1   47.277 145.94  0.610    0.4347    
## crithidia      1   48.451 147.12  1.784    0.1816    
## workers_alive  1   67.688 166.35 21.021 4.542e-06 ***
## duration       1   51.610 150.28  4.943    0.0262 *  
## avg_pollen     1  104.321 202.99 57.655 3.124e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
livepup.mod <- glm.nb(live_pupae ~ fungicide*crithidia + workers_alive + block + duration + avg_pollen, data = brood)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(live_pupae ~ fungicide * crithidia + workers_alive + block +
## : alternation limit reached
Anova(livepup.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_pupae
##                     LR Chisq Df Pr(>Chisq)    
## fungicide             0.2574  1   0.611898    
## crithidia             3.1498  1   0.075934 .  
## workers_alive        12.7658  1   0.000353 ***
## block                11.4846  8   0.175721    
## duration              4.3615  1   0.036760 *  
## avg_pollen           23.2025  1  1.458e-06 ***
## fungicide:crithidia   0.1222  1   0.726688    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(livepup.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## live_pupae ~ fungicide * crithidia + workers_alive + block + 
##     duration + avg_pollen
##                     Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>                   34.959 153.64                      
## workers_alive        1   47.725 164.40 12.7658  0.000353 ***
## block                8   46.444 149.12 11.4846  0.175721    
## duration             1   39.321 156.00  4.3615  0.036760 *  
## avg_pollen           1   58.162 174.84 23.2025 1.458e-06 ***
## fungicide:crithidia  1   35.081 151.76  0.1222  0.726688    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
livepup.mod <- glm(live_pupae ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen, data = brood, family = "poisson")
Anova(livepup.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_pupae
##               LR Chisq Df Pr(>Chisq)    
## fungicide       0.2579  1  0.6115536    
## crithidia       3.1538  1  0.0757492 .  
## workers_alive  12.6561  1  0.0003743 ***
## block          11.5771  8  0.1710932    
## duration        4.4296  1  0.0353208 *  
## avg_pollen     23.0991  1  1.539e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
livepup.mod.nb <- glm.nb(live_pupae ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen, data = brood)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(live_pupae ~ fungicide + crithidia + workers_alive + block +
## : alternation limit reached
Anova(livepup.mod.nb)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_pupae
##               LR Chisq Df Pr(>Chisq)    
## fungicide       0.2574  1  0.6119094    
## crithidia       3.1497  1  0.0759404 .  
## workers_alive  12.6524  1  0.0003751 ***
## block          11.5747  8  0.1712097    
## duration        4.4289  1  0.0353345 *  
## avg_pollen     23.0894  1  1.546e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lpnb1 <- update(livepup.mod.nb, .~. -block)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(formula = live_pupae ~ fungicide + crithidia + workers_alive
## + : alternation limit reached
drop1(lpnb1, test = "Chisq")
## Single term deletions
## 
## Model:
## live_pupae ~ fungicide + crithidia + workers_alive + duration + 
##     avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             46.648 147.34                     
## fungicide      1   47.256 145.94  0.608   0.43552    
## crithidia      1   48.426 147.11  1.778   0.18238    
## workers_alive  1   67.656 166.34 21.008 4.574e-06 ***
## duration       1   51.586 150.27  4.938   0.02627 *  
## avg_pollen     1  104.253 202.94 57.605 3.204e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(lpnb1)
## 
## Call:
## glm.nb(formula = live_pupae ~ fungicide + crithidia + workers_alive + 
##     duration + avg_pollen, data = brood, init.theta = 9275.737704, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2877  -0.9999  -0.4254   0.4985   3.2316  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -4.82616    1.52562  -3.163  0.00156 ** 
## fungicideTRUE -0.11596    0.14912  -0.778  0.43679    
## crithidiaTRUE -0.20690    0.15682  -1.319  0.18705    
## workers_alive  0.51275    0.12068   4.249 2.15e-05 ***
## duration       0.06014    0.02679   2.245  0.02476 *  
## avg_pollen     3.44634    0.48603   7.091 1.33e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(9275.738) family taken to be 1)
## 
##     Null deviance: 252.605  on 35  degrees of freedom
## Residual deviance:  46.648  on 30  degrees of freedom
## AIC: 149.33
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  9276 
##           Std. Err.:  120994 
## Warning while fitting theta: alternation limit reached 
## 
##  2 x log-likelihood:  -135.335
Anova(lpnb1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_pupae
##               LR Chisq Df Pr(>Chisq)    
## fungicide        0.608  1    0.43552    
## crithidia        1.778  1    0.18238    
## workers_alive   21.008  1  4.574e-06 ***
## duration         4.938  1    0.02627 *  
## avg_pollen      57.605  1  3.204e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(livepup.mod));qqline(resid(livepup.mod))

plot(livepup.mod)

AIC(livepup.mod, livepup.mod.nb)
##                df      AIC
## livepup.mod    14 151.7561
## livepup.mod.nb 15 153.7595
anova(livepup.mod, livepup.mod.nb, test = "Chisq")
## Analysis of Deviance Table
## 
## Model 1: live_pupae ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
## Model 2: live_pupae ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
##   Resid. Df Resid. Dev Df  Deviance Pr(>Chi)
## 1        22     35.089                      
## 2        22     35.081  0 0.0084061
drop1(livepup.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## live_pupae ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
##               Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>             35.089 151.76                      
## fungicide      1   35.347 150.01  0.2579 0.6115536    
## crithidia      1   38.243 152.91  3.1538 0.0757492 .  
## workers_alive  1   47.746 162.41 12.6561 0.0003743 ***
## block          8   46.667 147.33 11.5771 0.1710932    
## duration       1   39.519 154.19  4.4296 0.0353208 *  
## avg_pollen     1   58.189 172.85 23.0991 1.539e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lp1 <- update(livepup.mod, .~. -block)
drop1(lp1, test = "Chisq")
## Single term deletions
## 
## Model:
## live_pupae ~ fungicide + crithidia + workers_alive + duration + 
##     avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             46.667 147.33                     
## fungicide      1   47.277 145.94  0.610    0.4347    
## crithidia      1   48.451 147.12  1.784    0.1816    
## workers_alive  1   67.688 166.35 21.021 4.542e-06 ***
## duration       1   51.610 150.28  4.943    0.0262 *  
## avg_pollen     1  104.321 202.99 57.655 3.124e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lp2 <- update(lp1, .~. -duration)
Anova(lp2)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_pupae
##               LR Chisq Df Pr(>Chisq)    
## fungicide        0.544  1     0.4607    
## crithidia        1.940  1     0.1636    
## workers_alive   16.636  1  4.528e-05 ***
## avg_pollen      52.745  1  3.798e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(lp1)
## 
## Call:
## glm(formula = live_pupae ~ fungicide + crithidia + workers_alive + 
##     duration + avg_pollen, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2883  -0.9998  -0.4256   0.4991   3.2325  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -4.82576    1.52462  -3.165  0.00155 ** 
## fungicideTRUE -0.11609    0.14903  -0.779  0.43599    
## crithidiaTRUE -0.20712    0.15674  -1.321  0.18634    
## workers_alive  0.51273    0.12063   4.251 2.13e-05 ***
## duration       0.06014    0.02677   2.247  0.02467 *  
## avg_pollen     3.44614    0.48583   7.093 1.31e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 252.752  on 35  degrees of freedom
## Residual deviance:  46.667  on 30  degrees of freedom
## AIC: 147.33
## 
## Number of Fisher Scoring iterations: 5
Anova(lp1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_pupae
##               LR Chisq Df Pr(>Chisq)    
## fungicide        0.610  1     0.4347    
## crithidia        1.784  1     0.1816    
## workers_alive   21.021  1  4.542e-06 ***
## duration         4.943  1     0.0262 *  
## avg_pollen      57.655  1  3.124e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(lp1));qqline(resid(lp1))

anova(livepup.mod, lp1, test = "Chisq")
## Analysis of Deviance Table
## 
## Model 1: live_pupae ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
## Model 2: live_pupae ~ fungicide + crithidia + workers_alive + duration + 
##     avg_pollen
##   Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1        22     35.089                     
## 2        30     46.667 -8  -11.577   0.1711
AIC(livepup.mod, lp1)
##             df      AIC
## livepup.mod 14 151.7561
## lp1          6 147.3332
be <- emmeans(lp1, "crithidia")
pairs(be)
##  contrast     estimate    SE  df z.ratio p.value
##  FALSE - TRUE    0.207 0.157 Inf   1.321  0.1863
## 
## Results are averaged over the levels of: fungicide 
## Results are given on the log (not the response) scale.
broodem <- emmeans(lp1, pairwise ~ crithidia, type = "response")
broodem
## $emmeans
##  crithidia rate    SE  df asymp.LCL asymp.UCL
##  FALSE     2.79 0.429 Inf      2.06      3.77
##  TRUE      2.27 0.370 Inf      1.65      3.12
## 
## Results are averaged over the levels of: fungicide 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale 
## 
## $contrasts
##  contrast     ratio    SE  df null z.ratio p.value
##  FALSE / TRUE  1.23 0.193 Inf    1   1.321  0.1863
## 
## Results are averaged over the levels of: fungicide 
## Tests are performed on the log scale
broodem <- emmeans(lp1, pairwise ~ crithidia*fungicide, type = "response")

broodcld <-  cld(object = broodem,
                 adjust = "Tukey",
                 Letters = letters,
                 alpha = 0.05)
broodcld
##  crithidia fungicide rate    SE  df asymp.LCL asymp.UCL .group
##  TRUE      TRUE      2.14 0.386 Inf      1.36      3.35  a    
##  TRUE      FALSE     2.40 0.429 Inf      1.54      3.75  a    
##  FALSE     TRUE      2.63 0.458 Inf      1.71      4.06  a    
##  FALSE     FALSE     2.95 0.495 Inf      1.95      4.49  a    
## 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 4 estimates 
## Intervals are back-transformed from the log scale 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## Tests are performed on the log scale 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
livepup_sum <- brood %>%
  group_by(treatment) %>%
  summarise(mb = mean(live_pupae),
            nb = length(live_pupae), 
            sdb = sd(live_pupae)) %>%
  mutate(seb = (sdb/sqrt(nb)))

livepup_sum
## # A tibble: 4 × 5
##   treatment    mb    nb   sdb   seb
##   <fct>     <dbl> <int> <dbl> <dbl>
## 1 1          8.22     9  7.58  2.53
## 2 2          5.89     9  7.54  2.51
## 3 3          2.89     9  3.30  1.10
## 4 4          4        9  5.17  1.72
ggplot(data = livepup_sum, aes(x = treatment, y = mb, fill = treatment, pattern = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 13)) +
  geom_errorbar(aes(ymin = mb - seb, ymax = mb + seb), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Live Pupae") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 2,
    y = 12.5,
    label = "P > 0.05",
    size = 12
  ) +
 scale_x_discrete(labels = custom_labels) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) +
  theme(legend.position = "none")

  #geom_segment(x = 1, xend = 2, y = 12, yend = 12, 
   #            lineend = "round", linejoin = "round") +
  #geom_segment(x = 1, xend = 1, y = 11.8, yend = 12.2, 
   #            lineend = "round", linejoin = "round") +
#  geom_segment(x = 2, xend = 2, y = 11.8, yend = 12.2, 
  #             lineend = "round", linejoin = "round") +
 # geom_segment(x = 3, xend = 4, y = 7, yend = 7, 
#               lineend = "round", linejoin = "round") +
 # geom_segment(x = 3, xend = 3, y = 6.8, yend = 7.2, 
  #             lineend = "round", linejoin = "round") +
#  geom_segment(x = 4, xend = 4, y = 6.8, yend = 7.2, 
 #              lineend = "round", linejoin = "round") +
 # geom_text(x = 1.5, y = 12, label = "a", size = 6, vjust = -0.5) +
#  geom_text(x = 3.5, y = 7, label = "b", size = 6, vjust = -0.5) +
plot(brood$treatment, brood$live_larvae)

livelar.mod <- glm(live_larvae ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen , data = brood, family = "poisson")
summary(livelar.mod) #overdisp
## 
## Call:
## glm(formula = live_larvae ~ fungicide + crithidia + workers_alive + 
##     block + duration + avg_pollen, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.6068  -1.6238  -0.5069   1.0864   2.5547  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    1.90936    1.11950   1.706 0.088094 .  
## fungicideTRUE  0.19053    0.09850   1.934 0.053080 .  
## crithidiaTRUE  0.18432    0.09419   1.957 0.050357 .  
## workers_alive  0.34362    0.07345   4.678 2.89e-06 ***
## block4        -0.35446    0.23717  -1.495 0.135039    
## block6        -1.82877    0.60694  -3.013 0.002586 ** 
## block7        -0.55917    0.23774  -2.352 0.018674 *  
## block8        -0.90571    0.24315  -3.725 0.000195 ***
## block9        -0.66470    0.22504  -2.954 0.003140 ** 
## block10        0.75755    0.22272   3.401 0.000671 ***
## block11       -1.31312    0.38511  -3.410 0.000650 ***
## block12        0.32055    0.23934   1.339 0.180472    
## duration      -0.03840    0.02207  -1.740 0.081935 .  
## avg_pollen     2.24259    0.48644   4.610 4.02e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 690.91  on 35  degrees of freedom
## Residual deviance:  91.83  on 22  degrees of freedom
## AIC: 237.57
## 
## Number of Fisher Scoring iterations: 5
livelar.mod.int <- glm(live_larvae ~ fungicide*crithidia + workers_alive + block + duration + avg_pollen, data = brood, family = "poisson")
summary(livelar.mod.int) #overdisp
## 
## Call:
## glm(formula = live_larvae ~ fungicide * crithidia + workers_alive + 
##     block + duration + avg_pollen, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.6955  -1.6402  -0.5423   1.1193   2.2554  
## 
## Coefficients:
##                             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                  2.17431    1.15107   1.889 0.058898 .  
## fungicideTRUE                0.12449    0.12521   0.994 0.320099    
## crithidiaTRUE                0.11112    0.12715   0.874 0.382157    
## workers_alive                0.34537    0.07376   4.682 2.83e-06 ***
## block4                      -0.36849    0.23880  -1.543 0.122817    
## block6                      -1.83346    0.60674  -3.022 0.002513 ** 
## block7                      -0.56421    0.23834  -2.367 0.017924 *  
## block8                      -0.91356    0.24198  -3.775 0.000160 ***
## block9                      -0.70003    0.22921  -3.054 0.002257 ** 
## block10                      0.76821    0.22112   3.474 0.000512 ***
## block11                     -1.35595    0.38821  -3.493 0.000478 ***
## block12                      0.29780    0.24254   1.228 0.219513    
## duration                    -0.04277    0.02246  -1.904 0.056896 .  
## avg_pollen                   2.16957    0.49298   4.401 1.08e-05 ***
## fungicideTRUE:crithidiaTRUE  0.15563    0.18144   0.858 0.391032    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 690.912  on 35  degrees of freedom
## Residual deviance:  91.094  on 21  degrees of freedom
## AIC: 238.84
## 
## Number of Fisher Scoring iterations: 5
livelar.mod.nb.int <- glm.nb(live_larvae ~ fungicide*crithidia + workers_alive + block + duration + avg_pollen , data = brood)
## Warning in glm.nb(live_larvae ~ fungicide * crithidia + workers_alive + :
## alternation limit reached
summary(livelar.mod.nb.int)
## 
## Call:
## glm.nb(formula = live_larvae ~ fungicide * crithidia + workers_alive + 
##     block + duration + avg_pollen, data = brood, init.theta = 9.07466479, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.9298  -1.2359  -0.3805   0.5865   2.1165  
## 
## Coefficients:
##                             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                  1.36901    1.86239   0.735 0.462291    
## fungicideTRUE                0.12018    0.22743   0.528 0.597224    
## crithidiaTRUE               -0.02186    0.24449  -0.089 0.928765    
## workers_alive                0.43366    0.12208   3.552 0.000382 ***
## block4                      -0.65537    0.43381  -1.511 0.130857    
## block6                      -1.75205    0.68248  -2.567 0.010252 *  
## block7                      -0.65454    0.39712  -1.648 0.099312 .  
## block8                      -1.20924    0.39409  -3.068 0.002152 ** 
## block9                      -0.75635    0.35561  -2.127 0.033425 *  
## block10                      0.70621    0.37204   1.898 0.057666 .  
## block11                     -1.48747    0.51072  -2.912 0.003586 ** 
## block12                      0.37671    0.39256   0.960 0.337239    
## duration                    -0.03602    0.03572  -1.009 0.313178    
## avg_pollen                   2.70545    0.87460   3.093 0.001979 ** 
## fungicideTRUE:crithidiaTRUE  0.27237    0.34618   0.787 0.431409    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(9.0747) family taken to be 1)
## 
##     Null deviance: 311.724  on 35  degrees of freedom
## Residual deviance:  51.376  on 21  degrees of freedom
## AIC: 229.7
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  9.07 
##           Std. Err.:  5.05 
## Warning while fitting theta: alternation limit reached 
## 
##  2 x log-likelihood:  -197.70
drop1(livelar.mod.nb.int, test = "Chisq")
## Single term deletions
## 
## Model:
## live_larvae ~ fungicide * crithidia + workers_alive + block + 
##     duration + avg_pollen
##                     Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>                   51.376 227.70                     
## workers_alive        1   63.882 238.21 12.506 0.0004056 ***
## block                8  107.289 267.61 55.913 2.933e-09 ***
## duration             1   52.267 226.59  0.891 0.3452583    
## avg_pollen           1   60.587 234.91  9.211 0.0024050 ** 
## fungicide:crithidia  1   51.987 226.31  0.611 0.4344570    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
livelar.mod.nb <- glm.nb(live_larvae ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen , data = brood)  #start with this one 
## Warning in glm.nb(live_larvae ~ fungicide + crithidia + workers_alive + :
## alternation limit reached
summary(livelar.mod.nb)
## 
## Call:
## glm.nb(formula = live_larvae ~ fungicide + crithidia + workers_alive + 
##     block + duration + avg_pollen, data = brood, init.theta = 8.987768981, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.8127  -1.1505  -0.4229   0.5430   2.1928  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    0.98943    1.81342   0.546  0.58533    
## fungicideTRUE  0.23197    0.17923   1.294  0.19557    
## crithidiaTRUE  0.10121    0.18221   0.555  0.57858    
## workers_alive  0.42852    0.12171   3.521  0.00043 ***
## block4        -0.60665    0.43116  -1.407  0.15942    
## block6        -1.77937    0.68529  -2.597  0.00942 ** 
## block7        -0.63088    0.39774  -1.586  0.11270    
## block8        -1.16564    0.39233  -2.971  0.00297 ** 
## block9        -0.71906    0.35055  -2.051  0.04024 *  
## block10        0.70056    0.37496   1.868  0.06171 .  
## block11       -1.42670    0.50319  -2.835  0.00458 ** 
## block12        0.38682    0.39093   0.989  0.32243    
## duration      -0.02891    0.03499  -0.826  0.40872    
## avg_pollen     2.73864    0.87600   3.126  0.00177 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(8.9878) family taken to be 1)
## 
##     Null deviance: 310.310  on 35  degrees of freedom
## Residual deviance:  51.831  on 22  degrees of freedom
## AIC: 228.31
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  8.99 
##           Std. Err.:  5.08 
## Warning while fitting theta: alternation limit reached 
## 
##  2 x log-likelihood:  -198.31
drop1(livelar.mod.nb, test = "Chisq")
## Single term deletions
## 
## Model:
## live_larvae ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             51.831 226.31                     
## fungicide      1   53.501 225.98  1.670 0.1961955    
## crithidia      1   52.126 224.60  0.295 0.5868366    
## workers_alive  1   64.093 236.57 12.262 0.0004623 ***
## block          8  107.087 265.57 55.256 3.936e-09 ***
## duration       1   52.440 224.92  0.609 0.4352187    
## avg_pollen     1   61.252 233.73  9.421 0.0021450 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ll1 <-update(livelar.mod.nb, .~. -duration)
drop1(ll1, test = "Chisq")
## Single term deletions
## 
## Model:
## live_larvae ~ fungicide + crithidia + workers_alive + block + 
##     avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             51.138 224.90                     
## fungicide      1   52.618 224.38  1.480  0.223743    
## crithidia      1   51.325 223.09  0.188  0.664965    
## workers_alive  1   66.612 238.38 15.474 8.363e-05 ***
## block          8  107.238 265.00 56.100 2.697e-09 ***
## avg_pollen     1   60.958 232.72  9.820  0.001726 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ll1)
## 
## Call:
## glm.nb(formula = live_larvae ~ fungicide + crithidia + workers_alive + 
##     block + avg_pollen, data = brood, init.theta = 8.31087449, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.8906  -1.0503  -0.3603   0.6087   2.1456  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -0.48898    0.50908  -0.961 0.336787    
## fungicideTRUE  0.22321    0.18244   1.224 0.221140    
## crithidiaTRUE  0.08251    0.18540   0.445 0.656290    
## workers_alive  0.46356    0.11923   3.888 0.000101 ***
## block4        -0.53894    0.43472  -1.240 0.215077    
## block6        -1.86957    0.68175  -2.742 0.006101 ** 
## block7        -0.52319    0.38118  -1.373 0.169885    
## block8        -1.11085    0.39494  -2.813 0.004913 ** 
## block9        -0.63959    0.35012  -1.827 0.067733 .  
## block10        0.62654    0.36247   1.729 0.083891 .  
## block11       -1.41876    0.50792  -2.793 0.005218 ** 
## block12        0.44021    0.39404   1.117 0.263929    
## avg_pollen     2.84629    0.88950   3.200 0.001375 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(8.3109) family taken to be 1)
## 
##     Null deviance: 298.876  on 35  degrees of freedom
## Residual deviance:  51.138  on 23  degrees of freedom
## AIC: 226.9
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  8.31 
##           Std. Err.:  4.54 
## 
##  2 x log-likelihood:  -198.903
Anova(ll1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: live_larvae
##               LR Chisq Df Pr(>Chisq)    
## fungicide        1.480  1   0.223743    
## crithidia        0.188  1   0.664965    
## workers_alive   15.474  1  8.363e-05 ***
## block           56.100  8  2.697e-09 ***
## avg_pollen       9.820  1   0.001726 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
broodem <- emmeans(ll1, pairwise ~ crithidia, type = "response")

broodcld <-  cld(object = broodem,
                 adjust = "Tukey",
                 Letters = letters,
                 alpha = 0.05)
broodcld
##  crithidia response    SE  df asymp.LCL asymp.UCL .group
##  FALSE         6.31 0.956 Inf      4.49      8.85  a    
##  TRUE          6.85 1.057 Inf      4.85      9.67  a    
## 
## Results are averaged over the levels of: fungicide, block 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 2 estimates 
## Intervals are back-transformed from the log scale 
## Tests are performed on the log scale 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
livelarv_sum <- brood %>%
  group_by(treatment) %>%
  summarise(mb = mean(live_larvae),
            nb = length(live_larvae), 
            sdb = sd(live_larvae)) %>%
  mutate(seb = (sdb/sqrt(nb)))

livelarv_sum
## # A tibble: 4 × 5
##   treatment    mb    nb   sdb   seb
##   <fct>     <dbl> <int> <dbl> <dbl>
## 1 1          20.7     9  19.0  6.34
## 2 2          15.1     9  11.0  3.68
## 3 3          12.8     9  19.5  6.52
## 4 4          14.9     9  18.7  6.23
livelarv_sum$plot <- livelarv_sum$mb + livelarv_sum$seb

plot(brood$treatment, brood$live_larvae)

ggplot(data = livelarv_sum, aes(x = treatment, y = mb, fill = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 35)) +
  geom_errorbar(aes(ymin = mb - seb, ymax = mb + seb), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Live Pupae") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 1,
    y = 34,
    label = "P > 0.5",
    size = 7
  ) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "grey", "lightblue")) +
  scale_pattern_manual(values = c("none", "none", "none", "stripe")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none")

Dead larvae count

dl.mod.pois <- glm(dead_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + block + duration, data = brood, family = "poisson")
summary(dl.mod.pois) #overdisp
## 
## Call:
## glm(formula = dead_larvae ~ fungicide + crithidia + avg_pollen + 
##     workers_alive + block + duration, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2912  -1.2869  -0.6832   0.3491   3.0516  
## 
## Coefficients:
##                 Estimate Std. Error z value Pr(>|z|)  
## (Intercept)   -10.264220   4.789264  -2.143   0.0321 *
## fungicideTRUE   0.083851   0.320333   0.262   0.7935  
## crithidiaTRUE  -0.008702   0.317055  -0.027   0.9781  
## avg_pollen      4.213135   1.807802   2.331   0.0198 *
## workers_alive   0.241475   0.216043   1.118   0.2637  
## block4         -0.227251   0.816578  -0.278   0.7808  
## block6         -0.193539   0.770278  -0.251   0.8016  
## block7          0.715601   0.679101   1.054   0.2920  
## block8         -0.690911   0.828415  -0.834   0.4043  
## block9          0.701074   0.696017   1.007   0.3138  
## block10        -0.985941   0.749115  -1.316   0.1881  
## block11        -1.156822   1.109631  -1.043   0.2972  
## block12        -0.185549   0.807885  -0.230   0.8183  
## duration        0.173330   0.089374   1.939   0.0525 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 99.573  on 35  degrees of freedom
## Residual deviance: 69.971  on 22  degrees of freedom
## AIC: 144.73
## 
## Number of Fisher Scoring iterations: 6
dl.mod <- glm.nb(dead_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + block + duration, data = brood)
## Warning in glm.nb(dead_larvae ~ fungicide + crithidia + avg_pollen +
## workers_alive + : alternation limit reached
drop1(dl.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## dead_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + 
##     block + duration
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             32.959 131.44                  
## fungicide      1   33.100 129.58 0.1413  0.70698  
## crithidia      1   32.959 129.44 0.0007  0.97829  
## avg_pollen     1   34.546 131.03 1.5875  0.20768  
## workers_alive  1   33.888 130.37 0.9294  0.33501  
## block          8   37.315 119.80 4.3565  0.82361  
## duration       1   35.850 132.33 2.8916  0.08904 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dl1 <- update(dl.mod, .~. -block)
drop1(dl1, test = "Chisq")
## Single term deletions
## 
## Model:
## dead_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + 
##     duration
##               Df Deviance    AIC     LRT Pr(>Chi)
## <none>             33.942 119.61                 
## fungicide      1   34.357 118.03 0.41527   0.5193
## crithidia      1   34.025 117.69 0.08335   0.7728
## avg_pollen     1   36.405 120.08 2.46344   0.1165
## workers_alive  1   35.135 118.80 1.19302   0.2747
## duration       1   34.731 118.40 0.78902   0.3744
dl2 <- update(dl1, .~. -duration)
drop1(dl2, test = "Chisq")
## Single term deletions
## 
## Model:
## dead_larvae ~ fungicide + crithidia + avg_pollen + workers_alive
##               Df Deviance    AIC     LRT Pr(>Chi)
## <none>             34.069 118.39                 
## fungicide      1   34.491 116.81 0.42200   0.5159
## crithidia      1   34.310 116.63 0.24113   0.6234
## avg_pollen     1   35.877 118.20 1.80740   0.1788
## workers_alive  1   34.709 117.03 0.63955   0.4239
dl3 <- update(dl2, .~. -workers_alive)
drop1(dl3, test = "Chisq")
## Single term deletions
## 
## Model:
## dead_larvae ~ fungicide + crithidia + avg_pollen
##            Df Deviance    AIC    LRT Pr(>Chi)  
## <none>          33.976 117.02                  
## fungicide   1   34.462 115.51 0.4862  0.48563  
## crithidia   1   34.007 115.06 0.0316  0.85896  
## avg_pollen  1   39.815 120.86 5.8390  0.01567 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(brood$treatment, brood$dead_larvae)

Anova(dl3)
## Analysis of Deviance Table (Type II tests)
## 
## Response: dead_larvae
##            LR Chisq Df Pr(>Chisq)  
## fungicide    0.4862  1    0.48563  
## crithidia    0.0316  1    0.85896  
## avg_pollen   5.8390  1    0.01567 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(dl3)
## 
## Call:
## glm.nb(formula = dead_larvae ~ fungicide + crithidia + avg_pollen, 
##     data = brood, init.theta = 0.694531903, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5917  -1.0642  -0.8710   0.4214   1.5860  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)  
## (Intercept)    -1.2997     0.7873  -1.651   0.0988 .
## fungicideTRUE   0.3838     0.5182   0.741   0.4589  
## crithidiaTRUE   0.0926     0.5277   0.175   0.8607  
## avg_pollen      2.8820     1.1724   2.458   0.0140 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.6945) family taken to be 1)
## 
##     Null deviance: 39.938  on 35  degrees of freedom
## Residual deviance: 33.976  on 32  degrees of freedom
## AIC: 119.02
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.695 
##           Std. Err.:  0.331 
## 
##  2 x log-likelihood:  -109.023

dead pupae count

dp.mod.pois <- glm(dead_pupae ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood, family = "poisson")
summary(dp.mod.pois)
## 
## Call:
## glm(formula = dead_pupae ~ fungicide + crithidia + avg_pollen + 
##     workers_alive + duration, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.1201  -0.3856  -0.1049  -0.0464   1.4458  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)  
## (Intercept)   -23.6743    13.1053  -1.806   0.0708 .
## fungicideTRUE  -0.1068     0.9890  -0.108   0.9140  
## crithidiaTRUE   0.9183     1.1642   0.789   0.4302  
## avg_pollen     15.2873     8.0731   1.894   0.0583 .
## workers_alive  -1.1758     0.8133  -1.446   0.1483  
## duration        0.3746     0.2278   1.644   0.1002  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 19.741  on 35  degrees of freedom
## Residual deviance: 10.051  on 30  degrees of freedom
## AIC: 32.051
## 
## Number of Fisher Scoring iterations: 7
dp.mod <- glm.nb(dead_pupae ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(dp.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## dead_pupae ~ fungicide + crithidia + avg_pollen + workers_alive + 
##     duration
##               Df Deviance    AIC    LRT Pr(>Chi)   
## <none>             10.051 32.051                   
## fungicide      1   10.062 30.063 0.0116 0.914168   
## crithidia      1   10.687 30.688 0.6364 0.425029   
## avg_pollen     1   18.853 38.854 8.8026 0.003008 **
## workers_alive  1   12.979 32.980 2.9288 0.087014 . 
## duration       1   13.256 33.256 3.2053 0.073402 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dp1 <- update(dp.mod, .~. -duration)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(dp1, test = "Chisq")
## Single term deletions
## 
## Model:
## dead_pupae ~ fungicide + crithidia + avg_pollen + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             13.256 33.256                  
## fungicide      1   13.489 31.490 0.2336  0.62883  
## crithidia      1   13.410 31.411 0.1541  0.69468  
## avg_pollen     1   19.183 37.183 5.9270  0.01491 *
## workers_alive  1   17.549 35.550 4.2932  0.03826 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(dp1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: dead_pupae
##               LR Chisq Df Pr(>Chisq)  
## fungicide       0.2336  1    0.62883  
## crithidia       0.1541  1    0.69468  
## avg_pollen      5.9270  1    0.01491 *
## workers_alive   4.2932  1    0.03826 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(dp1)
## 
## Call:
## glm.nb(formula = dead_pupae ~ fungicide + crithidia + avg_pollen + 
##     workers_alive, data = brood, init.theta = 7846.456534, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.1378  -0.3987  -0.2465  -0.1208   1.3019  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)  
## (Intercept)    -3.2686     1.6092  -2.031   0.0422 *
## fungicideTRUE   0.4393     0.9185   0.478   0.6324  
## crithidiaTRUE   0.4173     1.0597   0.394   0.6938  
## avg_pollen      8.6462     4.4149   1.958   0.0502 .
## workers_alive  -1.0658     0.5938  -1.795   0.0726 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(7846.457) family taken to be 1)
## 
##     Null deviance: 19.740  on 35  degrees of freedom
## Residual deviance: 13.256  on 31  degrees of freedom
## AIC: 35.256
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  7846 
##           Std. Err.:  363756 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -23.256
plot(brood$treatment, brood$dead_pupae)

total larvae count

tl.mod.pois <- glm(total_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood, family = "poisson")
summary(tl.mod.pois)
## 
## Call:
## glm(formula = total_larvae ~ fungicide + crithidia + avg_pollen + 
##     workers_alive + duration, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.5921  -2.5442  -0.6843   0.8945   5.5109  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -3.08609    0.82293  -3.750 0.000177 ***
## fungicideTRUE -0.08435    0.08169  -1.033 0.301766    
## crithidiaTRUE  0.18685    0.08284   2.256 0.024101 *  
## avg_pollen     3.82748    0.27731  13.802  < 2e-16 ***
## workers_alive  0.22489    0.05595   4.019 5.84e-05 ***
## duration       0.06806    0.01486   4.580 4.65e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 710.95  on 35  degrees of freedom
## Residual deviance: 217.27  on 30  degrees of freedom
## AIC: 354.1
## 
## Number of Fisher Scoring iterations: 6
tl.mod <- glm.nb(total_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood) 
drop1(tl.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## total_larvae ~ fungicide + crithidia + avg_pollen + workers_alive + 
##     duration
##               Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>             44.435 249.21                      
## fungicide      1   47.530 250.30  3.0954   0.07851 .  
## crithidia      1   44.804 247.58  0.3699   0.54308    
## avg_pollen     1   69.509 272.28 25.0744 5.516e-07 ***
## workers_alive  1   47.526 250.30  3.0914   0.07871 .  
## duration       1   45.006 247.78  0.5711   0.44984    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tl.mod1 <- update(tl.mod, .~. -duration)
drop1(tl.mod1, test = "Chisq")
## Single term deletions
## 
## Model:
## total_larvae ~ fungicide + crithidia + avg_pollen + workers_alive
##               Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>             43.843 247.76                      
## fungicide      1   47.281 249.20  3.4379   0.06372 .  
## crithidia      1   44.368 246.28  0.5250   0.46874    
## avg_pollen     1   67.532 269.45 23.6883 1.133e-06 ***
## workers_alive  1   46.292 248.21  2.4490   0.11760    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tl1 <- update(tl.mod1, .~. -workers_alive)
drop1(tl1, test = "Chisq")
## Single term deletions
## 
## Model:
## total_larvae ~ fungicide + crithidia + avg_pollen
##            Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>          43.813 248.13                     
## fungicide   1   46.281 248.60  2.468    0.1162    
## crithidia   1   43.817 246.14  0.004    0.9516    
## avg_pollen  1   92.798 295.12 48.985 2.579e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tl2 <- update(tl1, .~. -crithidia)
drop1(tl2, test = "Chisq")
## Single term deletions
## 
## Model:
## total_larvae ~ fungicide + avg_pollen
##            Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>          43.803 246.14                     
## fungicide   1   46.268 246.60  2.465    0.1164    
## avg_pollen  1   93.421 293.75 49.618 1.868e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(tl.mod, tl.mod1, tl1)
##         df      AIC
## tl.mod   7 251.2058
## tl.mod1  6 249.7599
## tl1      5 250.1334
anova(tl.mod1, tl1, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
## 
## Response: total_larvae
##                                                Model    theta Resid. df
## 1                 fungicide + crithidia + avg_pollen 1.388644        32
## 2 fungicide + crithidia + avg_pollen + workers_alive 1.520016        31
##      2 x log-lik.   Test    df LR stat.   Pr(Chi)
## 1       -240.1334                                
## 2       -237.7599 1 vs 2     1 2.373457 0.1234135
Anova(tl1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: total_larvae
##            LR Chisq Df Pr(>Chisq)    
## fungicide     2.468  1     0.1162    
## crithidia     0.004  1     0.9516    
## avg_pollen   48.985  1  2.579e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(tl1)
## 
## Call:
## glm.nb(formula = total_larvae ~ fungicide + crithidia + avg_pollen, 
##     data = brood, init.theta = 1.388643983, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.8612  -1.3451  -0.4270   0.4856   1.4306  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -0.52648    0.48115  -1.094   0.2739    
## fungicideTRUE  0.52458    0.31805   1.649   0.0991 .  
## crithidiaTRUE  0.01889    0.32256   0.059   0.9533    
## avg_pollen     6.06181    0.73581   8.238   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(1.3886) family taken to be 1)
## 
##     Null deviance: 94.065  on 35  degrees of freedom
## Residual deviance: 43.813  on 32  degrees of freedom
## AIC: 250.13
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  1.389 
##           Std. Err.:  0.448 
## 
##  2 x log-likelihood:  -240.133
qqnorm(resid(tl.mod1));qqline(resid(tl.mod1))

plot(brood$treatment, brood$total_larvae)

total pupae

tp.mod.pois <- glm(total_pupae ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood, family = "poisson")
summary(tp.mod.pois)
## 
## Call:
## glm(formula = total_pupae ~ fungicide + crithidia + avg_pollen + 
##     workers_alive + duration, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.4136  -1.0783  -0.3123   0.4326   2.9573  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -4.70478    1.48725  -3.163 0.001559 ** 
## fungicideTRUE -0.11071    0.14684  -0.754 0.450906    
## crithidiaTRUE -0.18730    0.15421  -1.215 0.224525    
## avg_pollen     3.57736    0.48383   7.394 1.43e-13 ***
## workers_alive  0.44154    0.11456   3.854 0.000116 ***
## duration       0.06339    0.02625   2.415 0.015736 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 251.819  on 35  degrees of freedom
## Residual deviance:  49.933  on 30  degrees of freedom
## AIC: 151.97
## 
## Number of Fisher Scoring iterations: 6
tp.mod <- glm.nb(total_pupae ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(total_pupae ~ fungicide + crithidia + avg_pollen +
## workers_alive + : alternation limit reached
drop1(tp.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## total_pupae ~ fungicide + crithidia + avg_pollen + workers_alive + 
##     duration
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             49.912 151.97                     
## fungicide      1   50.481 150.54  0.569   0.45079    
## crithidia      1   51.409 151.47  1.497   0.22118    
## avg_pollen     1  112.935 212.99 63.023 2.043e-15 ***
## workers_alive  1   66.728 166.78 16.816 4.118e-05 ***
## duration       1   55.640 155.70  5.728   0.01669 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(tp.mod));qqline(resid(tp.mod))

Anova(tp.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: total_pupae
##               LR Chisq Df Pr(>Chisq)    
## fungicide        0.569  1    0.45079    
## crithidia        1.497  1    0.22118    
## avg_pollen      63.023  1  2.043e-15 ***
## workers_alive   16.816  1  4.118e-05 ***
## duration         5.728  1    0.01669 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(tp.mod)
## 
## Call:
## glm.nb(formula = total_pupae ~ fungicide + crithidia + avg_pollen + 
##     workers_alive + duration, data = brood, init.theta = 8477.73857, 
##     link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.4130  -1.0781  -0.3125   0.4323   2.9562  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -4.70524    1.48829  -3.162 0.001570 ** 
## fungicideTRUE -0.11053    0.14694  -0.752 0.451921    
## crithidiaTRUE -0.18703    0.15430  -1.212 0.225464    
## avg_pollen     3.57762    0.48405   7.391 1.46e-13 ***
## workers_alive  0.44155    0.11461   3.853 0.000117 ***
## duration       0.06339    0.02627   2.413 0.015811 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(8477.738) family taken to be 1)
## 
##     Null deviance: 251.656  on 35  degrees of freedom
## Residual deviance:  49.912  on 30  degrees of freedom
## AIC: 153.97
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  8478 
##           Std. Err.:  110861 
## Warning while fitting theta: alternation limit reached 
## 
##  2 x log-likelihood:  -139.969
plot(brood$treatment, brood$total_pupae)

total egg count

egg.mod.pois <- glm(eggs ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood, family = "poisson")
summary(egg.mod.pois)
## 
## Call:
## glm(formula = eggs ~ fungicide + crithidia + avg_pollen + workers_alive + 
##     duration, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -6.271  -3.295  -0.419   1.565  10.143  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    0.14893    0.67314   0.221   0.8249    
## fungicideTRUE  0.12523    0.07449   1.681   0.0927 .  
## crithidiaTRUE  0.05861    0.07671   0.764   0.4448    
## avg_pollen     1.73926    0.22538   7.717 1.19e-14 ***
## workers_alive  0.25345    0.04538   5.585 2.34e-08 ***
## duration       0.02166    0.01244   1.742   0.0816 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 713.26  on 35  degrees of freedom
## Residual deviance: 446.17  on 30  degrees of freedom
## AIC: 595.52
## 
## Number of Fisher Scoring iterations: 5
egg.mod <- glm.nb(eggs ~ fungicide + crithidia + avg_pollen + workers_alive + duration, data = brood)
drop1(egg.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## eggs ~ fungicide + crithidia + avg_pollen + workers_alive + duration
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             43.917 283.18                  
## fungicide      1   45.280 282.54 1.3631   0.2430  
## crithidia      1   43.938 281.20 0.0208   0.8853  
## avg_pollen     1   46.480 283.74 2.5624   0.1094  
## workers_alive  1   47.936 285.20 4.0188   0.0450 *
## duration       1   43.920 281.18 0.0024   0.9613  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em1 <- update(egg.mod, .~. -duration)
drop1(em1, test = "Chisq")
## Single term deletions
## 
## Model:
## eggs ~ fungicide + crithidia + avg_pollen + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             43.916 281.18                  
## fungicide      1   45.286 280.55 1.3697  0.24186  
## crithidia      1   43.935 279.20 0.0191  0.89005  
## avg_pollen     1   46.478 281.74 2.5623  0.10944  
## workers_alive  1   48.379 283.64 4.4628  0.03464 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em2 <- update(em1, .~. -avg_pollen)
drop1(em2, test = "Chisq")
## Single term deletions
## 
## Model:
## eggs ~ fungicide + crithidia + workers_alive
##               Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>             43.367 281.62                      
## fungicide      1   43.939 280.19  0.5719    0.4495    
## crithidia      1   43.482 279.73  0.1144    0.7352    
## workers_alive  1   58.565 294.82 15.1974 9.684e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(em2)
## Analysis of Deviance Table (Type II tests)
## 
## Response: eggs
##               LR Chisq Df Pr(>Chisq)    
## fungicide       0.5719  1     0.4495    
## crithidia       0.1144  1     0.7352    
## workers_alive  15.1974  1  9.684e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(em2)
## 
## Call:
## glm.nb(formula = eggs ~ fungicide + crithidia + workers_alive, 
##     data = brood, init.theta = 0.9210361052, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.5071  -1.0676  -0.1225   0.3527   1.6103  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)     0.7006     0.6135   1.142    0.253    
## fungicideTRUE   0.2787     0.3643   0.765    0.444    
## crithidiaTRUE  -0.1241     0.3840  -0.323    0.747    
## workers_alive   0.5793     0.1265   4.579 4.67e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.921) family taken to be 1)
## 
##     Null deviance: 59.183  on 35  degrees of freedom
## Residual deviance: 43.367  on 32  degrees of freedom
## AIC: 283.62
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.921 
##           Std. Err.:  0.251 
## 
##  2 x log-likelihood:  -273.620
plot(brood$treatment, brood$eggs)

total honey pot

hp.mod <- glm.nb(honey_pots ~ fungicide + crithidia + avg_pollen + workers_alive, data = brood)
hp.mod.pois <- glm.nb(honey_pots ~ fungicide + crithidia + avg_pollen + workers_alive, data = brood)
summary(hp.mod.pois)
## 
## Call:
## glm.nb(formula = honey_pots ~ fungicide + crithidia + avg_pollen + 
##     workers_alive, data = brood, init.theta = 19.67711085, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9346  -0.8011  -0.3146   0.3049   2.1513  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)   
## (Intercept)    -0.4199     0.4270  -0.983  0.32542   
## fungicideTRUE   0.4100     0.2147   1.910  0.05614 . 
## crithidiaTRUE  -0.2156     0.2246  -0.960  0.33705   
## avg_pollen      1.7467     0.6130   2.849  0.00438 **
## workers_alive   0.1452     0.1121   1.296  0.19503   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(19.6771) family taken to be 1)
## 
##     Null deviance: 67.908  on 35  degrees of freedom
## Residual deviance: 35.669  on 31  degrees of freedom
## AIC: 143.06
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  19.7 
##           Std. Err.:  30.4 
## 
##  2 x log-likelihood:  -131.059
anova(hp.mod, hp.mod.pois, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
## 
## Response: honey_pots
##                                                Model    theta Resid. df
## 1 fungicide + crithidia + avg_pollen + workers_alive 19.67711        31
## 2 fungicide + crithidia + avg_pollen + workers_alive 19.67711        31
##      2 x log-lik.   Test    df LR stat. Pr(Chi)
## 1       -131.0589                              
## 2       -131.0589 1 vs 2     0        0       1
AIC(hp.mod, hp.mod.pois)
##             df      AIC
## hp.mod       6 143.0589
## hp.mod.pois  6 143.0589
drop1(hp.mod.pois, test = "Chisq")
## Single term deletions
## 
## Model:
## honey_pots ~ fungicide + crithidia + avg_pollen + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)   
## <none>             35.669 141.06                   
## fungicide      1   39.320 142.71 3.6505 0.056053 . 
## crithidia      1   36.596 139.99 0.9269 0.335659   
## avg_pollen     1   43.770 147.16 8.1004 0.004425 **
## workers_alive  1   37.407 140.80 1.7372 0.187489   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
hp1 <- update(hp.mod.pois, .~. -workers_alive)
drop1(hp1, test = "Chisq")
## Single term deletions
## 
## Model:
## honey_pots ~ fungicide + crithidia + avg_pollen
##            Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>          36.875 140.79                      
## fungicide   1   40.087 142.00  3.2115   0.07312 .  
## crithidia   1   38.392 140.31  1.5173   0.21803    
## avg_pollen  1   59.717 161.63 22.8423 1.758e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(hp.mod, hp1)
## Likelihood ratio tests of Negative Binomial Models
## 
## Response: honey_pots
##                                                Model    theta Resid. df
## 1                 fungicide + crithidia + avg_pollen 17.57633        32
## 2 fungicide + crithidia + avg_pollen + workers_alive 19.67711        31
##      2 x log-lik.   Test    df LR stat.   Pr(Chi)
## 1       -132.7911                                
## 2       -131.0589 1 vs 2     1 1.732166 0.1881346
Anova(hp.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: honey_pots
##               LR Chisq Df Pr(>Chisq)   
## fungicide       3.6505  1   0.056053 . 
## crithidia       0.9269  1   0.335659   
## avg_pollen      8.1004  1   0.004425 **
## workers_alive   1.7372  1   0.187489   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(hp.mod, hp1)
##        df      AIC
## hp.mod  6 143.0589
## hp1     5 142.7911
Anova(hp1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: honey_pots
##            LR Chisq Df Pr(>Chisq)    
## fungicide    3.2115  1    0.07312 .  
## crithidia    1.5173  1    0.21803    
## avg_pollen  22.8423  1  1.758e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(hp1)
## 
## Call:
## glm.nb(formula = honey_pots ~ fungicide + crithidia + avg_pollen, 
##     data = brood, init.theta = 17.5763296, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0615  -0.7252  -0.3248   0.4896   2.2243  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   -0.08803    0.33089  -0.266   0.7902    
## fungicideTRUE  0.38631    0.21588   1.789   0.0735 .  
## crithidiaTRUE -0.27473    0.22410  -1.226   0.2202    
## avg_pollen     2.28998    0.46852   4.888 1.02e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(17.5763) family taken to be 1)
## 
##     Null deviance: 66.981  on 35  degrees of freedom
## Residual deviance: 36.875  on 32  degrees of freedom
## AIC: 142.79
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  17.6 
##           Std. Err.:  25.2 
## 
##  2 x log-likelihood:  -132.791
hpem_contrast <- emmeans(hp1, pairwise ~ fungicide, type = "response")
hpem_contrast
## $emmeans
##  fungicide response    SE  df asymp.LCL asymp.UCL
##  FALSE         2.09 0.356 Inf      1.49      2.91
##  TRUE          3.07 0.457 Inf      2.29      4.11
## 
## Results are averaged over the levels of: crithidia 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale 
## 
## $contrasts
##  contrast     ratio    SE  df null z.ratio p.value
##  FALSE / TRUE  0.68 0.147 Inf    1  -1.789  0.0735
## 
## Results are averaged over the levels of: crithidia 
## Tests are performed on the log scale
hpem <- emmeans(hp1, pairwise ~ fungicide*crithidia, type = "response")
hpem
## $emmeans
##  fungicide crithidia response    SE  df asymp.LCL asymp.UCL
##  FALSE     FALSE         2.39 0.473 Inf      1.63      3.52
##  TRUE      FALSE         3.52 0.622 Inf      2.49      4.98
##  FALSE     TRUE          1.82 0.383 Inf      1.20      2.75
##  TRUE      TRUE          2.68 0.524 Inf      1.82      3.93
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale 
## 
## $contrasts
##  contrast                 ratio    SE  df null z.ratio p.value
##  FALSE FALSE / TRUE FALSE 0.680 0.147 Inf    1  -1.789  0.2783
##  FALSE FALSE / FALSE TRUE 1.316 0.295 Inf    1   1.226  0.6103
##  FALSE FALSE / TRUE TRUE  0.894 0.281 Inf    1  -0.355  0.9846
##  TRUE FALSE / FALSE TRUE  1.937 0.597 Inf    1   2.144  0.1394
##  TRUE FALSE / TRUE TRUE   1.316 0.295 Inf    1   1.226  0.6103
##  FALSE TRUE / TRUE TRUE   0.680 0.147 Inf    1  -1.789  0.2783
## 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## Tests are performed on the log scale
hpem.df <- as.data.frame(hpem$emmeans)
hpem.df
##  fungicide crithidia response        SE  df asymp.LCL asymp.UCL
##  FALSE     FALSE     2.393723 0.4725121 Inf  1.625736  3.524504
##  TRUE      FALSE     3.522452 0.6223151 Inf  2.491509  4.979981
##  FALSE     TRUE      1.818697 0.3827489 Inf  1.203990  2.747246
##  TRUE      TRUE      2.676278 0.5235407 Inf  1.823967  3.926862
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale
hpem.df$treatment <- c(1, 2, 4, 3)
hpem.df$treatment <-as.factor(hpem.df$treatment)

hp_sum <- brood %>%
  group_by(treatment) %>%
  summarize(m = mean(honey_pots),
            sd = sd(honey_pots),
            l = length(honey_pots)) %>%
  mutate(se = sqrt(sd/l))

hp_sum
## # A tibble: 4 × 5
##   treatment     m    sd     l    se
##   <fct>     <dbl> <dbl> <int> <dbl>
## 1 1          3.33  2.5      9 0.527
## 2 2          4.11  3.02     9 0.579
## 3 3          2.56  2.24     9 0.499
## 4 4          1.89  1.90     9 0.460
hpcld <-  cld(object = hpem,
                 adjust = "Tukey",
                 Letters = letters,
                 alpha = 0.05)
hpcld
##  fungicide crithidia response    SE  df asymp.LCL asymp.UCL .group
##  FALSE     TRUE          1.82 0.383 Inf      1.08      3.07  a    
##  FALSE     FALSE         2.39 0.473 Inf      1.46      3.91  a    
##  TRUE      TRUE          2.68 0.524 Inf      1.64      4.36  a    
##  TRUE      FALSE         3.52 0.622 Inf      2.27      5.47  a    
## 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 4 estimates 
## Intervals are back-transformed from the log scale 
## P value adjustment: tukey method for comparing a family of 4 estimates 
## Tests are performed on the log scale 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
plot(brood$treatment, brood$honey_pots)

ggplot(data = hpem.df, aes(x = treatment, y = response, fill = treatment)) +
  geom_col_pattern(
    aes(pattern_density = treatment),
    pattern = "stripe",   # Set a common pattern type, but differentiate density
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the third column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 5.5)) +
  geom_errorbar(aes(ymin = response - SE, ymax = response + SE), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Honeypots") +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 1,
    y = 4,
    label = "P = 0.05",
    size = 7
  ) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_density_manual(values = c(0, 0, 0, 0.4)) +
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
   geom_segment(x = 2, xend = 3, y = 4.6, yend = 4.6, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 4.4, yend = 4.8, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 4.4, yend = 4.8, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 4, y = 5.2, yend = 5.2, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 5, yend = 5.4, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 5, yend = 5.4, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 2.5, y = 4.5, label = "b", size = 6, vjust = -0.5) +
  geom_text(x = 2.5, y = 5.2, label = "a", size = 6, vjust = -0.5)

total drone count

plot(brood$treatment, brood$drones)

dronecount.mod <- glm(total_drones ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen, data = brood, family = "poisson")
summary(dronecount.mod) #overdisp
## 
## Call:
## glm(formula = total_drones ~ fungicide + crithidia + workers_alive + 
##     block + duration + avg_pollen, family = "poisson", data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9548  -0.8831  -0.1200   0.2351   2.0003  
## 
## Coefficients:
##                 Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    2.569e+00  1.411e+00   1.821   0.0686 .  
## fungicideTRUE  3.633e-02  1.374e-01   0.264   0.7915    
## crithidiaTRUE  2.629e-02  1.351e-01   0.195   0.8457    
## workers_alive  1.418e-01  1.005e-01   1.411   0.1583    
## block4        -2.358e-01  3.810e-01  -0.619   0.5360    
## block6        -1.760e+01  1.728e+03  -0.010   0.9919    
## block7         5.448e-02  3.538e-01   0.154   0.8776    
## block8        -3.568e-01  3.738e-01  -0.955   0.3398    
## block9         2.143e-01  3.289e-01   0.652   0.5146    
## block10        8.056e-01  3.505e-01   2.298   0.0215 *  
## block11        2.199e-01  3.944e-01   0.558   0.5771    
## block12       -9.284e-04  4.101e-01  -0.002   0.9982    
## duration      -6.552e-02  2.833e-02  -2.312   0.0208 *  
## avg_pollen     3.210e+00  6.942e-01   4.624 3.77e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 308.730  on 35  degrees of freedom
## Residual deviance:  42.559  on 22  degrees of freedom
## AIC: 171.75
## 
## Number of Fisher Scoring iterations: 15
dronecount.mod.nb <- glm.nb(total_drones ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen, data = brood)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(total_drones ~ fungicide + crithidia + workers_alive + :
## alternation limit reached
qqnorm(resid(dronecount.mod));qqline(resid(dronecount.mod))

qqnorm(resid(dronecount.mod.nb));qqline(resid(dronecount.mod.nb))

anova(dronecount.mod, dronecount.mod.nb, test = "Chisq")
## Analysis of Deviance Table
## 
## Model 1: total_drones ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
## Model 2: total_drones ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
##   Resid. Df Resid. Dev Df  Deviance Pr(>Chi)
## 1        22     42.559                      
## 2        22     42.554  0 0.0050672
AIC(dronecount.mod, dronecount.mod.nb)
##                   df      AIC
## dronecount.mod    14 171.7458
## dronecount.mod.nb 15 173.7469
dronecount.mod.int <- glm.nb(total_drones ~ fungicide + crithidia + workers_alive + block + duration + avg_pollen, data = brood)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(total_drones ~ fungicide + crithidia + workers_alive + :
## alternation limit reached
drop1(dronecount.mod.int, test = "Chisq")
## Single term deletions
## 
## Model:
## total_drones ~ fungicide + crithidia + workers_alive + block + 
##     duration + avg_pollen
##               Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>             42.554 171.75                     
## fungicide      1   42.624 169.82  0.070   0.79147    
## crithidia      1   42.592 169.78  0.038   0.84583    
## workers_alive  1   44.579 171.77  2.025   0.15470    
## block          8   81.306 194.50 38.752 5.464e-06 ***
## duration       1   47.567 174.76  5.013   0.02516 *  
## avg_pollen     1   65.390 192.58 22.836 1.765e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dc1 <- update(dronecount.mod.int, .~. -workers_alive)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(dc1, test = "Chisq")
## Single term deletions
## 
## Model:
## total_drones ~ fungicide + crithidia + block + duration + avg_pollen
##            Df Deviance    AIC    LRT  Pr(>Chi)    
## <none>          44.579 171.77                     
## fungicide   1   44.581 169.77  0.002  0.968223    
## crithidia   1   44.583 169.78  0.003  0.953432    
## block       8   85.579 196.77 40.999 2.085e-06 ***
## duration    1   51.401 176.59  6.822  0.009006 ** 
## avg_pollen  1   94.523 219.72 49.944 1.582e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(dronecount.mod.int)
## Analysis of Deviance Table (Type II tests)
## 
## Response: total_drones
##               LR Chisq Df Pr(>Chisq)    
## fungicide        0.070  1    0.79147    
## crithidia        0.038  1    0.84583    
## workers_alive    2.025  1    0.15470    
## block           38.752  8  5.464e-06 ***
## duration         5.013  1    0.02516 *  
## avg_pollen      22.836  1  1.765e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(brood$treatment, brood$total_drones)

qqnorm(resid(dc1));qqline(resid(dc1))

summary(dc1)
## 
## Call:
## glm.nb(formula = total_drones ~ fungicide + crithidia + block + 
##     duration + avg_pollen, data = brood, init.theta = 48824.30615, 
##     link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -1.91115  -0.96690  -0.04188   0.30977   2.00077  
## 
## Coefficients:
##                 Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    3.254e+00  1.288e+00   2.526  0.01155 *  
## fungicideTRUE -5.323e-03  1.336e-01  -0.040  0.96822    
## crithidiaTRUE  7.849e-03  1.344e-01   0.058  0.95343    
## block4        -3.822e-01  3.708e-01  -1.031  0.30274    
## block6        -1.915e+01  3.649e+03  -0.005  0.99581    
## block7        -6.464e-02  3.471e-01  -0.186  0.85226    
## block8        -4.638e-01  3.712e-01  -1.249  0.21159    
## block9         2.513e-01  3.280e-01   0.766  0.44362    
## block10        6.737e-01  3.344e-01   2.015  0.04396 *  
## block11        1.909e-01  3.938e-01   0.485  0.62781    
## block12       -2.884e-01  3.654e-01  -0.789  0.42986    
## duration      -7.220e-02  2.697e-02  -2.677  0.00743 ** 
## avg_pollen     3.800e+00  5.659e-01   6.714  1.9e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(48824.31) family taken to be 1)
## 
##     Null deviance: 308.688  on 35  degrees of freedom
## Residual deviance:  44.579  on 23  degrees of freedom
## AIC: 173.77
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  48824 
##           Std. Err.:  812854 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -145.772
Anova(dc1)
## Analysis of Deviance Table (Type II tests)
## 
## Response: total_drones
##            LR Chisq Df Pr(>Chisq)    
## fungicide     0.002  1   0.968223    
## crithidia     0.003  1   0.953432    
## block        40.999  8  2.085e-06 ***
## duration      6.822  1   0.009006 ** 
## avg_pollen   49.944  1  1.582e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drones_sum <- brood %>%
  group_by(treatment) %>%
  summarise(mb = mean(total_drones),
            nb = length(total_drones), 
            sdb = sd(total_drones)) %>%
  mutate(seb = (sdb/sqrt(nb)))

drones_sum
## # A tibble: 4 × 5
##   treatment    mb    nb   sdb   seb
##   <fct>     <dbl> <int> <dbl> <dbl>
## 1 1         11.3      9  7.84  2.61
## 2 2          7.67     9  7.37  2.46
## 3 3          5.44     9  8.16  2.72
## 4 4          6.89     9  7.18  2.39
drones_sum$plot <- drones_sum$mb + drones_sum$seb
ggplot(data = drones_sum, aes(x = treatment, y = mb, fill = treatment)) +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  coord_cartesian(ylim = c(0, 17)) +
  geom_errorbar(aes(ymin = mb - seb, ymax = mb + seb), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Average Adults Males") +
  annotate(
    geom = "text",
    x = c(1, 2, 3, 4),
    y = drones_sum$plot + 1,  # Adjust the y-position as needed
    label = c("a", "a", "a", "a"),
    size = 8
  ) +
  theme_classic(base_size = 20) +
  annotate(
    geom = "text",
    x = 1,
    y = 16,
    label = "P > 0.5",
    size = 7
  ) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none")

proportion larvae and pupae survival

proportion larvae

plmod <- glm(cbind(live_larvae, dead_larvae) ~ fungicide + crithidia + avg_pollen + block + duration + workers_alive, data = brood, family = binomial("logit"))
Anova(plmod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(live_larvae, dead_larvae)
##               LR Chisq Df Pr(>Chisq)   
## fungicide       0.2335  1   0.628962   
## crithidia       0.0073  1   0.931992   
## avg_pollen      1.3257  1   0.249572   
## block          26.0519  8   0.001029 **
## duration        5.9041  1   0.015106 * 
## workers_alive   1.1226  1   0.289357   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(plmod, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live_larvae, dead_larvae) ~ fungicide + crithidia + avg_pollen + 
##     block + duration + workers_alive
##               Df Deviance    AIC     LRT Pr(>Chi)   
## <none>             46.944 114.62                    
## fungicide      1   47.178 112.85  0.2335 0.628962   
## crithidia      1   46.952 112.62  0.0073 0.931992   
## avg_pollen     1   48.270 113.94  1.3257 0.249572   
## block          8   72.996 124.67 26.0519 0.001029 **
## duration       1   52.848 118.52  5.9041 0.015106 * 
## workers_alive  1   48.067 113.74  1.1226 0.289357   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plmod1 <- update(plmod, .~. -workers_alive)
drop1(plmod1, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live_larvae, dead_larvae) ~ fungicide + crithidia + avg_pollen + 
##     block + duration
##            Df Deviance    AIC     LRT Pr(>Chi)   
## <none>          48.067 113.74                    
## fungicide   1   48.310 111.98  0.2435 0.621688   
## crithidia   1   48.119 111.79  0.0525 0.818706   
## avg_pollen  1   48.596 112.27  0.5290 0.467034   
## block       8   73.013 122.69 24.9462 0.001588 **
## duration    1   58.565 122.24 10.4982 0.001195 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plmod2 <- update(plmod1, .~. -avg_pollen)
drop1(plmod2, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live_larvae, dead_larvae) ~ fungicide + crithidia + block + 
##     duration
##           Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>         48.596 112.27                      
## fungicide  1   48.829 110.50  0.2330 0.6292730    
## crithidia  1   48.616 110.29  0.0199 0.8877947    
## block      8   77.731 125.40 29.1347 0.0003003 ***
## duration   1   59.635 121.31 11.0388 0.0008922 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(plmod2)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(live_larvae, dead_larvae)
##           LR Chisq Df Pr(>Chisq)    
## fungicide   0.2330  1  0.6292730    
## crithidia   0.0199  1  0.8877947    
## block      29.1347  8  0.0003003 ***
## duration   11.0388  1  0.0008922 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(plmod2)
## 
## Call:
## glm(formula = cbind(live_larvae, dead_larvae) ~ fungicide + crithidia + 
##     block + duration, family = binomial("logit"), data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.3237  -0.5519   0.0000   0.7894   2.5069  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   14.60178    3.97877   3.670 0.000243 ***
## fungicideTRUE  0.17912    0.37191   0.482 0.630077    
## crithidiaTRUE -0.04958    0.35142  -0.141 0.887792    
## block4        -1.42228    0.88102  -1.614 0.106452    
## block6        -1.56753    1.01330  -1.547 0.121875    
## block7        -1.97885    0.86417  -2.290 0.022028 *  
## block8        -1.37953    0.92912  -1.485 0.137603    
## block9        -2.07110    0.86256  -2.401 0.016345 *  
## block10        1.04134    0.65380   1.593 0.111216    
## block11       -1.44815    1.30648  -1.108 0.267675    
## block12       -0.08539    0.76238  -0.112 0.910824    
## duration      -0.26367    0.08352  -3.157 0.001595 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 79.536  on 27  degrees of freedom
## Residual deviance: 48.596  on 16  degrees of freedom
## AIC: 112.27
## 
## Number of Fisher Scoring iterations: 5
plot(plmod2)
## Warning: not plotting observations with leverage one:
##   2

proportion pupae

ppmod <- glm(cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + avg_pollen + block + duration + workers_alive, data = brood, family = binomial("logit"))
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
Anova(ppmod)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(live_pupae, dead_pupae)
##               LR Chisq Df Pr(>Chisq)    
## fungicide         0.47  1     0.4948    
## crithidia         0.00  1     1.0000    
## avg_pollen        0.00  1     1.0000    
## block             7.89  8     0.4447    
## duration        334.66  1     <2e-16 ***
## workers_alive     5.85  1     0.0156 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(ppmod, test = "Chisq")
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Single term deletions
## 
## Model:
## cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + avg_pollen + 
##     block + duration + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)    
## <none>               0.00  36.63                    
## fungicide      1     0.47  35.10   0.47   0.4948    
## crithidia      1     0.00  34.63   0.00   1.0000    
## avg_pollen     1     0.00  34.63   0.00   1.0000    
## block          8     7.89  28.52   7.89   0.4447    
## duration       1   334.66 369.29 334.66   <2e-16 ***
## workers_alive  1     5.85  40.48   5.85   0.0156 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ppmod1 <- update(ppmod, .~. -block)
drop1(ppmod1, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + avg_pollen + 
##     duration + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             7.8857 28.518                  
## fungicide      1   8.5302 27.163 0.6445  0.42207  
## crithidia      1   9.3781 28.011 1.4925  0.22184  
## avg_pollen     1  11.8154 30.448 3.9298  0.04744 *
## duration       1  10.9993 29.632 3.1137  0.07764 .
## workers_alive  1  14.4788 33.112 6.5931  0.01024 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ppmod2 <- update(ppmod1, .~. -duration)
drop1(ppmod2, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + avg_pollen + 
##     workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)   
## <none>             10.999 29.632                   
## fungicide      1   11.021 27.653 0.0211 0.884443   
## crithidia      1   11.486 28.119 0.4864 0.485529   
## avg_pollen     1   12.481 29.114 1.4817 0.223507   
## workers_alive  1   18.067 34.699 7.0672 0.007851 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ppmod3 <- update(ppmod2, .~. -avg_pollen)
drop1(ppmod3, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + workers_alive
##               Df Deviance    AIC    LRT Pr(>Chi)  
## <none>             12.481 29.114                  
## fungicide      1   12.559 27.192 0.0779  0.78011  
## crithidia      1   12.525 27.158 0.0444  0.83313  
## workers_alive  1   18.536 33.169 6.0550  0.01387 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(ppmod3)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(live_pupae, dead_pupae)
##               LR Chisq Df Pr(>Chisq)  
## fungicide       0.0779  1    0.78011  
## crithidia       0.0444  1    0.83313  
## workers_alive   6.0550  1    0.01387 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(ppmod3)
## 
## Call:
## glm(formula = cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + 
##     workers_alive, family = binomial("logit"), data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.7274   0.0000   0.2950   0.4739   0.9934  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)  
## (Intercept)    0.06189    2.02471   0.031    0.976  
## fungicideTRUE  0.32433    1.17111   0.277    0.782  
## crithidiaTRUE -0.23659    1.11658  -0.212    0.832  
## workers_alive  0.86841    0.36701   2.366    0.018 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 20.674  on 24  degrees of freedom
## Residual deviance: 12.481  on 21  degrees of freedom
## AIC: 29.114
## 
## Number of Fisher Scoring iterations: 6

proportion larvae and pupae

brood$live.lp <- brood$live_larvae + brood$live_pupae
brood$dead.lp <- brood$dead_larvae + brood$dead_pupae


lp.mod <- glm(cbind(live.lp, dead.lp) ~ fungicide + crithidia + block + duration, data = brood, family = binomial("logit"))
drop1(lp.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## cbind(live.lp, dead.lp) ~ fungicide + crithidia + block + duration
##           Df Deviance    AIC     LRT  Pr(>Chi)    
## <none>         49.967 117.75                      
## fungicide  1   50.195 115.98  0.2287 0.6324816    
## crithidia  1   50.106 115.89  0.1398 0.7085134    
## block      8   71.401 123.19 21.4348 0.0060778 ** 
## duration   1   60.986 126.78 11.0197 0.0009015 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(lp.mod)
## 
## Call:
## glm(formula = cbind(live.lp, dead.lp) ~ fungicide + crithidia + 
##     block + duration, family = binomial("logit"), data = brood)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.7214  -0.2108   0.0000   0.8444   2.4278  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    14.4401     3.7762   3.824 0.000131 ***
## fungicideTRUE   0.1698     0.3558   0.477 0.633193    
## crithidiaTRUE  -0.1214     0.3245  -0.374 0.708384    
## block4         -1.5238     0.8558  -1.781 0.074988 .  
## block6         -1.7535     0.9540  -1.838 0.066072 .  
## block7         -1.9081     0.8343  -2.287 0.022188 *  
## block8         -1.2544     0.9113  -1.376 0.168680    
## block9         -1.9538     0.8137  -2.401 0.016340 *  
## block10         0.4782     0.6109   0.783 0.433707    
## block11        -1.3380     1.2701  -1.053 0.292157    
## block12        -0.5217     0.7178  -0.727 0.467398    
## duration       -0.2509     0.0791  -3.172 0.001516 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 76.309  on 27  degrees of freedom
## Residual deviance: 49.967  on 16  degrees of freedom
## AIC: 117.76
## 
## Number of Fisher Scoring iterations: 5
Anova(lp.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: cbind(live.lp, dead.lp)
##           LR Chisq Df Pr(>Chisq)    
## fungicide   0.2287  1  0.6324816    
## crithidia   0.1398  1  0.7085134    
## block      21.4348  8  0.0060778 ** 
## duration   11.0197  1  0.0009015 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Drones health metric

Dry Weight

drones$fungicide <- as.factor(drones$fungicide)
drones$crithidia <- as.factor(drones$crithidia)

plot(drones$treatment, drones$dry_weight)

plot(drones_rf$treatment, drones_rf$dry_weight)

plot(brood$treatment, brood$drones)

shapiro.test(drones$dry_weight)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones$dry_weight
## W = 0.99166, p-value = 0.1135
hist(drones$dry_weight)

range(drones$dry_weight)
## [1] 0.0166 0.0541
dry <- lmer(dry_weight ~ fungicide + crithidia + workers_alive + block + emerge + (1|colony), data = drones)
drop1(dry, test = "Chisq")
## Single term deletions
## 
## Model:
## dry_weight ~ fungicide + crithidia + workers_alive + block + 
##     emerge + (1 | colony)
##               npar     AIC     LRT Pr(Chi)  
## <none>             -1999.9                  
## fungicide        1 -2001.7  0.1493 0.69923  
## crithidia        1 -1997.3  4.5582 0.03276 *
## workers_alive    1 -2000.1  1.7920 0.18069  
## block            7 -1997.3 16.6047 0.02013 *
## emerge           1 -1998.7  3.1875 0.07420 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dry1 <- update(dry, .~. -workers_alive)
drop1(dry1, test= "Chisq")
## Single term deletions
## 
## Model:
## dry_weight ~ fungicide + crithidia + block + emerge + (1 | colony)
##           npar     AIC     LRT Pr(Chi)  
## <none>         -2000.1                  
## fungicide    1 -2001.2  0.9199 0.33749  
## crithidia    1 -1998.5  3.5794 0.05850 .
## block        7 -1998.1 16.0008 0.02511 *
## emerge       1 -1998.1  3.9614 0.04656 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dry2 <- update(dry1, .~. -block)
drop1(dry2, test = "Chisq")
## Single term deletions
## 
## Model:
## dry_weight ~ fungicide + crithidia + emerge + (1 | colony)
##           npar     AIC    LRT Pr(Chi)  
## <none>         -1998.1                 
## fungicide    1 -1999.9 0.1553 0.69350  
## crithidia    1 -1999.3 0.7209 0.39585  
## emerge       1 -1993.8 6.2922 0.01213 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(dry2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: dry_weight
##            Chisq Df Pr(>Chisq)  
## fungicide 0.1985  1    0.65596  
## crithidia 0.6241  1    0.42951  
## emerge    6.0119  1    0.01421 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(dry2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: dry_weight ~ fungicide + crithidia + emerge + (1 | colony)
##    Data: drones
## 
## REML criterion at convergence: -1958.8
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.86701 -0.59248 -0.03622  0.60958  2.58281 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  colony   (Intercept) 6.923e-06 0.002631
##  Residual             4.271e-05 0.006535
## Number of obs: 281, groups:  colony, 24
## 
## Fixed effects:
##               Estimate Std. Error t value
## (Intercept)  0.0522562  0.0059986   8.711
## fungicide1  -0.0006294  0.0014127  -0.446
## crithidia1   0.0011136  0.0014096   0.790
## emerge      -0.0003927  0.0001602  -2.452
## 
## Correlation of Fixed Effects:
##            (Intr) fngcd1 crthd1
## fungicide1  0.073              
## crithidia1 -0.072 -0.002       
## emerge     -0.983 -0.177 -0.023
sum_dry <- drones %>%
  group_by(treatment) %>%
  summarise(m = mean(dry_weight),
            sd = sd(dry_weight),
            n = length(dry_weight)) %>%
  mutate(se = sd/sqrt(n))

sum_dry
## # A tibble: 4 × 5
##   treatment      m      sd     n       se
##   <fct>      <dbl>   <dbl> <int>    <dbl>
## 1 1         0.0373 0.00752   102 0.000745
## 2 2         0.0376 0.00653    69 0.000786
## 3 3         0.0378 0.00706    49 0.00101 
## 4 4         0.0393 0.00665    61 0.000852

Radial Cell

drones.na <- na.omit(drones)
drones.na$alive <- as.logical(drones.na$`alive?`)

shapiro.test(drones$radial_cell)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones$radial_cell
## W = 0.97715, p-value = 0.0001916
hist(drones$radial_cell)

descdist(drones.na$radial_cell, discrete = FALSE)

## summary statistics
## ------
## min:  2073.526   max:  3083.439 
## median:  2710.923 
## mean:  2694.575 
## estimated sd:  171.6365 
## estimated skewness:  -0.5726179 
## estimated kurtosis:  4.019655
range(drones$radial_cell)
## [1] NA NA
drones.na$square <- drones.na$radial_cell^3
shapiro.test(drones.na$square)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones.na$square
## W = 0.99215, p-value = 0.1516
hist(drones.na$square)

drones.na$log <- log(drones.na$radial_cell)
shapiro.test(drones.na$log)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones.na$log
## W = 0.95963, p-value = 5.927e-07
hist(drones.na$square)

rad_mod <- lmer(square ~ fungicide + crithidia + workers_alive + block + mean.pollen + emerge + alive + (1|colony), data = drones.na)
drop1(rad_mod, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + workers_alive + block + mean.pollen + 
##     emerge + alive + (1 | colony)
##               npar   AIC     LRT  Pr(Chi)   
## <none>             12934                    
## fungicide        1 12939  7.2355 0.007148 **
## crithidia        1 12933  1.3953 0.237507   
## workers_alive    1 12934  1.7286 0.188584   
## block            7 12932 11.7617 0.108673   
## mean.pollen      1 12935  3.3474 0.067311 . 
## emerge           1 12936  4.4149 0.035627 * 
## alive            1 12933  1.4090 0.235217   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm1 <- update(rad_mod, .~. -block)
drop1(rm1, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + workers_alive + mean.pollen + 
##     emerge + alive + (1 | colony)
##               npar   AIC    LRT  Pr(Chi)   
## <none>             12932                   
## fungicide        1 12932 2.9510 0.085825 . 
## crithidia        1 12930 0.7704 0.380101   
## workers_alive    1 12930 0.2499 0.617119   
## mean.pollen      1 12930 0.2225 0.637150   
## emerge           1 12936 6.7496 0.009377 **
## alive            1 12930 0.7498 0.386527   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm2 <- update(rm1, .~. -workers_alive)
drop1(rm2, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + mean.pollen + emerge + alive + 
##     (1 | colony)
##             npar   AIC    LRT Pr(Chi)   
## <none>           12930                  
## fungicide      1 12931 3.5558 0.05934 . 
## crithidia      1 12928 0.6686 0.41353   
## mean.pollen    1 12928 0.6137 0.43340   
## emerge         1 12935 7.0223 0.00805 **
## alive          1 12929 0.7897 0.37419   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm3 <- update(rm2, .~. -mean.pollen)
drop1(rm3, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + emerge + alive + (1 | colony)
##           npar   AIC    LRT  Pr(Chi)   
## <none>         12928                   
## fungicide    1 12930 3.6326 0.056657 . 
## crithidia    1 12927 0.5522 0.457427   
## emerge       1 12935 8.1007 0.004425 **
## alive        1 12927 0.8091 0.368391   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm4 <- update(rm3, .~. -alive)
drop1(rm4, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + emerge + (1 | colony)
##           npar   AIC    LRT  Pr(Chi)   
## <none>         12927                   
## fungicide    1 12929 3.8119 0.050889 . 
## crithidia    1 12926 0.6516 0.419537   
## emerge       1 12933 7.9923 0.004698 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(rm4)
## Linear mixed model fit by REML ['lmerMod']
## Formula: square ~ fungicide + crithidia + emerge + (1 | colony)
##    Data: drones.na
## 
## REML criterion at convergence: 12752
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9415 -0.5357  0.0455  0.5915  2.9574 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev. 
##  colony   (Intercept) 8.620e+17 9.284e+08
##  Residual             1.189e+19 3.448e+09
## Number of obs: 276, groups:  colony, 24
## 
## Fixed effects:
##               Estimate Std. Error t value
## (Intercept)  2.858e+10  3.044e+09   9.388
## fungicide1  -1.143e+09  6.022e+08  -1.898
## crithidia1   4.190e+08  5.965e+08   0.703
## emerge      -2.274e+08  8.179e+07  -2.781
## 
## Correlation of Fixed Effects:
##            (Intr) fngcd1 crthd1
## fungicide1  0.123              
## crithidia1 -0.055 -0.009       
## emerge     -0.989 -0.206 -0.022
Anova(rm4)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: square
##            Chisq Df Pr(>Chisq)   
## fungicide 3.6022  1   0.057704 . 
## crithidia 0.4935  1   0.482353   
## emerge    7.7324  1   0.005424 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rad_mod <- lmer(square ~ fungicide + crithidia + workers_alive + block + mean.pollen + days_active + alive + (1|colony), data = drones.na)
drop1(rad_mod, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + workers_alive + block + mean.pollen + 
##     days_active + alive + (1 | colony)
##               npar   AIC     LRT  Pr(Chi)   
## <none>             12938                    
## fungicide        1 12946  9.4396 0.002124 **
## crithidia        1 12938  2.0127 0.155989   
## workers_alive    1 12939  2.5934 0.107306   
## block            7 12938 13.9266 0.052503 . 
## mean.pollen      1 12940  3.3790 0.066032 . 
## days_active      1 12936  0.0170 0.896404   
## alive            1 12938  1.2506 0.263436   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm1 <- update(rad_mod, .~. -days_active)
drop1(rm1, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + workers_alive + block + mean.pollen + 
##     alive + (1 | colony)
##               npar   AIC     LRT Pr(Chi)   
## <none>             12936                   
## fungicide        1 12944  9.8595 0.00169 **
## crithidia        1 12936  2.0132 0.15593   
## workers_alive    1 12937  2.6202 0.10551   
## block            7 12936 14.0964 0.04949 * 
## mean.pollen      1 12938  3.4592 0.06290 . 
## alive            1 12936  1.2552 0.26255   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm2 <- update(rm1, .~. -block)
drop1(rm2, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + workers_alive + mean.pollen + 
##     alive + (1 | colony)
##               npar   AIC    LRT Pr(Chi)  
## <none>             12936                 
## fungicide        1 12939 4.4893 0.03411 *
## crithidia        1 12935 0.7453 0.38796  
## workers_alive    1 12935 0.5227 0.46970  
## mean.pollen      1 12935 0.6837 0.40833  
## alive            1 12935 0.6207 0.43080  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm3 <- update(rm2, .~. -workers_alive)
drop1(rm3, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + mean.pollen + alive + (1 | colony)
##             npar   AIC    LRT Pr(Chi)  
## <none>           12935                 
## fungicide      1 12938 5.5520 0.01846 *
## crithidia      1 12934 0.5944 0.44074  
## mean.pollen    1 12935 1.6920 0.19333  
## alive          1 12934 0.6684 0.41362  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm5 <- update(rm3, .~. -alive)
drop1(rm5, test = "Chisq")
## Single term deletions
## 
## Model:
## square ~ fungicide + crithidia + mean.pollen + (1 | colony)
##             npar   AIC    LRT Pr(Chi)  
## <none>           12934                 
## fungicide      1 12937 5.7439 0.01655 *
## crithidia      1 12932 0.6878 0.40693  
## mean.pollen    1 12933 1.7244 0.18913  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rm6 <- update(rm5, .~. -mean.pollen)

summary(rm6)
## Linear mixed model fit by REML ['lmerMod']
## Formula: square ~ fungicide + crithidia + (1 | colony)
##    Data: drones.na
## 
## REML criterion at convergence: 12797.8
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.85719 -0.55413  0.02787  0.61341  2.71516 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev. 
##  colony   (Intercept) 1.111e+18 1.054e+09
##  Residual             1.208e+19 3.475e+09
## Number of obs: 276, groups:  colony, 24
## 
## Fixed effects:
##               Estimate Std. Error t value
## (Intercept)  2.022e+10  4.863e+08  41.589
## fungicide1  -1.526e+09  6.296e+08  -2.424
## crithidia1   3.586e+08  6.373e+08   0.563
## 
## Correlation of Fixed Effects:
##            (Intr) fngcd1
## fungicide1 -0.559       
## crithidia1 -0.518 -0.011
Anova(rm6)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: square
##            Chisq Df Pr(>Chisq)  
## fungicide 5.8751  1    0.01536 *
## crithidia 0.3165  1    0.57371  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(rm4, rm6, test = "Chisq")
## Data: drones.na
## Models:
## rm6: square ~ fungicide + crithidia + (1 | colony)
## rm4: square ~ fungicide + crithidia + emerge + (1 | colony)
##     npar   AIC   BIC  logLik deviance  Chisq Df Pr(>Chisq)   
## rm6    5 12933 12951 -6461.6    12923                        
## rm4    6 12927 12949 -6457.6    12915 7.9923  1   0.004698 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(rm4, rm6)
##     df      AIC
## rm4  6 12764.01
## rm6  5 12807.83
qqnorm(resid(rad_mod));qqline(resid(rad_mod))

qqnorm(resid(rm4));qqline(resid(rm4))

qqnorm(resid(rm6));qqline(resid(rm6))

Anova(rm3)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: square
##              Chisq Df Pr(>Chisq)  
## fungicide   5.0629  1    0.02444 *
## crithidia   0.4090  1    0.52249  
## mean.pollen 1.5012  1    0.22049  
## alive       0.7139  1    0.39815  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rem <- emmeans(rm6, pairwise ~ fungicide, type = "response")
rem
## $emmeans
##  fungicide   emmean       SE   df lower.CL upper.CL
##  0         2.04e+10 4.22e+08 17.1 1.95e+10 2.13e+10
##  1         1.89e+10 4.82e+08 21.1 1.79e+10 1.99e+10
## 
## Results are averaged over the levels of: crithidia 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                estimate       SE   df t.ratio p.value
##  fungicide0 - fungicide1 1.53e+09 6.34e+08 19.1   2.405  0.0265
## 
## Results are averaged over the levels of: crithidia 
## Degrees-of-freedom method: kenward-roger
re <-  setDT(as.data.frame(rem$emmeans))
cont_radial <- setDT(as.data.frame(rem$contrasts))
rad.cld <- cld(object =rem,
               adjust = "Tukey",
               Letters = letters,
               alpha = 0.05)

rad.cld
##  fungicide   emmean       SE   df lower.CL upper.CL .group
##  1         1.89e+10 4.82e+08 21.1 1.77e+10 2.00e+10  a    
##  0         2.04e+10 4.22e+08 17.1 1.94e+10 2.14e+10   b   
## 
## Results are averaged over the levels of: crithidia 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 2 estimates 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
sum_radial <- drones_rf %>%
  group_by(treatment) %>%
  summarise(m = mean(radial_cell),
            sd = sd(radial_cell),
            n = length(radial_cell)) %>%
  mutate(se = sd/sqrt(n))

sum_radial
## # A tibble: 4 × 5
##   treatment     m    sd     n    se
##   <fct>     <dbl> <dbl> <int> <dbl>
## 1 1         2699.  182.    99  18.3
## 2 2         2664.  174.    68  21.1
## 3 3         2660.  173.    49  24.7
## 4 4         2750.  136.    60  17.5
sum_radial$plot <- sum_radial$m + sum_radial$se
ggplot(sum_radial, aes(x = treatment, y = m, fill = treatment)) +
  geom_bar(stat = "identity", color = "black") +
  scale_fill_viridis_d() +
  geom_errorbar(aes(ymin = m - se, ymax = m + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Radial Cell Length (um)") +
  theme_classic(base_size = 20) +
  coord_cartesian(ylim=c(2620, 2800)) +
  annotate(geom = "text", 
           x = 1, y = 3 ,
           label = "P > 0.05",
           size = 8) +
  theme(legend.position = "none",
        axis.text = element_text(size = 20),  # Set axis label font size
        axis.title = element_text(size = 20)) +  # Set axis title font size
  theme(text = element_text(size = 20)) +
  annotate(geom = "text",
           label = "P = 0.06",
           x = 1, y = 2762,
           size = 7)

Relative Fat (original units g/um)

drones_rf$fungicide <-as.factor(drones_rf$fungicide)
drones_rf$crithidia <- as.factor(drones_rf$crithidia)

shapiro.test(drones_rf$relative_fat_original)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones_rf$relative_fat_original
## W = 0.97273, p-value = 4.049e-05
hist(drones_rf$relative_fat_original)

plot(drones_rf$treatment, drones_rf$relative_fat_original)

range(drones_rf$relative_fat_original)
## [1] 1.78e-07 3.40e-06
drones_rf$log_ref <- log(drones_rf$relative_fat_original)
shapiro.test(drones_rf$log_ref)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones_rf$log_ref
## W = 0.94339, p-value = 8.074e-09
drones_rf$squarerf <- sqrt(drones_rf$relative_fat_original)
shapiro.test(drones_rf$squarerf)
## 
##  Shapiro-Wilk normality test
## 
## data:  drones_rf$squarerf
## W = 0.99031, p-value = 0.06387
rf_mod <- lmer(squarerf ~ fungicide + crithidia + block + mean.pollen + workers_alive + emerge + (1|colony), data = drones_rf)
drop1(rf_mod, test = "Chisq")
## Single term deletions
## 
## Model:
## squarerf ~ fungicide + crithidia + block + mean.pollen + workers_alive + 
##     emerge + (1 | colony)
##               npar     AIC     LRT   Pr(Chi)    
## <none>             -3926.8                      
## fungicide        1 -3927.2  1.5763 0.2092949    
## crithidia        1 -3926.6  2.1577 0.1418577    
## block            7 -3922.1 18.6722 0.0092788 ** 
## mean.pollen      1 -3928.1  0.6181 0.4317364    
## workers_alive    1 -3928.7  0.0348 0.8519805    
## emerge           1 -3916.1 12.6298 0.0003796 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf1 <- update(rf_mod, .~. -mean.pollen)
drop1(rf1, test = "Chisq")
## Single term deletions
## 
## Model:
## squarerf ~ fungicide + crithidia + block + workers_alive + emerge + 
##     (1 | colony)
##               npar     AIC     LRT   Pr(Chi)    
## <none>             -3928.1                      
## fungicide        1 -3928.8  1.3699 0.2418298    
## crithidia        1 -3927.9  2.2779 0.1312301    
## block            7 -3922.2 19.9284 0.0057265 ** 
## workers_alive    1 -3929.8  0.3342 0.5632243    
## emerge           1 -3917.5 12.6776 0.0003701 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf2 <- update(rf1, .~. -workers_alive)
drop1(rf2, test = "Chisq")
## Single term deletions
## 
## Model:
## squarerf ~ fungicide + crithidia + block + emerge + (1 | colony)
##           npar     AIC     LRT   Pr(Chi)    
## <none>         -3929.8                      
## fungicide    1 -3930.7  1.0627 0.3025989    
## crithidia    1 -3929.1  2.6716 0.1021510    
## block        7 -3924.2 19.6016 0.0064976 ** 
## emerge       1 -3919.5 12.3463 0.0004419 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf3 <- update(rf2, .~. -block)
drop1(rf3, test = "Chisq")
## Single term deletions
## 
## Model:
## squarerf ~ fungicide + crithidia + emerge + (1 | colony)
##           npar     AIC     LRT   Pr(Chi)    
## <none>         -3924.2                      
## fungicide    1 -3926.2  0.0054   0.94158    
## crithidia    1 -3922.0  4.2162   0.04004 *  
## emerge       1 -3908.2 17.9955 2.214e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf4 <- update(rf3, .~. -crithidia)
drop1(rf4, test = "Chisq")
## Single term deletions
## 
## Model:
## squarerf ~ fungicide + emerge + (1 | colony)
##           npar     AIC     LRT   Pr(Chi)    
## <none>         -3922.0                      
## fungicide    1 -3924.0  0.0137    0.9068    
## emerge       1 -3906.6 17.3510 3.107e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(rf_mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: squarerf
##                 Chisq Df Pr(>Chisq)    
## fungicide      0.8451  1  0.3579549    
## crithidia      1.7576  1  0.1849263    
## block         11.6312  7  0.1133564    
## mean.pollen    0.0127  1  0.9101582    
## workers_alive  0.0298  1  0.8628689    
## emerge        14.1663  1  0.0001673 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(rf4)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: squarerf
##             Chisq Df Pr(>Chisq)    
## fungicide  0.0213  1     0.8839    
## emerge    17.9437  1  2.275e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(rf3)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: squarerf
##             Chisq Df Pr(>Chisq)    
## fungicide  0.0149  1    0.90287    
## crithidia  3.9457  1    0.04699 *  
## emerge    18.5688  1  1.639e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(rf3)
## Linear mixed model fit by REML ['lmerMod']
## Formula: squarerf ~ fungicide + crithidia + emerge + (1 | colony)
##    Data: drones_rf
## 
## REML criterion at convergence: -3857.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8428 -0.5043  0.0419  0.5569  3.9576 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev. 
##  colony   (Intercept) 8.144e-09 9.024e-05
##  Residual             3.419e-08 1.849e-04
## Number of obs: 276, groups:  colony, 24
## 
## Fixed effects:
##               Estimate Std. Error t value
## (Intercept)  1.789e-03  1.769e-04  10.113
## fungicide1  -5.541e-06  4.541e-05  -0.122
## crithidia1   9.031e-05  4.546e-05   1.986
## emerge      -2.031e-05  4.714e-06  -4.309
## 
## Correlation of Fixed Effects:
##            (Intr) fngcd1 crthd1
## fungicide1  0.046              
## crithidia1 -0.070  0.002       
## emerge     -0.980 -0.162 -0.035
anova(rf3, rf4, test = "Chisq")
## Data: drones_rf
## Models:
## rf4: squarerf ~ fungicide + emerge + (1 | colony)
## rf3: squarerf ~ fungicide + crithidia + emerge + (1 | colony)
##     npar     AIC     BIC logLik deviance  Chisq Df Pr(>Chisq)  
## rf4    5 -3922.0 -3903.9 1966.0  -3932.0                       
## rf3    6 -3924.2 -3902.5 1968.1  -3936.2 4.2162  1    0.04004 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(rf3, rf4)
##     df       AIC
## rf3  6 -3845.295
## rf4  5 -3861.588
qqnorm(resid(rf3));qqline(resid(rf3))

qqnorm(resid(rf4));qqline(resid(rf4))

rf_em <- emmeans(rf3, pairwise ~ crithidia*fungicide, type = "response")
rf_em
## $emmeans
##  crithidia fungicide  emmean       SE   df lower.CL upper.CL
##  0         0         0.00103 3.55e-05 17.8 0.000955   0.0011
##  1         0         0.00112 4.07e-05 19.3 0.001035   0.0012
##  0         1         0.00102 3.84e-05 22.1 0.000944   0.0011
##  1         1         0.00111 4.33e-05 22.1 0.001024   0.0012
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                                       estimate       SE   df t.ratio
##  crithidia0 fungicide0 - crithidia1 fungicide0 -9.03e-05 4.56e-05 19.8  -1.979
##  crithidia0 fungicide0 - crithidia0 fungicide1  5.54e-06 4.56e-05 20.9   0.122
##  crithidia0 fungicide0 - crithidia1 fungicide1 -8.48e-05 6.46e-05 20.1  -1.312
##  crithidia1 fungicide0 - crithidia0 fungicide1  9.59e-05 6.44e-05 20.6   1.488
##  crithidia1 fungicide0 - crithidia1 fungicide1  5.54e-06 4.56e-05 20.9   0.122
##  crithidia0 fungicide1 - crithidia1 fungicide1 -9.03e-05 4.56e-05 19.8  -1.979
##  p.value
##   0.2291
##   0.9993
##   0.5660
##   0.4621
##   0.9993
##   0.2291
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates
rf_e <- setDT(as.data.frame(rf_em$emmeans))
rf_ce <- setDT(as.data.frame(rf_em$contrasts))

rf_em
## $emmeans
##  crithidia fungicide  emmean       SE   df lower.CL upper.CL
##  0         0         0.00103 3.55e-05 17.8 0.000955   0.0011
##  1         0         0.00112 4.07e-05 19.3 0.001035   0.0012
##  0         1         0.00102 3.84e-05 22.1 0.000944   0.0011
##  1         1         0.00111 4.33e-05 22.1 0.001024   0.0012
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast                                       estimate       SE   df t.ratio
##  crithidia0 fungicide0 - crithidia1 fungicide0 -9.03e-05 4.56e-05 19.8  -1.979
##  crithidia0 fungicide0 - crithidia0 fungicide1  5.54e-06 4.56e-05 20.9   0.122
##  crithidia0 fungicide0 - crithidia1 fungicide1 -8.48e-05 6.46e-05 20.1  -1.312
##  crithidia1 fungicide0 - crithidia0 fungicide1  9.59e-05 6.44e-05 20.6   1.488
##  crithidia1 fungicide0 - crithidia1 fungicide1  5.54e-06 4.56e-05 20.9   0.122
##  crithidia0 fungicide1 - crithidia1 fungicide1 -9.03e-05 4.56e-05 19.8  -1.979
##  p.value
##   0.2291
##   0.9993
##   0.5660
##   0.4621
##   0.9993
##   0.2291
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates
rf_e
##    crithidia fungicide      emmean           SE       df     lower.CL
## 1:         0         0 0.001029495 3.550520e-05 17.79935 0.0009548407
## 2:         1         0 0.001119806 4.067936e-05 19.26722 0.0010347432
## 3:         0         1 0.001023954 3.837426e-05 22.04877 0.0009443804
## 4:         1         1 0.001114265 4.334502e-05 22.07399 0.0010243905
##       upper.CL
## 1: 0.001104149
## 2: 0.001204869
## 3: 0.001103527
## 4: 0.001204140
rf_ce
##                                         contrast      estimate           SE
## 1: crithidia0 fungicide0 - crithidia1 fungicide0 -9.031152e-05 4.563038e-05
## 2: crithidia0 fungicide0 - crithidia0 fungicide1  5.541136e-06 4.558328e-05
## 3: crithidia0 fungicide0 - crithidia1 fungicide1 -8.477039e-05 6.459089e-05
## 4: crithidia1 fungicide0 - crithidia0 fungicide1  9.585266e-05 6.440459e-05
## 5: crithidia1 fungicide0 - crithidia1 fungicide1  5.541136e-06 4.558328e-05
## 6: crithidia0 fungicide1 - crithidia1 fungicide1 -9.031152e-05 4.563038e-05
##          df    t.ratio   p.value
## 1: 19.82692 -1.9791972 0.2290557
## 2: 20.88428  0.1215607 0.9993362
## 3: 20.10602 -1.3124202 0.5659652
## 4: 20.58874  1.4882893 0.4621385
## 5: 20.88428  0.1215607 0.9993362
## 6: 19.82692 -1.9791972 0.2290557
rf_e$treatment <- c(1, 4, 2, 3)
rf_e$treatment <- as.factor(rf_e$treatment)


rf_sum <- drones_rf %>%
  group_by(treatment) %>%
  summarise(m = mean(relative_fat_original),
            sd = sd(relative_fat_original),
            n = length(relative_fat_original)) %>%
  mutate(se = sd/sqrt(n))

rf_sum
## # A tibble: 4 × 5
##   treatment          m          sd     n           se
##   <fct>          <dbl>       <dbl> <int>        <dbl>
## 1 1         0.00000115 0.000000438    99 0.0000000440
## 2 2         0.00000111 0.000000408    68 0.0000000495
## 3 3         0.00000129 0.000000508    49 0.0000000726
## 4 4         0.00000128 0.000000435    60 0.0000000561
rf_sum$plot <- rf_sum$m + rf_sum$se
ggplot(rf_e, aes(x = treatment, y = emmean, fill = treatment)) +
  geom_bar(stat = "identity", color = "black") +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0, 0.4),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  scale_fill_viridis_d() +
  geom_errorbar(aes(ymin = emmean - SE, ymax = emmean + SE), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Square Root (Relative Fat (g/mm))") +
  theme_classic(base_size = 20) +
  coord_cartesian(ylim=c(0.0009, 0.00121)) +
  annotate(geom = "text", 
           x = 1, y = 0.00119,
           label = "P = 0.05",
           size = 8) +
  theme(legend.position = "none",
        axis.text = element_text(size = 16),  # Set axis label font size
        axis.title = element_text(size = 16)) +  # Set axis title font size
  theme(text = element_text(size = 16)) +
 scale_x_discrete(labels = custom_labels) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) + 
  geom_segment(x = 1, xend = 2, y = 0.0011, yend = 0.0011, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 0.00109, yend = 0.00111, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 0.00109, yend = 0.00111, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 4, y = 0.0012, yend = 0.0012, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 0.00119, yend = 0.00121, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 0.00119, yend = 0.00121, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 1.5, y = 0.00111, label = "a", size = 6, vjust = -0.5) +
  geom_text(x = 3.5, y = 0.001201, label = "b", size = 6, vjust = -0.5) +
  theme(legend.position = "none")

Emerge days

drones$fungicide <- as.logical(drones$fungicide)
drones$crithidia <- as.logical(drones$crithidia)

em.mod <- glm(emerge ~ fungicide + crithidia + dry_weight + live_weight + workers_alive + mean.pollen, data = drones.na, family = "poisson")
summary(em.mod)
## 
## Call:
## glm(formula = emerge ~ fungicide + crithidia + dry_weight + live_weight + 
##     workers_alive + mean.pollen, family = "poisson", data = drones.na)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -0.98926  -0.33225   0.00052   0.28013   1.76734  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    3.739837   0.083374  44.856   <2e-16 ***
## fungicide1     0.033579   0.020613   1.629    0.103    
## crithidia1    -0.003914   0.020394  -0.192    0.848    
## dry_weight    -1.691845   1.430164  -1.183    0.237    
## live_weight    0.015777   0.023522   0.671    0.502    
## workers_alive -0.008052   0.014627  -0.551    0.582    
## mean.pollen   -0.073468   0.063707  -1.153    0.249    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 58.303  on 275  degrees of freedom
## Residual deviance: 48.891  on 269  degrees of freedom
## AIC: 1570.1
## 
## Number of Fisher Scoring iterations: 3
em.mod <- glm.nb(emerge ~ fungicide + crithidia + dry_weight + live_weight + workers_alive + mean.pollen, data = drones.na)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
summary(em.mod)
## 
## Call:
## glm.nb(formula = emerge ~ fungicide + crithidia + dry_weight + 
##     live_weight + workers_alive + mean.pollen, data = drones.na, 
##     init.theta = 3809154.841, link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -0.98925  -0.33225   0.00052   0.28013   1.76733  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    3.739837   0.083375  44.856   <2e-16 ***
## fungicide1     0.033579   0.020613   1.629    0.103    
## crithidia1    -0.003914   0.020394  -0.192    0.848    
## dry_weight    -1.691845   1.430174  -1.183    0.237    
## live_weight    0.015777   0.023523   0.671    0.502    
## workers_alive -0.008052   0.014627  -0.551    0.582    
## mean.pollen   -0.073468   0.063708  -1.153    0.249    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(3809155) family taken to be 1)
## 
##     Null deviance: 58.303  on 275  degrees of freedom
## Residual deviance: 48.890  on 269  degrees of freedom
## AIC: 1572.1
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  3809155 
##           Std. Err.:  44034635 
## Warning while fitting theta: iteration limit reached 
## 
##  2 x log-likelihood:  -1556.135
drop1(em.mod, test = "Chisq")
## Single term deletions
## 
## Model:
## emerge ~ fungicide + crithidia + dry_weight + live_weight + workers_alive + 
##     mean.pollen
##               Df Deviance    AIC     LRT Pr(>Chi)
## <none>             48.890 1570.1                 
## fungicide      1   51.540 1570.8 2.64962   0.1036
## crithidia      1   48.927 1568.2 0.03685   0.8478
## dry_weight     1   50.288 1569.5 1.39821   0.2370
## live_weight    1   49.341 1568.6 0.45110   0.5018
## workers_alive  1   49.193 1568.4 0.30289   0.5821
## mean.pollen    1   50.217 1569.5 1.32744   0.2493
em1 <- update(em.mod, .~. -workers_alive)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(em1, test = "Chisq")
## Single term deletions
## 
## Model:
## emerge ~ fungicide + crithidia + dry_weight + live_weight + mean.pollen
##             Df Deviance    AIC    LRT Pr(>Chi)  
## <none>           49.193 1568.4                  
## fungicide    1   52.544 1569.8 3.3507  0.06718 .
## crithidia    1   49.214 1566.5 0.0209  0.88504  
## dry_weight   1   50.643 1567.9 1.4496  0.22859  
## live_weight  1   49.705 1567.0 0.5125  0.47407  
## mean.pollen  1   51.782 1569.0 2.5893  0.10759  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em2 <- update(em1, .~. -live_weight)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(em2, test = "Chisq")
## Single term deletions
## 
## Model:
## emerge ~ fungicide + crithidia + dry_weight + mean.pollen
##             Df Deviance    AIC    LRT Pr(>Chi)  
## <none>           49.705 1567.0                  
## fungicide    1   53.137 1568.4 3.4317  0.06396 .
## crithidia    1   49.720 1565.0 0.0147  0.90334  
## dry_weight   1   51.140 1566.4 1.4348  0.23098  
## mean.pollen  1   52.707 1568.0 3.0014  0.08319 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em3 <- update(em2, .~. -dry_weight)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
drop1(em3, test = "Chisq")
## Single term deletions
## 
## Model:
## emerge ~ fungicide + crithidia + mean.pollen
##             Df Deviance    AIC    LRT Pr(>Chi)  
## <none>           51.140 1566.4                  
## fungicide    1   54.822 1568.1 3.6820  0.05500 .
## crithidia    1   51.192 1564.4 0.0521  0.81952  
## mean.pollen  1   54.631 1567.9 3.4905  0.06172 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em4 <- update(em3, .~. -mean.pollen)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached

## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in glm.nb(formula = emerge ~ fungicide + crithidia, data = drones.na, :
## alternation limit reached
Anova(em4)
## Analysis of Deviance Table (Type II tests)
## 
## Response: emerge
##           LR Chisq Df Pr(>Chisq)  
## fungicide   3.6718  1    0.05534 .
## crithidia   0.0054  1    0.94153  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(em4)
## 
## Call:
## glm.nb(formula = emerge ~ fungicide + crithidia, data = drones.na, 
##     init.theta = 3366696.841, link = log)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -0.86749  -0.30028  -0.02929   0.28290   1.97226  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  3.605679   0.015123 238.421   <2e-16 ***
## fungicide1   0.038133   0.019883   1.918   0.0551 .  
## crithidia1  -0.001478   0.020155  -0.073   0.9415    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(3366782) family taken to be 1)
## 
##     Null deviance: 58.302  on 275  degrees of freedom
## Residual deviance: 54.631  on 273  degrees of freedom
## AIC: 1569.9
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  3366697 
##           Std. Err.:  37068676 
## Warning while fitting theta: alternation limit reached 
## 
##  2 x log-likelihood:  -1561.876
emem <- emmeans(em4, pairwise ~ fungicide, type = "response")
emem
## $emmeans
##  fungicide response    SE  df asymp.LCL asymp.UCL
##  0             36.8 0.489 Inf      35.8      37.8
##  1             38.2 0.575 Inf      37.1      39.4
## 
## Results are averaged over the levels of: crithidia 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale 
## 
## $contrasts
##  contrast                ratio     SE  df null z.ratio p.value
##  fungicide0 / fungicide1 0.963 0.0191 Inf    1  -1.918  0.0551
## 
## Results are averaged over the levels of: crithidia 
## Tests are performed on the log scale
emcld <-  cld(object = emem,
                 adjust = "Tukey",
                 Letters = letters,
                 alpha = 0.05)
emcld
##  fungicide response    SE  df asymp.LCL asymp.UCL .group
##  0             36.8 0.489 Inf      35.7      37.9  a    
##  1             38.2 0.575 Inf      36.9      39.5  a    
## 
## Results are averaged over the levels of: crithidia 
## Confidence level used: 0.95 
## Conf-level adjustment: sidak method for 2 estimates 
## Intervals are back-transformed from the log scale 
## Tests are performed on the log scale 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.
pairs(emem)
##  contrast                ratio     SE  df null z.ratio p.value
##  fungicide0 / fungicide1 0.963 0.0191 Inf    1  -1.918  0.0551
## 
## Results are averaged over the levels of: crithidia 
## Tests are performed on the log scale
em_sum <- drones %>%
  group_by(treatment) %>%
  summarise(m = mean(emerge),
            sd = sd(emerge),
            n = length(emerge)) %>%
  mutate(se = sd/sqrt(n))

em_sum
## # A tibble: 4 × 5
##   treatment     m    sd     n    se
##   <fct>     <dbl> <dbl> <int> <dbl>
## 1 1          37.0  2.41   102 0.238
## 2 2          38.1  2.54    69 0.306
## 3 3          38.4  4.08    49 0.583
## 4 4          36.5  2.23    61 0.286
em_sum$plot <- em_sum$m + em_sum$se
ggplot(em_sum, aes(x = treatment, y = m, fill = treatment)) +
  geom_bar(stat = "identity", color = "black") +
  geom_col_pattern(
    aes(pattern = treatment),
    pattern_density = c(0, 0, 0.4, 0),  # Add density for the fourth column
    pattern_spacing = 0.03,
    position = position_dodge(0.9)
  ) +
  scale_fill_viridis_d() +
  geom_errorbar(aes(ymin = m - se, ymax = m + se), width = 0.2, position = position_dodge(0.9)) +
  labs(x = "Treatment", y = "Days") +
  theme_classic(base_size = 20) +
  coord_cartesian(ylim=c(35, 41)) +
  annotate(geom = "text", 
           x = 1, y = 39,
           label = "P = 0.05",
           size = 8) +
  theme(legend.position = "none",
        axis.text = element_text(size = 20),  # Set axis label font size
        axis.title = element_text(size = 20)) +  # Set axis title font size
  theme(text = element_text(size = 20)) +
  scale_fill_manual(values = c("lightgreen", "lightblue", "lightblue", "grey")) +
  scale_pattern_manual(values = c("none", "none", "stripe", "none")) +  # Add stripes to the fourth column
  scale_x_discrete(labels = custom_labels) +
  theme(legend.position = "none") +
  geom_segment(x = 2, xend = 3, y = 39.6, yend = 39.6, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 2, xend = 2, y = 39.4, yend = 39.8, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 3, xend = 3, y = 39.4, yend = 39.8, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 4, y = 40.1, yend = 40.1, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 1, xend = 1, y = 39.9, yend = 40.3, 
               lineend = "round", linejoin = "round") +
  geom_segment(x = 4, xend = 4, y = 39.9, yend = 40.3, 
               lineend = "round", linejoin = "round") +
  geom_text(x = 2.5, y = 39.65, label = "b", size = 6, vjust = -0.5) +
  geom_text(x = 2.5, y = 40.15, label = "a", size = 6, vjust = -0.5)

LS0tDQp0aXRsZTogIkNoYXB0ZXIgMiBNaWNyb2NvbG9ueSBIZWFsdGggQW5hbHlzaXMiDQphdXRob3I6ICJFbWlseSBSdW5uaW9uIg0KZGF0ZTogIkRhdGEgQ29sbGVjdGVkIDIwMjIiDQpvdXRwdXQ6DQogIGh0bWxfZG9jdW1lbnQ6DQogICAgdG9jOiB0cnVlDQogICAgdG9jX2RlcHRoOiA0DQogICAgbnVtYmVyX3NlY3Rpb25zOiBmYWxzZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KICAgIHRoZW1lOiBqb3VybmFsDQogICAgY29kZV9kb3dubG9hZDogdHJ1ZQ0KLS0tDQoNCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQ0Ka25pdHI6Om9wdHNfY2h1bmskc2V0KG1lc3NhZ2UgPSBGQUxTRSkNCmBgYA0KDQoNCmBgYHtyIGxvYWQgbGlicmFyaWVzLCBpbmNsdWRlPUZBTFNFfQ0KbGlicmFyeShyZWFkcikNCmxpYnJhcnkodmlyaWRpc0xpdGUpDQpsaWJyYXJ5KHN0YXRzKQ0KbGlicmFyeShnZ3Bsb3QyKQ0KbGlicmFyeShjYXIpDQpsaWJyYXJ5KGVtbWVhbnMpDQpsaWJyYXJ5KE1BU1MpDQ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1tYXJpc2UoYXZnLnBvbCA9IG1lYW4od2hvbGVfZGlmKSkNCg0KZHVyYXRpb24gPC0gbWVyZ2UoZHVyYXRpb24sIGF2Zy5wb2wsIGJ5ID0gImNvbG9ueSIsIGFsbCA9IEZBTFNFKQ0KDQpuZXdfZGF0YWZyYW1lIDwtIGR1cmF0aW9uW2MoJ2NvbG9ueScsICdkYXlzX2FjdGl2ZScpXQ0KYnJvb2QgPC0gbWVyZ2UocXJvX3NpbXBsZSwgYnJvb2QsIGJ5ID0gImNvbG9ueSIsIGFsbCA9IEZBTFNFKQ0Kd29ya2VycyA8LSBtZXJnZShuZXdfZGF0YWZyYW1lLCB3b3JrZXJzLCBieSA9ICJjb2xvbnkiLCBhbGwgPSBGQUxTRSkNCg0KYWxsX2JlZXMgPC0gcmVhZF9jc3YoInFwY3JfYWxsX2JlZXNfOC4xLjI0LmNzdiIsIGNvbF90eXBlcyA9IGNvbHModHJlYXRtZW50ID0gY29sX2ZhY3RvcihsZXZlbHMgPSBjKCIxIiwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIjIiLCAiMyIsICI0IikpLCByZXBsaWNhdGUgPSBjb2xfZmFjdG9yKGxldmVscyA9IGMoIjEiLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiNCIsICI2IiwgIjciLCAiOCIsICI5IiwgIjEwIiwgIjExIiwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIjEyIikpLCBzdGFydCA9IGNvbF9kYXRlKGZvcm1hdCA9ICIlbS8lZC8lWSIpLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElubm9jdWxhdGlvbl9kYXRlID0gY29sX2RhdGUoZm9ybWF0ID0gIiVtLyVkLyVZIiksIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0ZSA9IGNvbF9kYXRlKGZvcm1hdCA9ICIlbS8lZC8lWSIpLCBjZW5zb3Jfc3RhdHVzID0gY29sX2ZhY3RvcihsZXZlbHMgPSBjKCIxIiwiMiIpKSkpDQoNCmFsbF9iZWVzJGNvbG9ueSA8LSBhcy5mYWN0b3IoYWxsX2JlZXMkY29sb255KQ0KYWxsX2JlZXMkYmVlX2lkIDwtIGFzLmZhY3RvcihhbGxfYmVlcyRiZWVfaWQpDQoNCg0Kd29ya2Vyc19mb3JfcXBjcl9tZXJnZSA8LSByZWFkX2Nzdigid29ya2Vyc19mb3IgcXBjciBtZXJnZS5jc3YiLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGVzID0gY29scyhmdW5naWNpZGUgPSBjb2xfbG9naWNhbCgpLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcml0aGlkaWEgPSBjb2xfbG9naWNhbCgpLCBpbm9jdWxhdGVfcm91bmQgPSBjb2xfZmFjdG9yKGxldmVscyA9IGMoIjEiLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIjIiLCAiMyIpKSwgaW5vY3VsYXRlID0gY29sX2xvZ2ljYWwoKSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJlb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oYmFzZV9zaXplID0gMjApICsNCiAgc2NhbGVfZmlsbF9tYW51YWwodmFsdWVzID0gYygibGlnaHRncmVlbiIsICJsaWdodGJsdWUiLCAibGlnaHRibHVlIiwgImdyZXkiKSkgKw0KICBzY2FsZV9wYXR0ZXJuX21hbnVhbCh2YWx1ZXMgPSBjKCJub25lIiwgIm5vbmUiLCAic3RyaXBlIiwgIm5vbmUiKSkgKyAgIyBBZGQgc3RyaXBlcyB0byB0aGUgZm91cnRoIGNvbHVtbg0KICBzY2FsZV94X2Rpc2NyZXRlKGxhYmVscyA9IGN1c3RvbV9sYWJlbHMpICsNCiAgdGhlbWUobGVnZW5kLnBvc2l0aW9uID0gIm5vbmUiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMSwgeGVuZCA9IDIsIHkgPSAwLjY1LCB5ZW5kID0gMC42NSwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMSwgeGVuZCA9IDEsIHkgPSAwLjY0LCB5ZW5kID0gMC42NiwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMiwgeGVuZCA9IDIsIHkgPSAwLjY0LCB5ZW5kID0gMC42NiwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMywgeGVuZCA9IDQsIHkgPSAwLjQ3LCB5ZW5kID0gMC40NywgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMywgeGVuZCA9IDMsIHkgPSAwLjQ2LCB5ZW5kID0gMC40OCwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWp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B5ZW5kID0gMC41NCwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMSwgeGVuZCA9IDEsIHkgPSAwLjU0LCB5ZW5kID0gMC41MywgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMiwgeGVuZCA9IDIsIHkgPSAwLjU0LCB5ZW5kID0gMC41MywgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMywgeGVuZCA9IDQsIHkgPSAwLjQyLCB5ZW5kID0gMC40MiwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMywgeGVuZCA9IDMsIHkgPSAwLjQyLCB5ZW5kID0gMC40MSwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gNCwgeGVuZCA9IDQsIHkgPSAwLjQyLCB5ZW5kID0gMC40MSwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fdGV4dCh4ID0gMS41LCB5ID0gMC41NSwgbGFiZWwgPSAiYSIsIHNpemUgPSA2LCB2anVzdCA9IC0wLjUpICsNCiAgZ2VvbV90ZXh0KHggPSAzLjUsIHkgPSAwLjQzLCBsYWJlbCA9ICJiIiwgc2l6ZSA9IDYsIHZqdXN0ID0gLTAuNSkNCmBgYA0KDQpgYGB7cn0NCmdncGxvdChkYXRhID0gcG9sbGVuX3N1bSwgYWVzKHggPSB0cmVhdG1lbnQsIHkgPSBtZ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kiKSkgKw0KICBzY2FsZV9wYXR0ZXJuX21hbnVhbCh2YWx1ZXMgPSBjKCJub25lIiwgIm5vbmUiLCAic3RyaXBlIiwgIm5vbmUiKSkgKyAgIyBBZGQgc3RyaXBlcyB0byB0aGUgZm91cnRoIGNvbHVtbg0KICBzY2FsZV94X2Rpc2NyZXRlKGxhYmVscyA9IGN1c3RvbV9sYWJlbHMpICsNCiAgdGhlbWUobGVnZW5kLnBvc2l0aW9uID0gIm5vbmUiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMiwgeGVuZCA9IDMsIHkgPSAzOS42LCB5ZW5kID0gMzkuNiwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMiwgeGVuZCA9IDIsIHkgPSAzOS40LCB5ZW5kID0gMzkuOCwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMywgeGVuZCA9IDMsIHkgPSAzOS40LCB5ZW5kID0gMzkuOCwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMSwgeGVuZCA9IDQsIHkgPSA0MC4xLCB5ZW5kID0gNDAuMSwgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gMSwgeGVuZCA9IDEsIHkgPSAzOS45LCB5ZW5kID0gNDAuMywgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fc2VnbWVudCh4ID0gNCwgeGVuZCA9IDQsIHkgPSAzOS45LCB5ZW5kID0gNDAuMywgDQogICAgICAgICAgICAgICBsaW5lZW5kID0gInJvdW5kIiwgbGluZWpvaW4gPSAicm91bmQiKSArDQogIGdlb21fdGV4dCh4ID0gMi41LCB5ID0gMzkuNjUsIGxhYmVsID0gImIiLCBzaXplID0gNiwgdmp1c3QgPSAtMC41KSArDQogIGdlb21fdGV4dCh4ID0gMi41LCB5ID0gNDAuMTUsIGxhYmVsID0gImEiLCBzaXplID0gNiwgdmp1c3QgPSAtMC41KQ0KDQpgYGANCg==