#### Data for qpCR Disease Dynamics
all_bees <- read_csv("qpcr_3.4_bees_all2.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")))
## 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)
a_df <- read_csv("individual bees 3.4 average.csv",
col_types = cols(date_first_adl = col_date(format = "%m/%d/%Y"),
round = col_factor(levels = c("1",
"2", "3"))))
a_df$bee_id <- as.factor(a_df$bee_id)
a_df$colony <- as.factor(a_df$colony)
a_df$treatment <- as.factor(a_df$treatment)
a_df$replicate <- as.factor(a_df$replicate)
a_df_na <- na.omit(a_df)
qpcr <- read_csv("qpcr_3.4_bees_all.csv",
col_types = cols(inoculate_round = col_factor(levels = c("1",
"2", "3")), inoculate_01 = col_logical(),
`end date` = col_date(format = "%m/%d/%Y"),
treatment = col_factor(levels = c("3",
"4")), replicate = col_factor(levels = c("1",
"4", "5", "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"),
alive_or_dead = col_logical()))
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
qpcr$fungicide <- as.logical(qpcr$fungicide)
qpcr$crithidia <- as.logical(qpcr$crithidia)
qpcr$qro <- as.factor(qpcr$qro)
qpcr$colony <- as.factor(qpcr$colony)
qpcr$premature_death <- as.factor(qpcr$premature_death)
qpcr$dry <- as.double(qpcr$dry)
qpcr$bee_id <- as.factor(qpcr$bee_id)
qpcr$spore_include <- as.numeric(qpcr$spore_include)
qpcr$col_days <- as.factor(qpcr$col_days)
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)
cbdf <- read_csv("cbdf.csv")
cbdf$colony <- as.factor(cbdf$colony)
cbdf$day <- as.factor(cbdf$day)
cbdf$fungicide <- as.factor(cbdf$fungicide)
cbdf$round <- as.factor(cbdf$round)
cbdf$block <- as.factor(cbdf$block)
qpcr_all <- read_csv("qpcr_3.4_bees_all_with5.csv")
qpcr_all.na <- na.omit(qpcr_all)
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)
custom_labels <- c("Control", "Fungicide", "Fungicide + Crithidia", "Crithidia")
#Over whole experiment
library(survival)
library(coxme)
library(survminer)
workers.na <- na.omit(workers)
workers.na$inoculate_round <- as.factor(workers.na$inoculate_round)
cox <- coxme(Surv(days_alive_since_inoc, inoc_censor) ~ crithidia + fungicide + inoculate_round + (1|colony), data = workers.na)
Anova(cox)
## Analysis of Deviance Table (Type II tests)
##
## Response: Surv(days_alive_since_inoc, inoc_censor)
## Df Chisq Pr(>Chisq)
## crithidia 1 4.9774 0.02568 *
## fungicide 1 0.6369 0.42485
## inoculate_round 2 6.7869 0.03359 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(cox)
## Mixed effects coxme model
## Formula: Surv(days_alive_since_inoc, inoc_censor) ~ crithidia + fungicide + inoculate_round + (1 | colony)
## Data: workers.na
##
## events, n = 53, 175
##
## Random effects:
## group variable sd variance
## 1 colony Intercept 0.8195113 0.6715988
## Chisq df p AIC BIC
## Integrated loglik 34.82 5.00 1.634e-06 24.82 14.97
## Penalized loglik 70.29 16.94 1.844e-08 36.40 3.01
##
## Fixed effects:
## coef exp(coef) se(coef) z p
## crithidia 0.9592 2.6097 0.4300 2.23 0.02568
## fungicide 0.3348 1.3977 0.4195 0.80 0.42485
## inoculate_round2 0.4119 1.5097 0.4837 0.85 0.39447
## inoculate_round3 1.4923 4.4474 0.5731 2.60 0.00921
emmeans(cox, pairwise ~ crithidia*fungicide)
## $emmeans
## crithidia fungicide emmean SE df asymp.LCL asymp.UCL
## 0 0 -0.3024 0.337 Inf -0.962 0.358
## 1 0 0.6569 0.317 Inf 0.036 1.278
## 0 1 0.0324 0.331 Inf -0.616 0.681
## 1 1 0.9917 0.331 Inf 0.342 1.641
##
## Results are averaged over the levels of: inoculate_round
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio
## crithidia0 fungicide0 - crithidia1 fungicide0 -0.959 0.430 Inf -2.231
## crithidia0 fungicide0 - crithidia0 fungicide1 -0.335 0.420 Inf -0.798
## crithidia0 fungicide0 - crithidia1 fungicide1 -1.294 0.612 Inf -2.116
## crithidia1 fungicide0 - crithidia0 fungicide1 0.624 0.590 Inf 1.059
## crithidia1 fungicide0 - crithidia1 fungicide1 -0.335 0.420 Inf -0.798
## crithidia0 fungicide1 - crithidia1 fungicide1 -0.959 0.430 Inf -2.231
## p.value
## 0.1149
## 0.8554
## 0.1479
## 0.7146
## 0.8554
## 0.1149
##
## Results are averaged over the levels of: inoculate_round
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 4 estimates
cox
## Cox mixed-effects model fit by maximum likelihood
## Data: workers.na
## events, n = 53, 175
## Iterations= 22 136
## NULL Integrated Fitted
## Log-likelihood -243.3123 -225.902 -208.1677
##
## Chisq df p AIC BIC
## Integrated loglik 34.82 5.00 1.6338e-06 24.82 14.97
## Penalized loglik 70.29 16.94 1.8439e-08 36.40 3.01
##
## Model: Surv(days_alive_since_inoc, inoc_censor) ~ crithidia + fungicide + inoculate_round + (1 | colony)
## Fixed coefficients
## coef exp(coef) se(coef) z p
## crithidia 0.9592279 2.609681 0.4299523 2.23 0.0260
## fungicide 0.3348056 1.397669 0.4195367 0.80 0.4200
## inoculate_round2 0.4118825 1.509657 0.4836896 0.85 0.3900
## inoculate_round3 1.4923181 4.447393 0.5730694 2.60 0.0092
##
## Random effects
## Group Variable Std Dev Variance
## colony Intercept 0.8195113 0.6715988
cox.t <- coxme(Surv(days_alive_since_inoc, inoc_censor) ~ treatment + inoculate_round + (1|colony), data = workers.na)
cox.emm <- emmeans(cox.t, pairwise ~ treatment)
cox.emm
## $emmeans
## treatment emmean SE df asymp.LCL asymp.UCL
## 1 -0.715 0.468 Inf -1.6319 0.201
## 2 0.344 0.386 Inf -0.4125 1.101
## 3 0.796 0.361 Inf 0.0884 1.504
## 4 0.918 0.355 Inf 0.2219 1.613
##
## Results are averaged over the levels of: inoculate_round
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## treatment1 - treatment2 -1.060 0.683 Inf -1.551 0.4069
## treatment1 - treatment3 -1.512 0.657 Inf -2.300 0.0980
## treatment1 - treatment4 -1.633 0.664 Inf -2.459 0.0665
## treatment2 - treatment3 -0.452 0.552 Inf -0.819 0.8457
## treatment2 - treatment4 -0.573 0.553 Inf -1.036 0.7283
## treatment3 - treatment4 -0.121 0.522 Inf -0.232 0.9956
##
## Results are averaged over the levels of: inoculate_round
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 4 estimates
ggsurvplot(
survfit(Surv(days_alive_since_inoc, inoc_censor) ~ treatment, data = workers.na),
legend.title = "",
censor.shape = 124,
censor.size = 2.5,
ylim = c(0.25, 1),
palette = c("darkgreen", "lightblue", "darkblue", "orange")
)
ggsurvplot(
survfit(Surv(days_alive_since_inoc, inoc_censor) ~ treatment, data = workers.na),
legend.title = "",
censor.shape = 124,
censor.size = 2.5,
ylim = c(0.25, 1),
palette = c("darkgreen", "lightblue", "darkblue", "orange"),
legend.labs = c("Control", "+Fungicide -Parasite", "+Fungicide +Parasite", "-Fungicide +Parasite")
)
ggsurvplot(
survfit(Surv(days_alive_since_inoc, inoc_censor) ~ inoculate, data = workers.na),
legend.title = "",
censor.shape = 124,
censor.size = 2.5,
ylim = c(0, 1),
palette = c("darkgreen", "orange")
)
#Over 14 day frass monitoring period
cox <- coxme(Surv(day14_survival, day14_censor) ~ crithidia + fungicide + inoculate_round + (1|colony), data = workers.na)
Anova(cox)
## Analysis of Deviance Table (Type II tests)
##
## Response: Surv(day14_survival, day14_censor)
## Df Chisq Pr(>Chisq)
## crithidia 1 1.2622 0.261244
## fungicide 1 2.5715 0.108803
## inoculate_round 2 9.7960 0.007462 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emm.cox <- emmeans(cox, pairwise ~ crithidia, type = "response")
pairs(emm.cox)
## contrast ratio SE df null z.ratio p.value
## crithidia0 / crithidia1 0.538 0.297 Inf 1 -1.123 0.2612
##
## Results are averaged over the levels of: fungicide, inoculate_round
## Tests are performed on the log scale
ggsurvplot(
survfit(Surv(day14_survival, day14_censor) ~ treatment, data = workers.na),
legend.title = "",
censor.shape = 124,
censor.size = 2.5,
ylim = c(0.8, 1),
palette = c("darkgreen", "lightblue", "darkblue", "orange")
)
brood <- read_csv("brood.csv")
brood <- read_csv("brood.csv")
brood$colony <- as.factor(brood$colony)
brood$treatment <- as.factor(brood$treatment)
brood$block <- as.factor(brood$block)
brood$fungicide <- as.logical(brood$fungicide)
brood$crithidia <- as.logical(brood$crithidia)
brood$workers_dead <- 5 - brood$workers_alive
work_prob <- glm(cbind(workers_alive, workers_dead) ~ treatment, data = brood, family = binomial("logit"))
wpe <- emmeans(work_prob, pairwise ~ treatment, type = "response")
wpe
## $emmeans
## treatment prob SE df asymp.LCL asymp.UCL
## 1 0.844 0.0540 Inf 0.708 0.924
## 2 0.756 0.0641 Inf 0.610 0.859
## 3 0.556 0.0741 Inf 0.410 0.692
## 4 0.578 0.0736 Inf 0.431 0.712
##
## Confidence level used: 0.95
## Intervals are back-transformed from the logit scale
##
## $contrasts
## contrast odds.ratio SE df null z.ratio p.value
## treatment1 / treatment2 1.756 0.945 Inf 1 1.047 0.7218
## treatment1 / treatment3 4.343 2.211 Inf 1 2.885 0.0205
## treatment1 / treatment4 3.967 2.024 Inf 1 2.701 0.0349
## treatment2 / treatment3 2.473 1.134 Inf 1 1.974 0.1978
## treatment2 / treatment4 2.259 1.039 Inf 1 1.772 0.2868
## treatment3 / treatment4 0.913 0.389 Inf 1 -0.213 0.9966
##
## P value adjustment: tukey method for comparing a family of 4 estimates
## Tests are performed on the log odds ratio scale
work_prob.mod <- glm(cbind(workers_alive, workers_dead) ~ fungicide + crithidia + block, data = brood, family = binomial("logit"))
Anova(work_prob.mod)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(workers_alive, workers_dead)
## LR Chisq Df Pr(>Chisq)
## fungicide 0.838 1 0.3599347
## crithidia 13.833 1 0.0001998 ***
## block 36.694 8 1.31e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qpcr_all.na$adl_neg <- 1 - qpcr_all.na$adl
qpcr_all.na$round <- as.factor(qpcr_all.na$round)
qpcr_all.na$replicate <- as.factor(qpcr_all.na$replicate)
cbw2 <- glm(cbind(adl, adl_neg) ~ fungicide + round + inoculate + replicate, data = qpcr_all.na, family = binomial("logit"))
drop1(cbw2, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(adl, adl_neg) ~ fungicide + round + inoculate + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 1164.6 1192.6
## fungicide 1 1172.3 1198.3 7.656 0.0056575 **
## round 2 1178.6 1202.6 13.936 0.0009416 ***
## inoculate 1 1267.3 1293.3 102.632 < 2.2e-16 ***
## replicate 9 1224.1 1234.1 59.463 1.701e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(cbw2)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(adl, adl_neg)
## LR Chisq Df Pr(>Chisq)
## fungicide 7.656 1 0.0056575 **
## round 13.936 2 0.0009416 ***
## inoculate 102.632 1 < 2.2e-16 ***
## replicate 59.463 9 1.701e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(cbw2)
##
## Call:
## glm(formula = cbind(adl, adl_neg) ~ fungicide + round + inoculate +
## replicate, family = binomial("logit"), data = qpcr_all.na)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.1059 0.2165 -9.725 < 2e-16 ***
## fungicideTRUE 0.4824 0.1748 2.759 0.00579 **
## round2 -1.6874 0.5422 -3.112 0.00186 **
## round3 1.0634 0.4727 2.250 0.02446 *
## inoculateTRUE 1.6621 0.1670 9.954 < 2e-16 ***
## replicate4 -0.4410 0.3231 -1.365 0.17225
## replicate5 2.8644 0.6075 4.715 2.41e-06 ***
## replicate6 0.2876 0.3651 0.788 0.43097
## replicate7 0.3445 0.5533 0.623 0.53356
## replicate8 2.4619 0.6048 4.071 4.68e-05 ***
## replicate9 -0.4547 0.3296 -1.380 0.16771
## replicate10 0.8307 0.3464 2.398 0.01649 *
## replicate11 1.2705 0.6384 1.990 0.04660 *
## replicate12 0.7912 0.3562 2.221 0.02635 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1354.0 on 1181 degrees of freedom
## Residual deviance: 1164.6 on 1168 degrees of freedom
## AIC: 1192.6
##
## Number of Fisher Scoring iterations: 4
emm1 <- emmeans(cbw2, pairwise ~ fungicide, type = "response")
pairs(emm1)
## contrast odds.ratio SE df null z.ratio p.value
## FALSE / TRUE 0.617 0.108 Inf 1 -2.759 0.0058
##
## Results are averaged over the levels of: round, inoculate, replicate
## Tests are performed on the log odds ratio scale
emm1
## $emmeans
## fungicide prob SE df asymp.LCL asymp.UCL
## FALSE 0.335 0.0298 Inf 0.279 0.395
## TRUE 0.449 0.0405 Inf 0.371 0.529
##
## Results are averaged over the levels of: round, inoculate, replicate
## Confidence level used: 0.95
## Intervals are back-transformed from the logit scale
##
## $contrasts
## contrast odds.ratio SE df null z.ratio p.value
## FALSE / TRUE 0.617 0.108 Inf 1 -2.759 0.0058
##
## Results are averaged over the levels of: round, inoculate, replicate
## Tests are performed on the log odds ratio scale
em.df <- as.data.frame(emm1$emmeans)
em.df
## fungicide prob SE df asymp.LCL asymp.UCL
## FALSE 0.3346131 0.02977979 Inf 0.2789763 0.3952630
## TRUE 0.4489313 0.04053016 Inf 0.3714293 0.5289951
##
## Results are averaged over the levels of: round, inoculate, replicate
## Confidence level used: 0.95
## Intervals are back-transformed from the logit scale
emm2 <- emmeans(cbw2, pairwise ~ inoculate, type = "response")
pairs(emm2)
## contrast odds.ratio SE df null z.ratio p.value
## FALSE / TRUE 0.19 0.0317 Inf 1 -9.954 <.0001
##
## Results are averaged over the levels of: fungicide, round, replicate
## Tests are performed on the log odds ratio scale
emm2
## $emmeans
## inoculate prob SE df asymp.LCL asymp.UCL
## FALSE 0.218 0.0209 Inf 0.180 0.262
## TRUE 0.595 0.0405 Inf 0.514 0.671
##
## Results are averaged over the levels of: fungicide, round, replicate
## Confidence level used: 0.95
## Intervals are back-transformed from the logit scale
##
## $contrasts
## contrast odds.ratio SE df null z.ratio p.value
## FALSE / TRUE 0.19 0.0317 Inf 1 -9.954 <.0001
##
## Results are averaged over the levels of: fungicide, round, replicate
## Tests are performed on the log odds ratio scale
qpcr_all.na$inoculate_01 <- as.numeric(qpcr_all.na$inoculate_01)
cbdfsum <- qpcr_all.na %>%
group_by(treatment) %>%
summarise(wrkrs = length(bee_id))
cbdfsum1 <- qpcr_all.na %>%
group_by(inoculate_01) %>%
summarise(wrkrs = length(bee_id))
cbdfsum
## # A tibble: 2 × 2
## treatment wrkrs
## <dbl> <int>
## 1 3 590
## 2 4 592
cbdfsum1
## # A tibble: 2 × 2
## inoculate_01 wrkrs
## <dbl> <int>
## 1 0 938
## 2 1 244
ggplot(data = em.df, aes(x = fungicide, y = prob, fill = fungicide)) +
geom_col() +
geom_bar(stat = "identity", color = "black") +
geom_col_pattern(
aes(pattern = fungicide),
pattern_density = c(0, 0.4), # Add density for the fourth column
pattern_spacing = 0.03,
position = position_dodge(0.9)
) +
labs(x = "Fungicide", y = "Probability of Testing Above Detection Limit") +
theme_cowplot() +
scale_x_discrete(labels = c("FALSE", "TRUE")) + # Change x-axis labels
scale_fill_manual(values = c("0" = "lightblue", "1" = "lightblue")) +
scale_pattern_manual(values = c("none", "stripe")) + # Customize bar colors
theme(legend.position = "none") + # Remove the legend
annotate(
geom = "text",
x = 1,
y = 0.31,
label = "P < 0.01",
size = 7
) +
geom_errorbar(aes(ymin = prob - SE, ymax = prob + SE), width = 0.2, size = 0.8, position = position_dodge(1)) +
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 = 16))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: No shared levels found between `names(values)` of the manual scale and the
## data's fill values.
## No shared levels found between `names(values)` of the manual scale and the
## data's fill values.
## No shared levels found between `names(values)` of the manual scale and the
## data's fill values.
## No shared levels found between `names(values)` of the manual scale and the
## data's fill values.
## No shared levels found between `names(values)` of the manual scale and the
## data's fill values.
adl <- read.csv("adl.csv")
adl$colony <- as.factor(adl$colony)
adl$treatment <-as.factor(adl$treatment)
adl$round <- as.factor(adl$round)
adl$inoculate <- as.logical(adl$inoculate)
adl$block <- as.factor(adl$block)
adlmod <- glmer.nb(days_to_adl ~ treatment + round + inoculate + block + (1|colony), data = adl)
drop1(adlmod, test = "Chisq")
## Single term deletions
##
## Model:
## days_to_adl ~ treatment + round + inoculate + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 404.34
## treatment 1 403.34 0.9990 0.3175519
## round 2 415.07 14.7348 0.0006315 ***
## inoculate 1 410.09 7.7491 0.0053738 **
## block 9 406.33 19.9939 0.0179503 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(adlmod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: days_to_adl
## Chisq Df Pr(>Chisq)
## treatment 0.9976 1 0.317888
## round 12.4897 2 0.001940 **
## inoculate 7.3985 1 0.006528 **
## block 20.9696 9 0.012786 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adlemm <- emmeans(adlmod, pairwise ~ treatment, type = "response")
pairs(adlemm)
## contrast ratio SE df null z.ratio p.value
## treatment3 / treatment4 0.866 0.124 Inf 1 -0.999 0.3179
##
## Results are averaged over the levels of: round, inoculate, block
## Tests are performed on the log scale
adlemm
## $emmeans
## treatment response SE df asymp.LCL asymp.UCL
## 3 2.12 0.397 Inf 1.47 3.06
## 4 2.45 0.397 Inf 1.78 3.36
##
## Results are averaged over the levels of: round, inoculate, block
## Confidence level used: 0.95
## Intervals are back-transformed from the log scale
##
## $contrasts
## contrast ratio SE df null z.ratio p.value
## treatment3 / treatment4 0.866 0.124 Inf 1 -0.999 0.3179
##
## Results are averaged over the levels of: round, inoculate, block
## Tests are performed on the log scale
adlemm <- emmeans(adlmod, pairwise ~ round, type = "response")
pairs(adlemm)
## contrast ratio SE df null z.ratio p.value
## round1 / round2 1.85 0.745 Inf 1 1.530 0.2767
## round1 / round3 6.76 4.233 Inf 1 3.051 0.0065
## round2 / round3 3.65 2.816 Inf 1 1.678 0.2135
##
## Results are averaged over the levels of: treatment, inoculate, block
## P value adjustment: tukey method for comparing a family of 3 estimates
## Tests are performed on the log scale
adlemm
## $emmeans
## round response SE df asymp.LCL asymp.UCL
## 1 5.288 0.936 Inf 3.738 7.48
## 2 2.857 0.846 Inf 1.598 5.10
## 3 0.783 0.457 Inf 0.249 2.46
##
## Results are averaged over the levels of: treatment, inoculate, block
## Confidence level used: 0.95
## Intervals are back-transformed from the log scale
##
## $contrasts
## contrast ratio SE df null z.ratio p.value
## round1 / round2 1.85 0.745 Inf 1 1.530 0.2767
## round1 / round3 6.76 4.233 Inf 1 3.051 0.0065
## round2 / round3 3.65 2.816 Inf 1 1.678 0.2135
##
## Results are averaged over the levels of: treatment, inoculate, block
## P value adjustment: tukey method for comparing a family of 3 estimates
## Tests are performed on the log scale
adlemm <- emmeans(adlmod, pairwise ~ inoculate, type = "response")
pairs(adlemm)
## contrast ratio SE df null z.ratio p.value
## FALSE / TRUE 1.62 0.289 Inf 1 2.720 0.0065
##
## Results are averaged over the levels of: treatment, round, block
## Tests are performed on the log scale
adlemm
## $emmeans
## inoculate response SE df asymp.LCL asymp.UCL
## FALSE 2.90 0.449 Inf 2.14 3.93
## TRUE 1.79 0.370 Inf 1.19 2.68
##
## Results are averaged over the levels of: treatment, round, 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 / TRUE 1.62 0.289 Inf 1 2.720 0.0065
##
## Results are averaged over the levels of: treatment, round, block
## Tests are performed on the log scale
detadl <- glmer.nb(total.adl ~ treatment + inoculate + (1|colony), data = adl)
drop1(detadl, test = "Chisq")
## Single term deletions
##
## Model:
## total.adl ~ treatment + inoculate + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 437.45
## treatment 1 435.98 0.5224 0.4698
## inoculate 1 466.19 30.7356 2.957e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(detadl)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: total.adl
## Chisq Df Pr(>Chisq)
## treatment 0.5418 1 0.4617
## inoculate 27.9557 1 1.241e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adl.t.emm <- emmeans(detadl, pairwise ~ inoculate, type = "response")
pairs(adl.t.emm)
## contrast ratio SE df null z.ratio p.value
## FALSE / TRUE 0.32 0.069 Inf 1 -5.287 <.0001
##
## Results are averaged over the levels of: treatment
## Tests are performed on the log scale
adl.t.emm
## $emmeans
## inoculate response SE df asymp.LCL asymp.UCL
## FALSE 2.01 0.308 Inf 1.49 2.72
## TRUE 6.29 1.299 Inf 4.20 9.43
##
## Results are averaged over the levels of: treatment
## 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.32 0.069 Inf 1 -5.287 <.0001
##
## Results are averaged over the levels of: treatment
## Tests are performed on the log scale
adl_sum <- adl %>%
group_by(treatment) %>%
summarise(wrkrs = length(bee_id))
adl_sum
## # A tibble: 2 × 2
## treatment wrkrs
## <fct> <int>
## 1 3 50
## 2 4 49
adl$bee_id <- as.factor(adl$bee_id)
hist(adl$max_infc)
adl$logmax <- log((adl$max_infc)+1)
hist(adl$logmax)
shapiro.test(adl$logmax)
##
## Shapiro-Wilk normality test
##
## data: adl$logmax
## W = 0.90717, p-value = 3.447e-06
range(adl$logmax)
## [1] 0.000000 6.270988
maxmod <- lmer(logmax ~ treatment + inoculate + round + (1|colony), data = adl)
Anova(maxmod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: logmax
## Chisq Df Pr(>Chisq)
## treatment 0.2929 1 0.588367
## inoculate 9.8498 1 0.001698 **
## round 11.9265 2 0.002572 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
maxmod.emm <- emmeans(maxmod, pairwise ~ inoculate, type = "response")
library(NBZIMM)
max.zig = lme.zig(fixed = logmax ~ treatment + inoculate + round + offset(log(days_to_adl + 1)),
random = ~ 1 | colony, data = adl)
## Computational iterations: 4
## Computational time: 0.001 minutes
Anova(max.zig)
## Analysis of Deviance Table (Type II tests)
##
## Response: zz
## Chisq Df Pr(>Chisq)
## treatment 2.3994 1 0.12138
## inoculate 7.9420 1 0.00483 **
## round 19.3761 2 6.202e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
max_sum <- adl %>%
group_by(treatment) %>%
summarise(m = mean(max_infc),
n = length(max_infc),
sd = sd(max_infc)) %>%
mutate(se = sd/sqrt(n))
max_sum
## # A tibble: 2 × 5
## treatment m n sd se
## <fct> <dbl> <int> <dbl> <dbl>
## 1 3 99.7 50 124. 17.5
## 2 4 81.1 49 106. 15.1
qpcr <- read_csv("qpcr_time2.csv")
qpcr$bee_id <- as.factor(qpcr$bee_id)
qpcr$time_group <- as.factor(qpcr$time_group)
qpcr$inoculate_round <- as.factor(qpcr$inoculate_round)
qpcr$replicate <- as.factor(qpcr$replicate)
f1 = lme.zig(fixed = logspores ~ fungicide*time_group + inoculate_round + inoculate + replicate + offset(log(days_since_innoculation + 1)),
random = ~ 1 | bee_id, data = qpcr)
## Computational iterations: 6
## Computational time: 0.005 minutes
Anova(f1)
## Analysis of Deviance Table (Type II tests)
##
## Response: zz
## Chisq Df Pr(>Chisq)
## fungicide 4.010 1 0.0452319 *
## time_group 226.681 2 < 2.2e-16 ***
## inoculate_round 18.931 2 7.749e-05 ***
## inoculate 39.976 1 2.572e-10 ***
## replicate 18.852 8 0.0156699 *
## fungicide:time_group 15.474 2 0.0004364 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
f1.emm <- emmeans(f1, pairwise ~ fungicide*time_group, type = "response")
f1.emm
## $emmeans
## fungicide time_group emmean SE df lower.CL upper.CL
## FALSE 1 0.66958 0.144 72 0.383 0.957
## TRUE 1 0.53311 0.164 72 0.206 0.860
## FALSE 2 -0.56071 0.144 72 -0.848 -0.274
## TRUE 2 -0.00202 0.161 72 -0.322 0.318
## FALSE 3 -0.97987 0.145 72 -1.269 -0.691
## TRUE 3 -0.57387 0.162 72 -0.897 -0.251
##
## Results are averaged over the levels of: inoculate_round, inoculate, replicate
## Degrees-of-freedom method: containment
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## FALSE time_group1 - TRUE time_group1 0.1365 0.184 72 0.740 0.9762
## FALSE time_group1 - FALSE time_group2 1.2303 0.129 989 9.529 <.0001
## FALSE time_group1 - TRUE time_group2 0.6716 0.181 72 3.716 0.0051
## FALSE time_group1 - FALSE time_group3 1.6495 0.131 989 12.601 <.0001
## FALSE time_group1 - TRUE time_group3 1.2434 0.182 72 6.845 <.0001
## TRUE time_group1 - FALSE time_group2 1.0938 0.181 72 6.042 <.0001
## TRUE time_group1 - TRUE time_group2 0.5351 0.132 989 4.061 0.0007
## TRUE time_group1 - FALSE time_group3 1.5130 0.182 72 8.314 <.0001
## TRUE time_group1 - TRUE time_group3 1.1070 0.133 989 8.317 <.0001
## FALSE time_group2 - TRUE time_group2 -0.5587 0.177 72 -3.155 0.0273
## FALSE time_group2 - FALSE time_group3 0.4192 0.124 989 3.371 0.0101
## FALSE time_group2 - TRUE time_group3 0.0132 0.178 72 0.074 1.0000
## TRUE time_group2 - FALSE time_group3 0.9779 0.178 72 5.490 <.0001
## TRUE time_group2 - TRUE time_group3 0.5718 0.124 989 4.595 0.0001
## FALSE time_group3 - TRUE time_group3 -0.4060 0.179 72 -2.267 0.2210
##
## Results are averaged over the levels of: inoculate_round, inoculate, replicate
## Degrees-of-freedom method: containment
## P value adjustment: tukey method for comparing a family of 6 estimates
f2.emm <- emmeans(f1, pairwise ~ inoculate_round, type = "response")
f2.emm
## $emmeans
## inoculate_round emmean SE df lower.CL upper.CL
## 1 -0.432 0.147 72 -0.725 -0.139
## 2 -1.333 0.321 72 -1.973 -0.693
## 3 1.308 0.411 72 0.489 2.126
##
## Results are averaged over the levels of: fungicide, time_group, inoculate, replicate
## Degrees-of-freedom method: containment
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## inoculate_round1 - inoculate_round2 0.901 0.409 72 2.203 0.0774
## inoculate_round1 - inoculate_round3 -1.740 0.441 72 -3.945 0.0005
## inoculate_round2 - inoculate_round3 -2.640 0.636 72 -4.155 0.0003
##
## Results are averaged over the levels of: fungicide, time_group, inoculate, replicate
## Degrees-of-freedom method: containment
## P value adjustment: tukey method for comparing a family of 3 estimates
f3.emm <- emmeans(f1, pairwise ~ inoculate, type = "response")
f3.emm
## $emmeans
## inoculate emmean SE df lower.CL upper.CL
## FALSE -0.644 0.107 72 -0.8583 -0.430
## TRUE 0.340 0.162 72 0.0175 0.662
##
## Results are averaged over the levels of: fungicide, time_group, inoculate_round, replicate
## Degrees-of-freedom method: containment
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## FALSE - TRUE -0.984 0.157 72 -6.273 <.0001
##
## Results are averaged over the levels of: fungicide, time_group, inoculate_round, replicate
## Degrees-of-freedom method: containment
f4.emm <- emmeans(f1, pairwise ~ fungicide, type = "response")
f4.emm
## $emmeans
## fungicide emmean SE df lower.CL upper.CL
## FALSE -0.2903 0.124 72 -0.537 -0.0433
## TRUE -0.0143 0.144 72 -0.301 0.2724
##
## Results are averaged over the levels of: time_group, inoculate_round, inoculate, replicate
## Degrees-of-freedom method: containment
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## FALSE - TRUE -0.276 0.146 72 -1.887 0.0631
##
## Results are averaged over the levels of: time_group, inoculate_round, inoculate, replicate
## Degrees-of-freedom method: containment
infec_sum <- qpcr %>%
group_by(treatment, time_group) %>%
summarise(m = mean(logspores),
n = length(logspores),
sd = sd(logspores)) %>%
mutate(se = sd/sqrt(n))
infec_sum
## # A tibble: 6 × 6
## # Groups: treatment [2]
## treatment time_group m n sd se
## <dbl> <fct> <dbl> <int> <dbl> <dbl>
## 1 3 1 0.869 163 1.46 0.114
## 2 3 2 1.14 190 1.49 0.108
## 3 3 3 1.08 177 1.36 0.102
## 4 4 1 1.23 169 1.72 0.132
## 5 4 2 0.848 194 1.21 0.0869
## 6 4 3 0.922 185 1.22 0.0896
## compare slopes
qpcr_time <- read_csv("qpcr_time.csv")
qpcr_time$time_group <- as.numeric(qpcr_time$time_group)
qpcr_time$fungicide <- as.logical(qpcr_time$fungicide)
qpcr_time$inoculate <- as.factor(qpcr_time$inoculate)
qpcr_time$inoculate_round <- as.factor(qpcr_time$inoculate_round)
library(lsmeans)
m.interaction <- lm(logspores ~ time_group*fungicide, data = qpcr_time)
anova(m.interaction)
## Analysis of Variance Table
##
## Response: logspores
## Df Sum Sq Mean Sq F value Pr(>F)
## time_group 1 0.51 0.5145 0.2572 0.61215
## fungicide 1 0.51 0.5089 0.2544 0.61409
## time_group:fungicide 1 10.97 10.9688 5.4830 0.01938 *
## Residuals 1074 2148.53 2.0005
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain slopes
m.interaction$coefficients
## (Intercept) time_group fungicideTRUE
## 1.2961702 -0.1504946 -0.4668058
## time_group:fungicideTRUE
## 0.2516393
m.lst <- lstrends(m.interaction, "fungicide", var="time_group")
m.lst
## fungicide time_group.trend SE df lower.CL upper.CL
## FALSE -0.150 0.0752 1074 -0.2981 -0.00289
## TRUE 0.101 0.0767 1074 -0.0494 0.25174
##
## Confidence level used: 0.95
qpcr_time$time_group <- as.factor(qpcr_time$time_group)
qpcr_time$days_factor <- as.factor(qpcr_time$days_factor)
pairs(m.lst)
## contrast estimate SE df t.ratio p.value
## FALSE - TRUE -0.252 0.107 1074 -2.342 0.0194
#write.csv(condf, file = "C:/Users/runni/OneDrive - The Ohio State University/Runnion and Sivakoff/Synergism Experiment/Disease Dynamics Manuscript/Data and code/condf.csv", row.names = FALSE)
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)
brood <- read_csv("brood.csv")
drones$fungicide <- as.logical(drones$fungicide)
drones$crithidia <- as.logical(drones$crithidia)
drones <- na.omit(drones)
em.mod <- glmer.nb(emerge ~ fungicide + crithidia + dry_weight + live_weight + workers_alive + mean.pollen + block + (1|colony), data = drones)
## Warning in theta.ml(Y, mu, weights = object@resp$weights, limit = limit, :
## iteration limit reached
summary(em.mod)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: Negative Binomial(10735426) ( log )
## Formula:
## emerge ~ fungicide + crithidia + dry_weight + live_weight + workers_alive +
## mean.pollen + block + (1 | colony)
## Data: drones
##
## AIC BIC logLik deviance df.resid
## 1585.0 1643.0 -776.5 1553.0 260
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.99595 -0.33402 -0.00726 0.28623 1.42899
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 4.161e-11 6.451e-06
## Number of obs: 276, groups: colony, 24
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 3.781181 0.054563 69.299 <2e-16 ***
## fungicideTRUE 0.031461 0.021124 1.489 0.1364
## crithidiaTRUE -0.016026 0.021391 -0.749 0.4537
## dry_weight -0.996784 0.082201 -12.126 <2e-16 ***
## live_weight 0.020070 0.022366 0.897 0.3695
## workers_alive -0.017403 0.014123 -1.232 0.2178
## mean.pollen 0.008142 0.070263 0.116 0.9078
## block4 -0.079237 0.046513 -1.704 0.0885 .
## block7 -0.054322 0.046684 -1.164 0.2446
## block8 -0.087186 0.051441 -1.695 0.0901 .
## block9 -0.058945 0.045830 -1.286 0.1984
## block10 -0.088586 0.040787 -2.172 0.0299 *
## block11 -0.070740 0.064007 -1.105 0.2691
## block12 -0.102562 0.050383 -2.036 0.0418 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
drop1(em.mod, test = "Chisq")
## Single term deletions
##
## Model:
## emerge ~ fungicide + crithidia + dry_weight + live_weight + workers_alive +
## mean.pollen + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1585.0
## fungicide 1 1584.8 1.79510 0.1803
## crithidia 1 1583.5 0.48092 0.4880
## dry_weight 1 1583.5 0.42580 0.5141
## live_weight 1 1583.7 0.70007 0.4028
## workers_alive 1 1583.8 0.76689 0.3812
## mean.pollen 1 1583.0 0.00493 0.9440
## block 7 1574.1 3.10694 0.8749
em1 <- update(em.mod, .~. -workers_alive)
drop1(em1, test = "Chisq")
## Single term deletions
##
## Model:
## emerge ~ fungicide + crithidia + dry_weight + live_weight + mean.pollen +
## block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1583.8
## fungicide 1 1584.6 2.83989 0.09195 .
## crithidia 1 1582.1 0.33177 0.56462
## dry_weight 1 1582.4 0.61781 0.43186
## live_weight 1 1582.5 0.67830 0.41017
## mean.pollen 1 1581.9 0.13475 0.71355
## block 7 1572.4 2.64294 0.91595
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em2 <- update(em1, .~. -live_weight)
drop1(em2, test = "Chisq")
## Single term deletions
##
## Model:
## emerge ~ fungicide + crithidia + dry_weight + mean.pollen + block +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1582.5
## fungicide 1 1583.4 2.93735 0.08655 .
## crithidia 1 1580.7 0.27039 0.60307
## dry_weight 1 1581.1 0.64017 0.42365
## mean.pollen 1 1580.7 0.18562 0.66659
## block 7 1571.0 2.47712 0.92881
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em3 <- update(em2, .~. -dry_weight)
drop1(em3, test = "Chisq")
## Single term deletions
##
## Model:
## emerge ~ fungicide + crithidia + mean.pollen + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1581.1
## fungicide 1 1582.4 3.2994 0.06931 .
## crithidia 1 1579.5 0.4233 0.51529
## mean.pollen 1 1579.3 0.1540 0.69475
## block 7 1570.4 3.2718 0.85878
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em4 <- update(em3, .~. -mean.pollen)
em4 <- update(em4, .~. -block)
Anova(em4)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: emerge
## Chisq Df Pr(>Chisq)
## fungicide 4.0505 1 0.04416 *
## crithidia 0.0056 1 0.94029
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(em4)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: emerge
## Chisq Df Pr(>Chisq)
## fungicide 4.0505 1 0.04416 *
## crithidia 0.0056 1 0.94029
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(em4)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: Negative Binomial(10735426) ( log )
## Formula: emerge ~ fungicide + crithidia + (1 | colony)
## Data: drones
##
## AIC BIC logLik deviance df.resid
## 1571.9 1590.0 -780.9 1561.9 271
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.84695 -0.29780 -0.02924 0.28507 2.07464
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 2.519e-10 1.587e-05
## Number of obs: 276, groups: colony, 24
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 3.60568 0.01462 246.557 <2e-16 ***
## fungicideTRUE 0.03813 0.01894 2.013 0.0442 *
## crithidiaTRUE -0.00148 0.01976 -0.075 0.9403
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) fnTRUE
## fungicdTRUE -0.530
## crithidTRUE -0.497 -0.049
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
emem <- emmeans(em4, pairwise ~ fungicide, type = "response")
emem
## $emmeans
## fungicide response SE df asymp.LCL asymp.UCL
## FALSE 36.8 0.477 Inf 35.9 37.7
## TRUE 38.2 0.560 Inf 37.1 39.3
##
## 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.963 0.0182 Inf 1 -2.013 0.0442
##
## 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
## FALSE 36.8 0.477 Inf 35.7 37.9 a
## TRUE 38.2 0.560 Inf 37.0 39.5 b
##
## 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
## FALSE / TRUE 0.963 0.0182 Inf 1 -2.013 0.0442
##
## 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 36.9 2.42 99 0.243
## 2 2 38.1 2.53 68 0.307
## 3 3 38.4 4.08 49 0.583
## 4 4 36.6 2.17 60 0.281
em_sum$plot <- em_sum$m + em_sum$se
emerge_plot <- 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.04",
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)
hist(drones$relative_fat)
shapiro.test(drones$relative_fat)
##
## Shapiro-Wilk normality test
##
## data: drones$relative_fat
## W = 0.97273, p-value = 4.049e-05
drones$sqrt_rf <- (sqrt(drones$relative_fat))
shapiro.test(drones$sqrt_rf)
##
## Shapiro-Wilk normality test
##
## data: drones$sqrt_rf
## W = 0.99031, p-value = 0.06387
rf.mod <- lmer(sqrt_rf ~ fungicide + crithidia + workers_alive + block + (1|colony), data = drones)
drop1(rf.mod, test = "Chisq")
## Single term deletions
##
## Model:
## sqrt_rf ~ fungicide + crithidia + workers_alive + block + (1 |
## colony)
## npar AIC LRT Pr(Chi)
## <none> -3917.5
## fungicide 1 -3916.1 3.3914 0.0655362 .
## crithidia 1 -3916.1 3.3812 0.0659450 .
## workers_alive 1 -3919.5 0.0028 0.9580624
## block 7 -3906.4 25.0249 0.0007511 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf2 <- update(rf.mod, .~. -workers_alive)
drop1(rf2, test = "Chisq")
## Single term deletions
##
## Model:
## sqrt_rf ~ fungicide + crithidia + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -3919.5
## fungicide 1 -3917.5 3.9604 0.0465822 *
## crithidia 1 -3918.0 3.4955 0.0615375 .
## block 7 -3908.2 25.2508 0.0006849 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(rf2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: sqrt_rf
## Chisq Df Pr(>Chisq)
## fungicide 3.1025 1 0.0781740 .
## crithidia 2.6455 1 0.1038434
## block 24.9699 7 0.0007682 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf_sum <- drones %>%
group_by(treatment) %>%
summarise(m = mean(relative_fat),
sd = sd(relative_fat),
n = length(relative_fat)) %>%
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
hist(drones$radial_cell)
shapiro.test(drones$radial_cell)
##
## Shapiro-Wilk normality test
##
## data: drones$radial_cell
## W = 0.97655, p-value = 0.0001662
range(drones$radial_cell)
## [1] 2073.526 3083.439
drones$cuberc <- (drones$radial_cell)^3
shapiro.test(drones$cuberc)
##
## Shapiro-Wilk normality test
##
## data: drones$cuberc
## W = 0.99215, p-value = 0.1516
hist(drones$cuberc)
rc_mod <- lmer(cuberc ~ fungicide + crithidia + block + workers_alive + (1|colony), data = drones)
drop1(rc_mod, test = "Chisq")
## Single term deletions
##
## Model:
## cuberc ~ fungicide + crithidia + block + workers_alive + (1 |
## colony)
## npar AIC LRT Pr(Chi)
## <none> 12937
## fungicide 1 12943 8.1764 0.004244 **
## crithidia 1 12937 2.0554 0.151666
## block 7 12934 10.8866 0.143641
## workers_alive 1 12936 0.9179 0.338029
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rc2 <- update(rc_mod, .~. -workers_alive)
drop1(rc2, test = "Chisq")
## Single term deletions
##
## Model:
## cuberc ~ fungicide + crithidia + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 12936
## fungicide 1 12945 11.5929 0.000662 ***
## crithidia 1 12935 1.5925 0.206967
## block 7 12933 11.5882 0.114941
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rc3 <- update(rc2, .~. -block)
Anova(rc3)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: cuberc
## 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
rc_sum <- drones %>%
group_by(treatment) %>%
summarise(m = mean(radial_cell),
sd = sd(radial_cell),
n = length(radial_cell)) %>%
mutate(se = sd/sqrt(n))
rc_sum
## # 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
rc_sum$plot <- rc_sum$m + rc_sum$se
rc_sum
## # A tibble: 4 × 6
## treatment m sd n se plot
## <fct> <dbl> <dbl> <int> <dbl> <dbl>
## 1 1 2699. 182. 99 18.3 2717.
## 2 2 2664. 174. 68 21.1 2685.
## 3 3 2660. 173. 49 24.7 2685.
## 4 4 2750. 136. 60 17.5 2768.
rc_plot <- ggplot(rc_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 = "Radial cell length (ul)") +
theme_classic(base_size = 20) +
coord_cartesian(ylim=c(2600, 2800)) +
annotate(geom = "text",
x = 1, y = 2745,
label = "P = 0.02",
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 = 2710, yend = 2710,
lineend = "round", linejoin = "round") +
geom_segment(x = 2, xend = 2, y = 2700, yend = 2720,
lineend = "round", linejoin = "round") +
geom_segment(x = 3, xend = 3, y = 2700, yend = 2720,
lineend = "round", linejoin = "round") +
geom_segment(x = 1, xend = 4, y = 2790, yend = 2790,
lineend = "round", linejoin = "round") +
geom_segment(x = 1, xend = 1, y = 2780, yend = 2800,
lineend = "round", linejoin = "round") +
geom_segment(x = 4, xend = 4, y = 2780, yend = 2800,
lineend = "round", linejoin = "round") +
geom_text(x = 2.5, y = 2712, label = "b", size = 6, vjust = -0.5) +
geom_text(x = 2.5, y = 2792, label = "a", size = 6, vjust = -0.5)
rc_plot
plot_grid(emerge_plot, rc_plot, ncol=2, nrow =1)
## Count of males
brood <- read_csv("brood.csv")
brood <- read_csv("brood.csv")
brood$colony <- as.factor(brood$colony)
brood$treatment <- as.factor(brood$treatment)
brood$block <- as.factor(brood$block)
brood$fungicide <- as.logical(brood$fungicide)
brood$crithidia <- as.logical(brood$crithidia)
male_count <- glm.nb(total_drones ~ fungicide + crithidia + block + workers_alive, data = brood)
## Warning in glm.nb(total_drones ~ fungicide + crithidia + block + workers_alive,
## : alternation limit reached
drop1(male_count, test = "Chisq")
## Single term deletions
##
## Model:
## total_drones ~ fungicide + crithidia + block + workers_alive
## Df Deviance AIC LRT Pr(>Chi)
## <none> 42.183 190.34
## fungicide 1 42.673 188.83 0.490 0.4840
## crithidia 1 42.767 188.93 0.584 0.4446
## block 8 94.592 226.75 52.408 1.404e-08 ***
## workers_alive 1 72.919 219.08 30.736 2.957e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(male_count)
## Analysis of Deviance Table (Type II tests)
##
## Response: total_drones
## LR Chisq Df Pr(>Chisq)
## fungicide 0.490 1 0.4840
## crithidia 0.584 1 0.4446
## block 52.408 8 1.404e-08 ***
## workers_alive 30.736 1 2.957e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(male_count)
##
## Call:
## glm.nb(formula = total_drones ~ fungicide + crithidia + block +
## workers_alive, data = brood, init.theta = 6.826554202, link = log)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -6.452e-01 6.069e-01 -1.063 0.287785
## fungicideTRUE -1.500e-01 2.099e-01 -0.714 0.475035
## crithidiaTRUE -1.671e-01 2.126e-01 -0.786 0.431855
## block4 9.474e-01 4.131e-01 2.294 0.021808 *
## block6 -3.766e+01 3.355e+07 0.000 0.999999
## block7 5.753e-01 4.511e-01 1.275 0.202200
## block8 2.564e-01 4.383e-01 0.585 0.558634
## block9 1.972e-01 4.331e-01 0.455 0.648894
## block10 1.442e+00 4.027e-01 3.581 0.000342 ***
## block11 -2.076e-01 5.231e-01 -0.397 0.691532
## block12 8.826e-01 4.625e-01 1.908 0.056345 .
## workers_alive 5.700e-01 1.086e-01 5.247 1.55e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(6.8266) family taken to be 1)
##
## Null deviance: 172.432 on 35 degrees of freedom
## Residual deviance: 42.183 on 24 degrees of freedom
## AIC: 192.34
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 6.83
## Std. Err.: 3.60
## Warning while fitting theta: alternation limit reached
##
## 2 x log-likelihood: -166.341
m0 <- glmmTMB(total_drones ~ fungicide + crithidia + block + workers_alive, data = brood)
Anova(m0)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: total_drones
## Chisq Df Pr(>Chisq)
## fungicide 2.7355 1 0.09814 .
## crithidia 0.3672 1 0.54456
## block 58.4296 8 9.465e-10 ***
## workers_alive 18.9357 1 1.352e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mc_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(total_drones),
n = length(total_drones),
sd = sd(total_drones)) %>%
mutate(se = sd/sqrt(n))
mc_sum
## # A tibble: 4 × 5
## treatment m n sd se
## <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
hist(drones$dry_weight)
shapiro.test(drones$dry_weight)
##
## Shapiro-Wilk normality test
##
## data: drones$dry_weight
## W = 0.99092, p-value = 0.08545
mdw <- lmer(dry_weight ~ fungicide + crithidia + block + workers_alive + (1|colony), data = drones )
drop1(mdw, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ fungicide + crithidia + block + workers_alive +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -1972.0
## fungicide 1 -1973.2 0.8566 0.354692
## crithidia 1 -1968.2 5.7878 0.016137 *
## block 7 -1964.7 21.3501 0.003285 **
## workers_alive 1 -1971.4 2.5854 0.107854
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mdw1 <- update(mdw, .~. -workers_alive)
drop1(mdw1, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ fungicide + crithidia + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -1971.4
## fungicide 1 -1970.4 2.9877 0.083900 .
## crithidia 1 -1969.0 4.4024 0.035888 *
## block 7 -1965.0 20.4208 0.004729 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(mdw1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: dry_weight
## Chisq Df Pr(>Chisq)
## fungicide 2.6144 1 0.10590
## crithidia 2.4038 1 0.12104
## block 17.9827 7 0.01205 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
male_dw <- drones %>%
group_by(treatment) %>%
summarise(m = mean(dry_weight),
sd = sd(dry_weight),
n = length(dry_weight)) %>%
mutate(se = sd/sqrt(n))
male_dw
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 0.0376 0.00739 99 0.000743
## 2 2 0.0376 0.00658 68 0.000798
## 3 3 0.0378 0.00706 49 0.00101
## 4 4 0.0395 0.00658 60 0.000849
workers <- na.omit(workers)
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)
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.96135, p-value = 3.197e-05
workers$logdry <- log(workers$dry)
shapiro.test(workers$logdry)
##
## Shapiro-Wilk normality test
##
## data: workers$logdry
## W = 0.99094, p-value = 0.2537
hist(workers$logdry)
workers$fungicide <- as.logical(workers$fungicide)
workers$crithidia <- as.logical(workers$crithidia)
wrkdry <- lmer(logdry ~ fungicide*crithidia + inoculate +block + (1|colony), data = workers)
drop1(wrkdry, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ fungicide * crithidia + inoculate + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 93.353
## inoculate 1 91.391 0.0373 0.8468608
## block 9 104.116 28.7625 0.0007106 ***
## fungicide:crithidia 1 91.794 0.4412 0.5065339
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wrkdry <- lmer(logdry ~ fungicide + crithidia + inoculate +block + (1|colony), data = workers)
drop1(wrkdry, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ fungicide + crithidia + inoculate + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 91.794
## fungicide 1 95.101 5.3065 0.0212462 *
## crithidia 1 102.738 12.9433 0.0003211 ***
## inoculate 1 89.833 0.0381 0.8452327
## block 9 102.295 28.5009 0.0007863 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(wrkdry)
## Linear mixed model fit by REML ['lmerMod']
## Formula: logdry ~ fungicide + crithidia + inoculate + block + (1 | colony)
## Data: workers
##
## REML criterion at convergence: 104.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.91492 -0.56289 -0.00892 0.66798 2.04904
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 0.02217 0.1489
## Residual 0.07178 0.2679
## Number of obs: 197, groups: colony, 40
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) -2.781148 0.105194 -26.438
## fungicideTRUE -0.122302 0.061443 -1.990
## crithidiaTRUE -0.200682 0.061443 -3.266
## inoculateTRUE -0.009667 0.047465 -0.204
## block4 0.087618 0.135147 0.648
## block5 -0.156602 0.136922 -1.144
## block6 -0.008842 0.135923 -0.065
## block7 -0.100143 0.135922 -0.737
## block8 0.121194 0.135147 0.897
## block9 -0.386717 0.135147 -2.861
## block10 -0.126487 0.135147 -0.936
## block11 -0.378121 0.135922 -2.782
## block12 -0.156229 0.135147 -1.156
wrkdry1 <- update(wrkdry, .~. -inoculate)
drop1(wrkdry1, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ fungicide + crithidia + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 89.833
## fungicide 1 93.139 5.3061 0.0212508 *
## crithidia 1 100.782 12.9492 0.0003201 ***
## block 9 100.343 28.5101 0.0007835 ***
## ---
## 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 + block + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 93.139
## crithidia 1 102.998 11.859 0.0005738 ***
## block 9 100.838 25.700 0.0022873 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(wrkdry, wm2, test = "Chisq")
## Data: workers
## Models:
## wm2: logdry ~ crithidia + block + (1 | colony)
## wrkdry: logdry ~ fungicide + crithidia + inoculate + block + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## wm2 13 93.139 135.82 -33.569 67.139
## wrkdry 15 91.794 141.04 -30.897 61.794 5.3442 2 0.06911 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(wrkdry1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: logdry ~ fungicide + crithidia + block + (1 | colony)
## Data: workers
##
## REML criterion at convergence: 100.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.91419 -0.57743 -0.00892 0.67578 2.02348
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 0.02225 0.1492
## Residual 0.07134 0.2671
## Number of obs: 197, groups: colony, 40
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) -2.78308 0.10475 -26.568
## fungicideTRUE -0.12228 0.06144 -1.990
## crithidiaTRUE -0.20072 0.06144 -3.267
## block4 0.08762 0.13513 0.648
## block5 -0.15659 0.13691 -1.144
## block6 -0.00897 0.13590 -0.066
## block7 -0.10021 0.13590 -0.737
## block8 0.12119 0.13513 0.897
## block9 -0.38672 0.13513 -2.862
## block10 -0.12649 0.13513 -0.936
## block11 -0.37822 0.13590 -2.783
## block12 -0.15623 0.13513 -1.156
##
## Correlation of Fixed Effects:
## (Intr) fnTRUE crTRUE block4 block5 block6 block7 block8 block9
## fungicdTRUE -0.286
## crithidTRUE -0.286 -0.023
## block4 -0.645 0.000 0.000
## block5 -0.637 0.115 -0.115 0.494
## block6 -0.641 -0.005 0.005 0.497 0.490
## block7 -0.638 -0.005 -0.005 0.497 0.491 0.494
## block8 -0.645 0.000 0.000 0.500 0.494 0.497 0.497
## block9 -0.645 0.000 0.000 0.500 0.494 0.497 0.497 0.500
## block10 -0.645 0.000 0.000 0.500 0.494 0.497 0.497 0.500 0.500
## block11 -0.644 0.005 0.005 0.497 0.491 0.494 0.494 0.497 0.497
## block12 -0.645 0.000 0.000 0.500 0.494 0.497 0.497 0.500 0.500
## blck10 blck11
## fungicdTRUE
## crithidTRUE
## block4
## block5
## block6
## block7
## block8
## block9
## block10
## block11 0.497
## block12 0.500 0.497
Anova(wrkdry1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: logdry
## Chisq Df Pr(>Chisq)
## fungicide 3.9617 1 0.0465471 *
## crithidia 10.6738 1 0.0010866 **
## block 29.1364 9 0.0006146 ***
## ---
## 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
## FALSE -2.95 0.0443 27.9 -3.05 -2.86
## TRUE -3.16 0.0421 28.1 -3.24 -3.07
##
## 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.201 0.0614 28 3.267 0.0029
##
## 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
## FALSE - TRUE 0.201 0.0614 28 3.267 0.0029
##
## 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.0418 0.0128 42 0.00198
## 4 4 0.0488 0.0184 43 0.00281
wtuk.means <- emmeans(object = wrkdry1,
specs = "crithidia",
adjust = "Tukey",
type = "response")
wtuk.means
## crithidia emmean SE df lower.CL upper.CL
## FALSE -2.95 0.0443 27.9 -3.06 -2.85
## TRUE -3.16 0.0421 28.1 -3.25 -3.06
##
## 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
## TRUE -3.16 0.0421 28.1 -3.25 -3.06 a
## FALSE -2.95 0.0443 27.9 -3.06 -2.85 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.
work_dry <- 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)
bcm <- glm.nb(brood_cells ~ fungicide + crithidia + workers_alive + block, data = brood)
Anova(bcm)
## Analysis of Deviance Table (Type II tests)
##
## Response: brood_cells
## LR Chisq Df Pr(>Chisq)
## fungicide 3.070 1 0.07973 .
## crithidia 0.010 1 0.91928
## workers_alive 92.831 1 < 2e-16 ***
## block 102.709 8 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
b_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(brood_cells),
sd = sd(brood_cells),
n = length(brood_cells)) %>%
mutate(se = sd/sqrt(n))
b_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 30.7 23.1 9 7.71
## 2 2 29.8 21.1 9 7.04
## 3 3 21.7 24.9 9 8.30
## 4 4 23.9 26.3 9 8.77
hpm <- glm(honey_pots ~ fungicide + crithidia + workers_alive + block, data = brood, family = "poisson")
Anova(hpm)
## Analysis of Deviance Table (Type II tests)
##
## Response: honey_pots
## LR Chisq Df Pr(>Chisq)
## fungicide 3.5096 1 0.0610131 .
## crithidia 1.2041 1 0.2725029
## workers_alive 8.0172 1 0.0046336 **
## block 27.4941 8 0.0005806 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
hp_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(honey_pots),
sd = sd(honey_pots),
n = length(honey_pots)) %>%
mutate(se = sd/sqrt(n))
hp_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 3.33 2.5 9 0.833
## 2 2 4.11 3.02 9 1.01
## 3 3 2.56 2.24 9 0.747
## 4 4 1.89 1.90 9 0.633
tlm <- glm.nb(total_larvae ~ fungicide + crithidia + workers_alive + block, data = brood)
Anova(tlm)
## Analysis of Deviance Table (Type II tests)
##
## Response: total_larvae
## LR Chisq Df Pr(>Chisq)
## fungicide 0.646 1 0.4217
## crithidia 0.037 1 0.8478
## workers_alive 39.129 1 3.967e-10 ***
## block 66.939 8 1.994e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tl_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(total_larvae),
sd = sd(total_larvae),
n = length(total_larvae)) %>%
mutate(se = sd/sqrt(n))
tl_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 22.4 20.9 9 6.97
## 2 2 16.3 11.3 9 3.76
## 3 3 14.2 20.4 9 6.79
## 4 4 16 19.9 9 6.62
dlm <- glm.nb(dead_larvae ~ fungicide + crithidia + workers_alive, data = brood)
Anova(dlm)
## Analysis of Deviance Table (Type II tests)
##
## Response: dead_larvae
## LR Chisq Df Pr(>Chisq)
## fungicide 0.0725 1 0.78771
## crithidia 0.3865 1 0.53413
## workers_alive 4.4928 1 0.03404 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dl_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(dead_larvae),
sd = sd(dead_larvae),
n = length(dead_larvae)) %>%
mutate(se = sd/sqrt(n))
dl_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 1.78 2.82 9 0.940
## 2 2 1.22 2.11 9 0.703
## 3 3 1.44 1.81 9 0.603
## 4 4 1.11 1.96 9 0.655
llm <- glm.nb(live_larvae ~ fungicide + crithidia + workers_alive + block, data = brood)
Anova(llm)
## Analysis of Deviance Table (Type II tests)
##
## Response: live_larvae
## LR Chisq Df Pr(>Chisq)
## fungicide 0.516 1 0.4723
## crithidia 0.002 1 0.9656
## workers_alive 44.398 1 2.680e-11 ***
## block 82.510 8 1.526e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ll_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(live_larvae),
sd = sd(live_larvae),
n = length(live_larvae)) %>%
mutate(se = sd/sqrt(n))
ll_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 20.7 19.0 9 6.34
## 2 2 15.1 11.0 9 3.68
## 3 3 12.8 19.5 9 6.52
## 4 4 14.9 18.7 9 6.23
plmod <- glm(cbind(live_larvae, dead_larvae) ~ fungicide + crithidia + block + 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.0179 1 0.893715
## crithidia 0.0067 1 0.934615
## block 24.1726 8 0.002144 **
## workers_alive 6.1501 1 0.013140 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tpm <- glm(total_pupae ~ fungicide + crithidia + workers_alive + block, data = brood, family = "poisson")
Anova(tpm)
## Analysis of Deviance Table (Type II tests)
##
## Response: total_pupae
## LR Chisq Df Pr(>Chisq)
## fungicide 0.005 1 0.94611
## crithidia 4.885 1 0.02709 *
## workers_alive 51.869 1 5.932e-13 ***
## block 50.394 8 3.433e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tp_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(total_pupae),
sd = sd(total_pupae),
n = length(total_pupae)) %>%
mutate(se = sd/sqrt(n))
tp_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 8.33 7.78 9 2.59
## 2 2 6 7.55 9 2.52
## 3 3 3.11 3.22 9 1.07
## 4 4 4.11 5.21 9 1.74
dpm <- glm.nb(dead_pupae ~ fungicide + crithidia + workers_alive + block, data = brood)
## Warning: glm.fit: fitted rates numerically 0 occurred
## 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
Anova(dpm)
## Analysis of Deviance Table (Type II tests)
##
## Response: dead_pupae
## LR Chisq Df Pr(>Chisq)
## fungicide 1.9743 1 0.15999
## crithidia 0.1183 1 0.73086
## workers_alive 4.5035 1 0.03383 *
## block 16.8182 8 0.03206 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dp_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(dead_pupae),
sd = sd(dead_pupae),
n = length(dead_pupae)) %>%
mutate(se = sd/sqrt(n))
dp_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 0.111 0.333 9 0.111
## 2 2 0.111 0.333 9 0.111
## 3 3 0.222 0.441 9 0.147
## 4 4 0.111 0.333 9 0.111
lpm <- glm(live_pupae ~ fungicide + crithidia + workers_alive + block, data = brood, family = "poisson")
Anova(lpm)
## Analysis of Deviance Table (Type II tests)
##
## Response: live_pupae
## LR Chisq Df Pr(>Chisq)
## fungicide 0.002 1 0.96330
## crithidia 5.386 1 0.02029 *
## workers_alive 58.627 1 1.905e-14 ***
## block 45.223 8 3.339e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lp_sum <- brood %>%
group_by(treatment) %>%
summarise(m = mean(live_pupae),
sd = sd(live_pupae),
n = length(live_pupae)) %>%
mutate(se = sd/sqrt(n))
lp_sum
## # A tibble: 4 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 8.22 7.58 9 2.53
## 2 2 5.89 7.54 9 2.51
## 3 3 2.89 3.30 9 1.10
## 4 4 4 5.17 9 1.72
ppmod <- glm(cbind(live_pupae, dead_pupae) ~ fungicide + crithidia + workers_alive, data = brood, family = binomial("logit"))
Anova(ppmod)
## 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
live_pup <- ggplot(data = lp_sum, aes(x = treatment, y = m, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0, 13)) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Live Pupae Count") +
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 = 12,
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 = 12, yend = 12,
lineend = "round", linejoin = "round") +
geom_segment(x = 1, xend = 1, y = 11.7, yend = 12.3,
lineend = "round", linejoin = "round") +
geom_segment(x = 2, xend = 2, y = 11.7, yend = 12.3,
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.7, yend = 7.3,
lineend = "round", linejoin = "round") +
geom_segment(x = 4, xend = 4, y = 6.7, yend = 7.3,
lineend = "round", linejoin = "round") +
geom_text(x = 1.5, y = 12.1, label = "a", size = 6, vjust = -0.5) +
geom_text(x = 3.5, y = 7.1, label = "b", size = 6, vjust = -0.5)
tp_plot <- ggplot(data = tp_sum, aes(x = treatment, y = m, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0, 13)) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Total Pupae Count") +
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 = 12,
label = "P = 0.03",
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 = 12, yend = 12,
lineend = "round", linejoin = "round") +
geom_segment(x = 1, xend = 1, y = 11.7, yend = 12.3,
lineend = "round", linejoin = "round") +
geom_segment(x = 2, xend = 2, y = 11.7, yend = 12.3,
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.7, yend = 7.3,
lineend = "round", linejoin = "round") +
geom_segment(x = 4, xend = 4, y = 6.7, yend = 7.3,
lineend = "round", linejoin = "round") +
geom_text(x = 1.5, y = 12.1, label = "a", size = 6, vjust = -0.5) +
geom_text(x = 3.5, y = 7.1, label = "b", size = 6, vjust = -0.5)
plot_grid(work_dry, tp_plot, live_pup, ncol=3, nrow =1)
total_mod <- glm.nb(total_larv_pup ~ fungicide + crithidia + workers_alive + block, data = brood)
Anova(total_mod)
## Analysis of Deviance Table (Type II tests)
##
## Response: total_larv_pup
## LR Chisq Df Pr(>Chisq)
## fungicide 0.888 1 0.3459
## crithidia 0.050 1 0.8227
## workers_alive 42.315 1 7.768e-11 ***
## block 61.151 8 2.769e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ppmod <- glm(cbind(total_live_larv_pup, total_dead_larv_pup) ~ fungicide + crithidia + workers_alive + block, data = brood, family = binomial("logit"))
Anova(ppmod)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(total_live_larv_pup, total_dead_larv_pup)
## LR Chisq Df Pr(>Chisq)
## fungicide 0.0591 1 0.807883
## crithidia 0.0003 1 0.985178
## workers_alive 10.3477 1 0.001296 **
## block 19.0622 8 0.014531 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
egg.mod <- glm.nb(eggs ~ fungicide + crithidia + workers_alive + block, data = brood)
drop1(egg.mod, test = "Chisq")
## Single term deletions
##
## Model:
## eggs ~ fungicide + crithidia + workers_alive + block
## Df Deviance AIC LRT Pr(>Chi)
## <none> 46.045 281.46
## fungicide 1 46.605 280.02 0.5603 0.454128
## crithidia 1 46.053 279.46 0.0079 0.929219
## workers_alive 1 61.824 295.24 15.7787 7.12e-05 ***
## block 8 67.938 287.35 21.8931 0.005118 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(egg.mod)
## Analysis of Deviance Table (Type II tests)
##
## Response: eggs
## LR Chisq Df Pr(>Chisq)
## fungicide 0.5603 1 0.454128
## crithidia 0.0079 1 0.929219
## workers_alive 15.7787 1 7.12e-05 ***
## block 21.8931 8 0.005118 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1