Weight Change
w <- weights
range(w$difference)
## [1] 3.79 18.50
u <- is.na(w)
unique(u)
## colony whole.mean mean.dose round dose treatment replicate brood_cells
## [1,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## honey_pot eggs dead_larvae live_larvae dead_pupae live_pupae dead_drones
## [1,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## live_drones drones avg_pollen qro duration dead_lp alive_lp alive dead
## [1,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## first last difference
## [1,] FALSE FALSE FALSE
ggplot(w, aes(x = difference, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.5, col = I("black")) +
scale_fill_viridis_d() + # Use viridis_d() for the color-blind friendly palette
ggtitle("Colony Weight Change") +
labs(y = "Count", x = "Weight (g)")

shapiro.test(w$difference)
##
## Shapiro-Wilk normality test
##
## data: w$difference
## W = 0.97975, p-value = 0.6097
descdist(w$difference, discrete = FALSE)

## summary statistics
## ------
## min: 3.79 max: 18.5
## median: 10.7
## mean: 10.74422
## estimated sd: 3.708625
## estimated skewness: 0.1757572
## estimated kurtosis: 2.431206
wmod.int <- glm(difference ~ treatment*whole.mean + alive + duration + replicate, data = w)
wmod1 <- glm(difference ~ treatment + whole.mean + alive + duration + replicate, data = w)
anova(wmod.int, wmod1, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: difference ~ treatment * whole.mean + alive + duration + replicate
## Model 2: difference ~ treatment + whole.mean + alive + duration + replicate
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 25 195.94
## 2 29 250.10 -4 -54.158 0.1407
AIC(wmod.int, wmod1)
## df AIC
## wmod.int 21 235.906
## wmod1 17 238.888
drop1(wmod1, test = "Chisq")
## Single term deletions
##
## Model:
## difference ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 250.10 238.89
## treatment 4 298.93 238.91 8.0254 0.09065 .
## whole.mean 1 397.49 257.74 20.8492 4.969e-06 ***
## alive 1 268.12 240.02 3.1307 0.07683 .
## duration 1 250.83 237.02 0.1309 0.71752
## replicate 8 313.55 233.06 10.1745 0.25299
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wmod2 <- update(wmod1, .~. -duration)
anova(wmod1, wmod2, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: difference ~ treatment + whole.mean + alive + duration + replicate
## Model 2: difference ~ treatment + whole.mean + alive + replicate
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 29 250.10
## 2 30 250.83 -1 -0.72848 0.7713
AIC(wmod1, wmod2)
## df AIC
## wmod1 17 238.8880
## wmod2 16 237.0189
drop1(wmod2, test = "Chisq")
## Single term deletions
##
## Model:
## difference ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 250.83 237.02
## treatment 4 301.98 237.37 8.3513 0.07952 .
## whole.mean 1 443.88 260.70 25.6856 4.018e-07 ***
## alive 1 274.43 239.07 4.0472 0.04424 *
## replicate 8 320.77 232.09 11.0679 0.19788
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wmod3 <- update(wmod2, .~. -replicate)
anova(wmod2, wmod3, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: difference ~ treatment + whole.mean + alive + replicate
## Model 2: difference ~ treatment + whole.mean + alive
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 30 250.83
## 2 38 320.77 -8 -69.94 0.3986
drop1(wmod3, test = "Chisq")
## Single term deletions
##
## Model:
## difference ~ treatment + whole.mean + alive
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 320.77 232.09
## treatment 4 372.88 230.86 6.7744 0.1483
## whole.mean 1 516.19 251.50 21.4095 3.709e-06 ***
## alive 1 328.93 231.22 1.1302 0.2877
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wmod3 <- update(wmod3, .~. -alive)
drop1(wmod3, test = "Chisq")
## Single term deletions
##
## Model:
## difference ~ treatment + whole.mean
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 328.93 231.22
## treatment 4 375.38 229.16 5.9447 0.2033
## whole.mean 1 523.29 250.11 20.8939 4.854e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(wmod3)
## Analysis of Deviance Table (Type II tests)
##
## Response: difference
## LR Chisq Df Pr(>Chisq)
## treatment 5.5078 4 0.239
## whole.mean 23.0457 1 1.582e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wmod3
##
## Call: glm(formula = difference ~ treatment + whole.mean, data = w)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 3.438 1.484 3.079 2.306 1.442 11.745
##
## Degrees of Freedom: 44 Total (i.e. Null); 39 Residual
## Null Deviance: 605.2
## Residual Deviance: 328.9 AIC: 231.2
summary(wmod3)
##
## Call:
## glm(formula = difference ~ treatment + whole.mean, data = w)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -8.3141 -1.6206 -0.0015 1.6194 7.0005
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.438 1.464 2.348 0.0240 *
## treatment2 1.484 1.375 1.079 0.2870
## treatment3 3.079 1.381 2.230 0.0316 *
## treatment4 2.306 1.375 1.678 0.1014
## treatment5 1.442 1.370 1.053 0.2989
## whole.mean 11.745 2.447 4.801 2.34e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 8.433975)
##
## Null deviance: 605.17 on 44 degrees of freedom
## Residual deviance: 328.93 on 39 degrees of freedom
## AIC: 231.22
##
## Number of Fisher Scoring iterations: 2
wsum <- w %>%
group_by(treatment) %>%
summarise(m = mean(difference),
sd = sd(difference),
n = length(difference)) %>%
mutate(se = sd/sqrt(n))
wdt <- setDT(as.data.frame(wsum))
wdt
## treatment m sd n se
## 1: 1 8.712222 4.019004 9 1.3396681
## 2: 2 10.786667 2.706511 9 0.9021702
## 3: 3 12.644444 4.078943 9 1.3596477
## 4: 4 11.611111 3.522941 9 1.1743136
## 5: 5 9.966667 3.589568 9 1.1965227
aw <- setDT(as.data.frame(Anova(wmod3)))
aw
## LR Chisq Df Pr(>Chisq)
## 1: 5.507845 4 2.390407e-01
## 2: 23.045699 1 1.581960e-06
we <- emmeans(wmod3, "treatment")
wp <- pairs(we)
wp <- as.data.frame(wp)
wp <- setDT(wp)
wp
## contrast estimate SE df t.ratio p.value
## 1: treatment1 - treatment2 -1.48367801 1.374540 39 -1.07939953 0.8159169
## 2: treatment1 - treatment3 -3.07899331 1.380509 39 -2.23033139 0.1901671
## 3: treatment1 - treatment4 -2.30634802 1.374573 39 -1.67786469 0.4589569
## 4: treatment1 - treatment5 -1.44181836 1.369577 39 -1.05274751 0.8290717
## 5: treatment2 - treatment3 -1.59531530 1.370112 39 -1.16436888 0.7711973
## 6: treatment2 - treatment4 -0.82267002 1.369020 39 -0.60091875 0.9741158
## 7: treatment2 - treatment5 0.04185964 1.378583 39 0.03036426 0.9999998
## 8: treatment3 - treatment4 0.77264528 1.370097 39 0.56393478 0.9794900
## 9: treatment3 - treatment5 1.63717494 1.386075 39 1.18115899 0.7619078
## 10: treatment4 - treatment5 0.86452966 1.378626 39 0.62709498 0.9697859
wtuk.means <- emmeans(object = wmod3,
specs = "treatment",
adjust = "Tukey",
type = "response")
wtuk.means
## treatment emmean SE df lower.CL upper.CL
## 1 9.08 0.971 39 6.46 11.7
## 2 10.57 0.969 39 7.95 13.2
## 3 12.16 0.973 39 9.53 14.8
## 4 11.39 0.969 39 8.77 14.0
## 5 10.52 0.975 39 7.89 13.2
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
wtkdt <- setDT(as.data.frame(wtuk.means))
wtkdt
## treatment emmean SE df lower.CL upper.CL
## 1: 1 9.082055 0.9711042 39 6.460238 11.70387
## 2: 2 10.565733 0.9691369 39 7.949227 13.18224
## 3: 3 12.161048 0.9732666 39 9.533393 14.78870
## 4: 4 11.388403 0.9691545 39 8.771849 14.00496
## 5: 5 10.523873 0.9749772 39 7.891599 13.15615
w.cld.model <- cld(object = wtuk.means,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
w.cld.model
## treatment emmean SE df lower.CL upper.CL .group
## 1 9.08 0.971 39 6.46 11.7 a
## 5 10.52 0.975 39 7.89 13.2 a
## 2 10.57 0.969 39 7.95 13.2 a
## 4 11.39 0.969 39 8.77 14.0 a
## 3 12.16 0.973 39 9.53 14.8 a
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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.
wtuk.treatment <- as.data.frame(w.cld.model)
wtuk.treatment
## treatment emmean SE df lower.CL upper.CL .group
## 1 9.082055 0.9711042 39 6.460238 11.70387 a
## 5 10.523873 0.9749772 39 7.891599 13.15615 a
## 2 10.565733 0.9691369 39 7.949227 13.18224 a
## 4 11.388403 0.9691545 39 8.771849 14.00496 a
## 3 12.161048 0.9732666 39 9.533393 14.78870 a
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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.
w_max <- w %>%
group_by(treatment) %>%
summarize(maxw = max(mean(difference)))
w_for_plotting <- full_join(wtuk.treatment, w_max,
by="treatment")
wsum
## # A tibble: 5 × 5
## treatment m sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 8.71 4.02 9 1.34
## 2 2 10.8 2.71 9 0.902
## 3 3 12.6 4.08 9 1.36
## 4 4 11.6 3.52 9 1.17
## 5 5 9.97 3.59 9 1.20
ggplot(data = wsum, aes(x = treatment, y = m, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0, 20)) +
scale_fill_viridis_d() + # Use viridis_d() for the color-blind friendly palette
geom_errorbar(aes(ymin = m - se, ymax = m + sd),
position = position_dodge(2), width = 0.4, size = 1.5) +
labs(y = "Mean Weight Difference") +
ggtitle("Average Colony Weight Change(g) by Treatment") +
scale_x_discrete(
name = "Treatment",
labels = c("0 PPB", "150 PPB", "1,500 PPB", "15,000 PPB", "150,000 PPB")
) +
theme_classic(base_size = 30) + # Adjust the base_size as needed
annotate(
geom = "text",
x = 1, y = 19,
label = " p = 0.24",
size = 15 # Adjust the size of the annotation text as needed
) +
annotate(
geom = "text",
x = c(1, 5, 2, 4, 3),
y = c(14, 15, 14.5, 16, 18),
label = c("a", "a", "a", "a", "a"),
size = 20 # Adjust the size of the annotation text as needed
) +
theme(legend.position = "none")
## 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.

ggplot(w, aes(x = whole.mean, y = difference, color = treatment)) +
geom_point(size = 5)+
ggtitle("Amount of Pollen Consumed vs. Average Colony Weight Change")+
xlab("Mean Polen Consumption(g)") +
ylab("Mean Weight(g)") +
scale_fill_viridis_d() +
theme(text = element_text(size = 20)) +
geom_smooth(method = "lm", color = "black")

Pollen Consumption
shapiro.test(pollen$difference)
##
## Shapiro-Wilk normality test
##
## data: pollen$difference
## W = 0.84265, p-value < 2.2e-16
pollen$sq <- (pollen$difference)^(1/3)
pollen$box <- bcPower(pollen$difference, -3, gamma=1)
shapiro.test(pollen$sq)
##
## Shapiro-Wilk normality test
##
## data: pollen$sq
## W = 0.9442, p-value < 2.2e-16
shapiro.test(pollen$box)
##
## Shapiro-Wilk normality test
##
## data: pollen$box
## W = 0.9588, p-value = 2.044e-15
ggplot(pollen, aes(x = box, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.01, 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)")

p1 <- aov(box ~ treatment + count + bees_alive + replicate, data = pollen )
drop1(p1, test = "Chisq")
## Single term deletions
##
## Model:
## box ~ treatment + count + bees_alive + replicate
## Df Sum of Sq RSS AIC Pr(>Chi)
## <none> 2.5081 -5402.5
## treatment 4 0.08144 2.5895 -5381.1 6.492e-06 ***
## count 1 0.61649 3.1246 -5202.3 < 2.2e-16 ***
## bees_alive 1 0.24627 2.7543 -5318.3 < 2.2e-16 ***
## replicate 8 0.53402 3.0421 -5240.9 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(p1)
## Df Sum Sq Mean Sq F value Pr(>F)
## treatment 4 0.0735 0.0184 6.631 2.92e-05 ***
## count 1 0.3695 0.3695 133.326 < 2e-16 ***
## bees_alive 1 0.1899 0.1899 68.517 4.49e-16 ***
## replicate 8 0.5340 0.0668 24.087 < 2e-16 ***
## Residuals 905 2.5081 0.0028
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(p1)




tuk <- glht(p1, linfct = mcp(treatment = "Tukey"))
tukcld <- cld(tuk)
tukcld
## 1 2 3 4 5
## "a" "b" "b" "b" "a"
p3 <- lmer(difference ~ treatment + count + bees_alive + replicate + (1|colony), data = pollen)
plot(p3)

qqnorm(resid(p3));qqline(resid(p3))

Anova(p3)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: difference
## Chisq Df Pr(>Chisq)
## treatment 2.7066 4 0.6081
## count 184.5733 1 < 2.2e-16 ***
## bees_alive 24.7960 1 6.373e-07 ***
## replicate 35.7638 8 1.940e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p2 <- lmer(box ~ treatment*count + bees_alive + (1|colony), data = pollen )
plot(p2)

p2
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ treatment * count + bees_alive + (1 | colony)
## Data: pollen
## REML criterion at convergence: -2751.426
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 0.03372
## Residual 0.04850
## Number of obs: 920, groups: colony, 45
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4
## 7.584e-02 1.929e-02 1.120e-02 1.882e-02
## treatment5 count bees_alive treatment2:count
## -7.211e-03 4.071e-03 1.425e-02 -1.455e-04
## treatment3:count treatment4:count treatment5:count
## 5.332e-04 -3.714e-05 4.675e-04
summary(p2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ treatment * count + bees_alive + (1 | colony)
## Data: pollen
##
## REML criterion at convergence: -2751.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5872 -0.6298 0.0038 0.6769 2.9954
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 0.001137 0.03372
## Residual 0.002352 0.04850
## Number of obs: 920, groups: colony, 45
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 7.584e-02 2.365e-02 3.207
## treatment2 1.929e-02 1.930e-02 1.000
## treatment3 1.120e-02 1.919e-02 0.584
## treatment4 1.882e-02 1.936e-02 0.972
## treatment5 -7.211e-03 1.922e-02 -0.375
## count 4.071e-03 5.512e-04 7.387
## bees_alive 1.425e-02 3.768e-03 3.782
## treatment2:count -1.455e-04 8.168e-04 -0.178
## treatment3:count 5.332e-04 7.759e-04 0.687
## treatment4:count -3.714e-05 8.087e-04 -0.046
## treatment5:count 4.676e-04 7.955e-04 0.588
##
## Correlation of Fixed Effects:
## (Intr) trtmn2 trtmn3 trtmn4 trtmn5 count bes_lv trtm2: trtm3:
## treatment2 -0.401
## treatment3 -0.414 0.492
## treatment4 -0.452 0.488 0.492
## treatment5 -0.421 0.492 0.495 0.492
## count -0.479 0.332 0.337 0.347 0.339
## bees_alive -0.821 0.002 0.014 0.066 0.024 0.254
## trtmnt2:cnt 0.229 -0.502 -0.226 -0.227 -0.226 -0.646 -0.057
## trtmnt3:cnt 0.278 -0.236 -0.495 -0.242 -0.239 -0.691 -0.104 0.454
## trtmnt4:cnt 0.243 -0.226 -0.228 -0.507 -0.229 -0.656 -0.071 0.434 0.460
## trtmnt5:cnt 0.294 -0.230 -0.233 -0.237 -0.492 -0.681 -0.129 0.445 0.474
## trtm4:
## treatment2
## treatment3
## treatment4
## treatment5
## count
## bees_alive
## trtmnt2:cnt
## trtmnt3:cnt
## trtmnt4:cnt
## trtmnt5:cnt 0.451
Anova(p2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: box
## Chisq Df Pr(>Chisq)
## treatment 3.0609 4 0.5476799
## count 246.6972 1 < 2.2e-16 ***
## bees_alive 14.3030 1 0.0001556 ***
## treatment:count 1.1537 4 0.8856630
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AP <- setDT(as.data.frame(Anova(p2)))
AP
## Chisq Df Pr(>Chisq)
## 1: 3.060938 4 5.476799e-01
## 2: 246.697184 1 1.363020e-55
## 3: 14.302979 1 1.556184e-04
## 4: 1.153689 4 8.856630e-01
qqnorm(resid(p2));qqline(resid(p2))

drop1(p2, test = "Chisq")
## Single term deletions
##
## Model:
## box ~ treatment * count + bees_alive + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -2835.7
## bees_alive 1 -2823.0 14.6401 0.0001301 ***
## treatment:count 4 -2842.5 1.1425 0.8874664
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pe <- emmeans(p2, pairwise ~ treatment, type = "response")
pe
## $emmeans
## treatment emmean SE df lower.CL upper.CL
## 1 0.193 0.0118 39.3 0.169 0.217
## 2 0.211 0.0118 39.9 0.187 0.235
## 3 0.211 0.0118 39.5 0.187 0.235
## 4 0.212 0.0119 40.3 0.188 0.236
## 5 0.192 0.0119 40.4 0.168 0.216
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## treatment1 - treatment2 -0.017520 0.0167 39.6 -1.050 0.8305
## treatment1 - treatment3 -0.017681 0.0167 39.4 -1.061 0.8253
## treatment1 - treatment4 -0.018370 0.0167 39.6 -1.100 0.8052
## treatment1 - treatment5 0.001528 0.0167 39.9 0.091 1.0000
## treatment2 - treatment3 -0.000161 0.0167 39.6 -0.010 1.0000
## treatment2 - treatment4 -0.000849 0.0168 40.2 -0.051 1.0000
## treatment2 - treatment5 0.019049 0.0167 40.1 1.138 0.7856
## treatment3 - treatment4 -0.000688 0.0167 40.1 -0.041 1.0000
## treatment3 - treatment5 0.019210 0.0167 39.8 1.149 0.7796
## treatment4 - treatment5 0.019898 0.0168 40.6 1.184 0.7601
##
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 5 estimates
pecld <- cld(object = pe,
adjust = "TUkey",
alpha = 0.05,
Letters = letters)
pecld
## treatment emmean SE df lower.CL upper.CL .group
## 5 0.192 0.0119 40.4 0.160 0.224 a
## 1 0.193 0.0118 39.3 0.162 0.225 a
## 2 0.211 0.0118 39.9 0.179 0.243 a
## 3 0.211 0.0118 39.5 0.179 0.243 a
## 4 0.212 0.0119 40.3 0.180 0.244 a
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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 <- pollen %>%
group_by(treatment) %>%
summarise(mean = mean(difference),
sd = sd(difference),
n = length(difference)) %>%
mutate(se = sd/sqrt(n))
sum$plot <- sum$mean + sum$se
sum
## # A tibble: 5 × 6
## treatment mean sd n se plot
## <fct> <dbl> <dbl> <int> <dbl> <dbl>
## 1 1 0.430 0.336 195 0.0240 0.454
## 2 2 0.502 0.348 180 0.0259 0.528
## 3 3 0.508 0.345 190 0.0250 0.533
## 4 4 0.488 0.342 178 0.0256 0.514
## 5 5 0.435 0.316 177 0.0238 0.458
sumdt <- setDT(as.data.frame(sum))
sumdt
## treatment mean sd n se plot
## 1: 1 0.4295408 0.3355322 195 0.02402796 0.4535687
## 2: 2 0.5016397 0.3475493 180 0.02590480 0.5275445
## 3: 3 0.5076188 0.3448961 190 0.02502139 0.5326402
## 4: 4 0.4880310 0.3416825 178 0.02561019 0.5136412
## 5: 5 0.4345232 0.3164491 177 0.02378577 0.4583089
emp <- emmeans(p2, pairwise ~ "treatment")
empdt <- setDT(as.data.frame(emp$emmeans))
ecpdt <- setDT(as.data.frame(emp$contrasts))
empdt
## treatment emmean SE df lower.CL upper.CL
## 1: 1 0.1932923 0.01177477 39.25663 0.1694806 0.2171041
## 2: 2 0.2108128 0.01181844 39.84801 0.1869240 0.2347016
## 3: 3 0.2109737 0.01179208 39.47997 0.1871313 0.2348162
## 4: 4 0.2116621 0.01185056 40.26260 0.1877161 0.2356081
## 5: 5 0.1917638 0.01187107 40.43920 0.1677796 0.2157480
ecpdt
## contrast estimate SE df t.ratio
## 1: treatment1 - treatment2 -0.0175204529 0.01668726 39.58739 -1.049929748
## 2: treatment1 - treatment3 -0.0176814309 0.01667131 39.42441 -1.060590169
## 3: treatment1 - treatment4 -0.0183697977 0.01669282 39.64919 -1.100461250
## 4: treatment1 - treatment5 0.0015284838 0.01672841 39.91434 0.091370562
## 5: treatment2 - treatment3 -0.0001609780 0.01668763 39.59994 -0.009646548
## 6: treatment2 - treatment4 -0.0008493449 0.01675036 40.17884 -0.050706079
## 7: treatment2 - treatment5 0.0190489367 0.01674232 40.06600 1.137771354
## 8: treatment3 - treatment4 -0.0006883669 0.01674047 40.06600 -0.041119928
## 9: treatment3 - treatment5 0.0192099147 0.01671822 39.83645 1.149040565
## 10: treatment4 - treatment5 0.0198982815 0.01679982 40.58776 1.184434406
## p.value
## 1: 0.8304574
## 2: 0.8252618
## 3: 0.8052310
## 4: 0.9999835
## 5: 1.0000000
## 6: 0.9999984
## 7: 0.7856426
## 8: 0.9999993
## 9: 0.7795688
## 10: 0.7600889
ggplot(data = sum, aes(x=treatment, y = mean, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0, 0.58)) +
scale_fill_viridis_d() +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
labs(title = "Average Pollen Consumption per Treatment", x = "Treatment", y = "Mean Pollen Consumed (g)") +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(sum$plot + 0.05),
label = c("a", "a", "a", "a", "a"),
size = 8 # Adjust the size of the annotation text as needed
) +
theme_classic(base_size = 20) +
theme(legend.position = "none") +
annotate(geom = "text",
x = 1, y = 0.58,
label = "P > 0.05",
size = 10)

Whole Mean
wm1 <- glm(whole.mean ~ treatment + alive + replicate + brood_cells + drones, data = brood)
summary(wm1)
##
## Call:
## glm(formula = whole.mean ~ treatment + alive + replicate + brood_cells +
## drones, data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.168002 -0.028726 -0.005817 0.032292 0.156129
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1560337 0.0505439 3.087 0.00442 **
## treatment2 0.0331195 0.0326879 1.013 0.31934
## treatment3 0.0114362 0.0362968 0.315 0.75496
## treatment4 0.0106155 0.0319558 0.332 0.74213
## treatment5 0.0004372 0.0331180 0.013 0.98956
## alive 0.0063722 0.0096655 0.659 0.51492
## replicate2 -0.0671698 0.0450969 -1.489 0.14716
## replicate3 0.0428798 0.0435337 0.985 0.33278
## replicate4 0.0135469 0.0486152 0.279 0.78249
## replicate5 0.0746653 0.0470832 1.586 0.12363
## replicate7 0.0207619 0.0432419 0.480 0.63473
## replicate9 0.0070622 0.0433163 0.163 0.87162
## replicate11 -0.0228053 0.0440746 -0.517 0.60878
## replicate12 -0.0275425 0.0456598 -0.603 0.55106
## brood_cells 0.0058210 0.0009147 6.364 5.91e-07 ***
## drones 0.0075695 0.0026053 2.905 0.00695 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.004469417)
##
## Null deviance: 1.45979 on 44 degrees of freedom
## Residual deviance: 0.12961 on 29 degrees of freedom
## AIC: -101.54
##
## Number of Fisher Scoring iterations: 2
drop1(wm1, test = "Chisq")
## Single term deletions
##
## Model:
## whole.mean ~ treatment + alive + replicate + brood_cells + drones
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 0.12961 -101.539
## treatment 4 0.13580 -107.441 2.099 0.7176158
## alive 1 0.13156 -102.870 0.669 0.4132482
## replicate 8 0.18642 -101.184 16.355 0.0375664 *
## brood_cells 1 0.31060 -64.212 39.328 3.583e-10 ***
## drones 1 0.16734 -92.043 11.497 0.0006972 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(wm1)
## Analysis of Deviance Table (Type II tests)
##
## Response: whole.mean
## LR Chisq Df Pr(>Chisq)
## treatment 1.385 4 0.846882
## alive 0.435 1 0.509721
## replicate 12.710 8 0.122211
## brood_cells 40.495 1 1.972e-10 ***
## drones 8.441 1 0.003668 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Workers
Dry Weight
ggplot(workers, aes(x = dry_weight, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.002, col = I("black")) +
scale_fill_viridis_d() + # Use viridis_d() for the color-blind friendly palette
ggtitle("Worker Dry Weight(g)") +
labs(y = "Count", x = "Weight (g)")

shapiro.test(workers$dry_weight)
##
## Shapiro-Wilk normality test
##
## data: workers$dry_weight
## W = 0.906, p-value = 1.153e-10
workers$logdry <- log(workers$dry_weight)
shapiro.test(workers$logdry)
##
## Shapiro-Wilk normality test
##
## data: workers$logdry
## W = 0.98708, p-value = 0.04033
ggplot(workers, aes(x = logdry, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.05, col = I("black")) +
scale_fill_viridis_d() + # Use viridis_d() for the color-blind friendly palette
ggtitle("Worker Dry Weight(g)") +
labs(y = "Count", x = "Weight (g)")

wrkdry.int <- lmer(logdry ~ treatment*whole.mean + alive_at_end + colony_duration + days_alive + (1|colony), data = workers)
wrkdry1 <- lmer(logdry ~ treatment + whole.mean + alive_at_end + colony_duration + days_alive + (1|colony), data = workers)
anova(wrkdry.int, wrkdry1)
## Data: workers
## Models:
## wrkdry1: logdry ~ treatment + whole.mean + alive_at_end + colony_duration + days_alive + (1 | colony)
## wrkdry.int: logdry ~ treatment * whole.mean + alive_at_end + colony_duration + days_alive + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## wrkdry1 11 155.32 192.85 -66.662 133.32
## wrkdry.int 15 161.28 212.45 -65.640 131.28 2.0438 4 0.7277
drop1(wrkdry1, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ treatment + whole.mean + alive_at_end + colony_duration +
## days_alive + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 155.32
## treatment 4 149.92 2.596 0.6275
## whole.mean 1 185.17 31.842 1.672e-08 ***
## alive_at_end 1 153.44 0.118 0.7312
## colony_duration 1 154.08 0.754 0.3851
## days_alive 1 153.32 0.001 0.9796
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wd1 <- update(wrkdry1, .~. -alive_at_end)
drop1(wd1, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ treatment + whole.mean + colony_duration + days_alive +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 153.44
## treatment 4 148.03 2.584 0.6296
## whole.mean 1 186.67 35.232 2.926e-09 ***
## colony_duration 1 152.12 0.677 0.4106
## days_alive 1 151.51 0.066 0.7966
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wd2 <- update(wd1, .~. -days_alive)
drop1(wd1, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ treatment + whole.mean + colony_duration + days_alive +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 153.44
## treatment 4 148.03 2.584 0.6296
## whole.mean 1 186.67 35.232 2.926e-09 ***
## colony_duration 1 152.12 0.677 0.4106
## days_alive 1 151.51 0.066 0.7966
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wd3 <- update(wd2, .~. -colony_duration)
drop1(wd3, test = "Chisq")
## Single term deletions
##
## Model:
## logdry ~ treatment + whole.mean + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 151.81
## treatment 4 146.06 2.247 0.6903
## whole.mean 1 188.94 39.135 3.955e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wd3
## Linear mixed model fit by REML ['lmerMod']
## Formula: logdry ~ treatment + whole.mean + (1 | colony)
## Data: workers
## REML criterion at convergence: 157.7482
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 0.09229
## Residual 0.32110
## Number of obs: 224, groups: colony, 45
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## -3.61018 -0.06123 -0.01718 -0.02813 0.04931 1.05864
Anova(wd3)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: logdry
## Chisq Df Pr(>Chisq)
## treatment 1.9987 4 0.736
## whole.mean 54.1859 1 1.824e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wa <- setDT(as.data.frame(((Anova(wd3)))))
wa
## Chisq Df Pr(>Chisq)
## 1: 1.998704 4 7.359973e-01
## 2: 54.185905 1 1.823905e-13
workdry <- workers %>%
group_by(treatment) %>%
summarise(a.m= mean(dry_weight),
sd.a = sd(dry_weight),
n.a = length(dry_weight)) %>%
mutate(sea = sd.a / sqrt(n.a))
workdry <- setDT(workdry)
workdry
## treatment a.m sd.a n.a sea
## 1: 1 0.04741244 0.02047277 45 0.003051901
## 2: 2 0.04555133 0.01594982 45 0.002377659
## 3: 3 0.04992178 0.02039617 45 0.003040482
## 4: 4 0.04874068 0.02274766 44 0.003429339
## 5: 5 0.04778982 0.01760140 45 0.002623861
workdryem <- emmeans(wmod3, ~treatment, type = "response")
workdryem
## treatment emmean SE df lower.CL upper.CL
## 1 9.08 0.971 39 7.12 11.0
## 2 10.57 0.969 39 8.61 12.5
## 3 12.16 0.973 39 10.19 14.1
## 4 11.39 0.969 39 9.43 13.3
## 5 10.52 0.975 39 8.55 12.5
##
## Confidence level used: 0.95
wp <- as.data.frame(pairs(workdryem))
wp <- setDT(wp)
wp
## contrast estimate SE df t.ratio p.value
## 1: treatment1 - treatment2 -1.48367801 1.374540 39 -1.07939953 0.8159169
## 2: treatment1 - treatment3 -3.07899331 1.380509 39 -2.23033139 0.1901671
## 3: treatment1 - treatment4 -2.30634802 1.374573 39 -1.67786469 0.4589569
## 4: treatment1 - treatment5 -1.44181836 1.369577 39 -1.05274751 0.8290717
## 5: treatment2 - treatment3 -1.59531530 1.370112 39 -1.16436888 0.7711973
## 6: treatment2 - treatment4 -0.82267002 1.369020 39 -0.60091875 0.9741158
## 7: treatment2 - treatment5 0.04185964 1.378583 39 0.03036426 0.9999998
## 8: treatment3 - treatment4 0.77264528 1.370097 39 0.56393478 0.9794900
## 9: treatment3 - treatment5 1.63717494 1.386075 39 1.18115899 0.7619078
## 10: treatment4 - treatment5 0.86452966 1.378626 39 0.62709498 0.9697859
wde <- as.data.frame(workdryem)
wde2 <- setDT(wde)
wde2
## treatment emmean SE df lower.CL upper.CL
## 1: 1 9.082055 0.9711042 39 7.117811 11.04630
## 2: 2 10.565733 0.9691369 39 8.605468 12.52600
## 3: 3 12.161048 0.9732666 39 10.192431 14.12967
## 4: 4 11.388403 0.9691545 39 9.428103 13.34870
## 5: 5 10.523873 0.9749772 39 8.551795 12.49595
workcld <- cld(object = workdryem,
adjust = "TUkey",
alpha = 0.05,
Letters = letters)
workcld
## treatment emmean SE df lower.CL upper.CL .group
## 1 9.08 0.971 39 6.46 11.7 a
## 5 10.52 0.975 39 7.89 13.2 a
## 2 10.57 0.969 39 7.95 13.2 a
## 4 11.39 0.969 39 8.77 14.0 a
## 3 12.16 0.973 39 9.53 14.8 a
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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.
emmdf2 <- as.data.frame(workcld)
emmdf2
## treatment emmean SE df lower.CL upper.CL .group
## 1 9.082055 0.9711042 39 6.460238 11.70387 a
## 5 10.523873 0.9749772 39 7.891599 13.15615 a
## 2 10.565733 0.9691369 39 7.949227 13.18224 a
## 4 11.388403 0.9691545 39 8.771849 14.00496 a
## 3 12.161048 0.9732666 39 9.533393 14.78870 a
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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.
workdry$plot <- workdry$a.m + workdry$sea
ggplot(data = workdry, aes(x = treatment, y = a.m, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0, 0.06)) +
scale_fill_viridis_d() + # Use viridis_d() for the color-blind friendly palette
geom_errorbar(aes(ymax = a.m + sea, ymin = a.m - sea),
position = position_dodge(2), width = 0.4, size = 1.5) +
labs(y = "Average Worker Dry Weight(g)") +
ggtitle("Average Worker Dry Weight(g) by Treatment") +
scale_x_discrete(
name = "Treatment",
labels = c("0 PPB", "150 PPB", "1,500 PPB", "15,000 PPB", "150,000 PPB")
) +
theme_classic(base_size = 30) + # Adjust the base_size as needed
annotate(
geom = "text",
x = 1, y = 0.06,
label = " p = 0.74",
size = 15 # Adjust the size of the annotation text as needed
) +
annotate(
geom = "text",
x = c(1, 5, 2, 4, 3),
y = c(0.055, 0.055, 0.054, 0.057, 0.056),
label = c("a", "a", "a", "a", "a"),
size = 20 # Adjust the size of the annotation text as needed
) +
theme(legend.position = "none")

ggplot(workers, aes(x = whole.mean, y = dry_weight, color = treatment)) +
geom_point(size = 5)+
ggtitle("Amount of Pollen Consumed vs. Average Worker Dry Weight")+
xlab("Mean Polen Consumption(g)") +
ylab("Mean Dry Weight(g)") +
scale_fill_viridis_d() +
theme(text = element_text(size = 20)) +
geom_smooth(method = "lm", color = "black")

Worker Survival
Days Alive
workers$survived <- as.logical(workers$survived)
wrkdays1 <- lmer(days_alive ~ treatment + whole.mean + colony_duration + replicate + dry_weight + (1|colony), data = workers)
drop1(wrkdays1, test = "Chisq")
## Single term deletions
##
## Model:
## days_alive ~ treatment + whole.mean + colony_duration + replicate +
## dry_weight + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1408.8
## treatment 4 1409.8 8.968 0.0619080 .
## whole.mean 1 1417.8 11.022 0.0009005 ***
## colony_duration 1 1457.8 51.014 9.171e-13 ***
## replicate 8 1418.6 25.779 0.0011459 **
## dry_weight 1 1407.1 0.324 0.5693793
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wd2 <- update(wrkdays1, .~. -dry_weight)
drop1(wd2, test = "Chisq")
## Single term deletions
##
## Model:
## days_alive ~ treatment + whole.mean + colony_duration + replicate +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1407.1
## treatment 4 1408.1 9.006 0.0609542 .
## whole.mean 1 1419.5 14.414 0.0001467 ***
## colony_duration 1 1456.0 50.900 9.721e-13 ***
## replicate 8 1416.6 25.457 0.0013001 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(wd2));qqline(resid(wd2))

wd2
## Linear mixed model fit by REML ['lmerMod']
## Formula: days_alive ~ treatment + whole.mean + colony_duration + replicate +
## (1 | colony)
## Data: workers
## REML criterion at convergence: 1346.341
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 1.625
## Residual 5.196
## Number of obs: 224, groups: colony, 45
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4
## -7.4379 1.4261 1.0134 -0.5655
## treatment5 whole.mean colony_duration replicate2
## 2.4923 10.4889 1.0263 -0.1383
## replicate3 replicate4 replicate5 replicate7
## 0.3587 -3.5815 -5.1032 -1.0568
## replicate9 replicate11 replicate12
## 0.5789 1.5052 -2.6992
Anova(wd2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: days_alive
## Chisq Df Pr(>Chisq)
## treatment 6.3918 4 0.1717385
## whole.mean 11.1579 1 0.0008367 ***
## colony_duration 135.4327 1 < 2.2e-16 ***
## replicate 22.2021 8 0.0045549 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
cbind workers
cbw1 <- glm(cbind(alive, dead) ~ treatment + whole.mean + qro + duration, data = cbindworkers, family = binomial("logit"))
cbw2 <- glm(cbind(alive, dead) ~ treatment + whole.mean + replicate + duration, data = cbindworkers, family = binomial("logit"))
anova(cbw1, cbw2, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: cbind(alive, dead) ~ treatment + whole.mean + qro + duration
## Model 2: cbind(alive, dead) ~ treatment + whole.mean + replicate + duration
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 35 55.296
## 2 30 32.655 5 22.641 0.0003953 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(cbw1, cbw2)
## df AIC
## cbw1 10 98.07714
## cbw2 15 85.43635
drop1(cbw1, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(alive, dead) ~ treatment + whole.mean + qro + duration
## Df Deviance AIC LRT Pr(>Chi)
## <none> 55.296 98.077
## treatment 4 75.837 110.618 20.541 0.0003904 ***
## whole.mean 1 106.167 146.948 50.871 9.865e-13 ***
## qro 3 100.520 137.301 45.224 8.291e-10 ***
## duration 1 72.405 113.186 17.108 3.531e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(cbw1)




plot(cbw2)




cbw1
##
## Call: glm(formula = cbind(alive, dead) ~ treatment + whole.mean + qro +
## duration, family = binomial("logit"), data = cbindworkers)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 4.9227 1.7801 3.1766 0.6824 3.0456 11.3968
## qroB3 qroB4 qroB5 duration
## -1.1338 -5.8092 -3.3144 -0.1758
##
## Degrees of Freedom: 44 Total (i.e. Null); 35 Residual
## Null Deviance: 143.7
## Residual Deviance: 55.3 AIC: 98.08
Anova(cbw1)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(alive, dead)
## LR Chisq Df Pr(>Chisq)
## treatment 20.541 4 0.0003904 ***
## whole.mean 50.871 1 9.865e-13 ***
## qro 45.224 3 8.291e-10 ***
## duration 17.108 1 3.531e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
acw <- setDT(as.data.frame(Anova(cbw1)))
acw
## LR Chisq Df Pr(>Chisq)
## 1: 20.54104 4 3.904029e-04
## 2: 50.87087 1 9.864667e-13
## 3: 45.22428 3 8.290881e-10
## 4: 17.10837 1 3.530640e-05
emm1 <- emmeans(cbw1, pairwise ~ treatment, type = "response")
pairs(emm1)
## contrast odds.ratio SE df null z.ratio p.value
## treatment1 / treatment2 0.1686 0.1255 Inf 1 -2.391 0.1176
## treatment1 / treatment3 0.0417 0.0405 Inf 1 -3.272 0.0094
## treatment1 / treatment4 0.5054 0.3493 Inf 1 -0.987 0.8612
## treatment1 / treatment5 0.0476 0.0433 Inf 1 -3.345 0.0074
## treatment2 / treatment3 0.2475 0.2213 Inf 1 -1.562 0.5221
## treatment2 / treatment4 2.9973 2.5498 Inf 1 1.290 0.6972
## treatment2 / treatment5 0.2821 0.2340 Inf 1 -1.526 0.5457
## treatment3 / treatment4 12.1119 12.6742 Inf 1 2.384 0.1197
## treatment3 / treatment5 1.1400 1.0911 Inf 1 0.137 0.9999
## treatment4 / treatment5 0.0941 0.0938 Inf 1 -2.371 0.1233
##
## Results are averaged over the levels of: qro
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio scale
emm1
## $emmeans
## treatment prob SE df asymp.LCL asymp.UCL
## 1 0.569 0.1039 Inf 0.365 0.752
## 2 0.887 0.0591 Inf 0.712 0.961
## 3 0.969 0.0251 Inf 0.858 0.994
## 4 0.723 0.1275 Inf 0.428 0.901
## 5 0.965 0.0251 Inf 0.865 0.992
##
## Results are averaged over the levels of: qro
## 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 0.1686 0.1255 Inf 1 -2.391 0.1176
## treatment1 / treatment3 0.0417 0.0405 Inf 1 -3.272 0.0094
## treatment1 / treatment4 0.5054 0.3493 Inf 1 -0.987 0.8612
## treatment1 / treatment5 0.0476 0.0433 Inf 1 -3.345 0.0074
## treatment2 / treatment3 0.2475 0.2213 Inf 1 -1.562 0.5221
## treatment2 / treatment4 2.9973 2.5498 Inf 1 1.290 0.6972
## treatment2 / treatment5 0.2821 0.2340 Inf 1 -1.526 0.5457
## treatment3 / treatment4 12.1119 12.6742 Inf 1 2.384 0.1197
## treatment3 / treatment5 1.1400 1.0911 Inf 1 0.137 0.9999
## treatment4 / treatment5 0.0941 0.0938 Inf 1 -2.371 0.1233
##
## Results are averaged over the levels of: qro
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio scale
emmdf <- as.data.frame(emm1$contrasts)
emmdf
## contrast odds.ratio SE df null z.ratio p.value
## treatment1 / treatment2 0.168615 0.125511 Inf 1 -2.391 0.1176
## treatment1 / treatment3 0.041727 0.040505 Inf 1 -3.272 0.0094
## treatment1 / treatment4 0.505393 0.349343 Inf 1 -0.987 0.8612
## treatment1 / treatment5 0.047569 0.043314 Inf 1 -3.345 0.0074
## treatment2 / treatment3 0.247469 0.221268 Inf 1 -1.562 0.5221
## treatment2 / treatment4 2.997324 2.549782 Inf 1 1.290 0.6972
## treatment2 / treatment5 0.282117 0.234013 Inf 1 -1.526 0.5457
## treatment3 / treatment4 12.111902 12.674160 Inf 1 2.384 0.1197
## treatment3 / treatment5 1.140009 1.091140 Inf 1 0.137 0.9999
## treatment4 / treatment5 0.094123 0.093819 Inf 1 -2.371 0.1233
##
## Results are averaged over the levels of: qro
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio scale
workcld <- cld(object = emm1,
adjust = "Tukey",
alpha = 0.05,
Letters = letters)
workcld
## treatment prob SE df asymp.LCL asymp.UCL .group
## 1 0.569 0.1039 Inf 0.308 0.797 a
## 4 0.723 0.1275 Inf 0.337 0.931 ab
## 2 0.887 0.0591 Inf 0.634 0.973 ab
## 5 0.965 0.0251 Inf 0.803 0.995 b
## 3 0.969 0.0251 Inf 0.783 0.996 b
##
## Results are averaged over the levels of: qro
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the logit scale
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio 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.
workcld <- as.data.frame(workcld)
workcld$plot <- workcld$prob + workcld$asymp.UCL
workcld
## treatment prob SE df asymp.LCL asymp.UCL .group plot
## 1 0.5688864 0.10394405 Inf 0.3075951 0.7967339 a 1.365620
## 4 0.7230672 0.12747855 Inf 0.3372412 0.9305434 ab 1.653611
## 2 0.8866979 0.05905240 Inf 0.6335663 0.9725444 ab 1.859242
## 5 0.9652054 0.02508011 Inf 0.8029056 0.9947340 b 1.959939
## 3 0.9693477 0.02510820 Inf 0.7829991 0.9964050 b 1.965753
##
## Results are averaged over the levels of: qro
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the logit scale
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio 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.
ggplot(data = workcld, aes(x=treatment, y=prob, fill=treatment)) +
geom_col(position = "dodge", color = "black") +
geom_errorbar(aes(ymin = prob - SE, ymax = prob + SE), width = 0.2, position = position_dodge(0.9)) +
coord_cartesian(ylim = c(0,1.3)) +
labs(x = "Treatment", y = "Probability of Survival", title ="Probability of Worker Survival for Duration of Experiment") +
theme(text = element_text(size = 20)) +
annotate(geom = "text",
x = 1, y = 1.2,
label = "P < 0.001",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(0.75, 1.1, 1.1, 1, 1.1),
label = c("a", "ab", "b", "ab", "b"),
size = 8) +
theme(legend.position = "none")

Brood Production
#Variables to keep = duration, treatment, whole mean, number alive, block, and qro
brood1 <- glm.nb(brood_cells ~ treatment + whole.mean + alive + duration, data = brood)
brood2 <- glm.nb(brood_cells ~ treatment + whole.mean + alive + duration + replicate, data = brood)
## Warning in glm.nb(brood_cells ~ treatment + whole.mean + alive + duration + :
## alternation limit reached
emmeans(brood1, pairwise ~ treatment)
## $emmeans
## treatment emmean SE df asymp.LCL asymp.UCL
## 1 3.43 0.1063 Inf 3.23 3.64
## 2 3.54 0.0991 Inf 3.34 3.73
## 3 3.53 0.0986 Inf 3.33 3.72
## 4 3.41 0.1018 Inf 3.21 3.61
## 5 3.36 0.1061 Inf 3.16 3.57
##
## 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 -0.1039 0.148 Inf -0.702 0.9561
## treatment1 - treatment3 -0.0918 0.146 Inf -0.629 0.9705
## treatment1 - treatment4 0.0237 0.145 Inf 0.163 0.9998
## treatment1 - treatment5 0.0709 0.154 Inf 0.461 0.9907
## treatment2 - treatment3 0.0121 0.138 Inf 0.088 1.0000
## treatment2 - treatment4 0.1275 0.142 Inf 0.896 0.8985
## treatment2 - treatment5 0.1748 0.144 Inf 1.218 0.7411
## treatment3 - treatment4 0.1154 0.140 Inf 0.825 0.9230
## treatment3 - treatment5 0.1626 0.143 Inf 1.134 0.7885
## treatment4 - treatment5 0.0472 0.149 Inf 0.318 0.9978
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 5 estimates
brood2 <- glm(brood_cells ~ treatment + whole.mean + alive + duration + replicate + qro, data = brood, family = "poisson") #overdispersed
summary(brood2)
##
## Call:
## glm(formula = brood_cells ~ treatment + whole.mean + alive +
## duration + replicate + qro, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -4.0227 -0.9214 0.0736 0.9484 2.3573
##
## Coefficients: (3 not defined because of singularities)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 2.274381 0.204357 11.129 <2e-16 ***
## treatment2 0.039510 0.084349 0.468 0.6395
## treatment3 0.111859 0.079845 1.401 0.1612
## treatment4 -0.109472 0.084192 -1.300 0.1935
## treatment5 -0.091775 0.092613 -0.991 0.3217
## whole.mean 2.609927 0.258741 10.087 <2e-16 ***
## alive 0.077260 0.030415 2.540 0.0111 *
## duration -0.007328 0.004152 -1.765 0.0776 .
## replicate2 0.162040 0.108199 1.498 0.1342
## replicate3 -0.280237 0.111674 -2.509 0.0121 *
## replicate4 0.081276 0.112527 0.722 0.4701
## replicate5 -0.183881 0.117754 -1.562 0.1184
## replicate7 -0.069792 0.104045 -0.671 0.5024
## replicate9 -0.079930 0.108805 -0.735 0.4626
## replicate11 -0.012759 0.117027 -0.109 0.9132
## replicate12 -0.200823 0.140230 -1.432 0.1521
## qroB3 NA NA NA NA
## qroB4 NA NA NA NA
## qroB5 NA NA NA NA
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 526.03 on 44 degrees of freedom
## Residual deviance: 109.62 on 29 degrees of freedom
## AIC: 373.46
##
## Number of Fisher Scoring iterations: 5
drop1(brood1, test = "Chisq")
## Single term deletions
##
## Model:
## brood_cells ~ treatment + whole.mean + alive + duration
## Df Deviance AIC LRT Pr(>Chi)
## <none> 60.842 356.16
## treatment 4 63.101 350.42 2.258 0.688397
## whole.mean 1 160.948 454.27 100.105 < 2.2e-16 ***
## alive 1 67.616 360.93 6.773 0.009253 **
## duration 1 63.907 357.22 3.064 0.080034 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
brood4 <- glm.nb(brood_cells ~ treatment*whole.mean + alive + duration, data = brood)
anova(brood1, brood4, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: brood_cells
## Model theta Resid. df 2 x log-lik.
## 1 treatment + whole.mean + alive + duration 17.62812 37 -340.1606
## 2 treatment * whole.mean + alive + duration 19.92861 33 -333.6440
## Test df LR stat. Pr(Chi)
## 1
## 2 1 vs 2 4 6.516653 0.1637441
AIC(brood1, brood4)
## df AIC
## brood1 9 358.1606
## brood4 13 359.6440
drop1(brood1, test = "Chisq")
## Single term deletions
##
## Model:
## brood_cells ~ treatment + whole.mean + alive + duration
## Df Deviance AIC LRT Pr(>Chi)
## <none> 60.842 356.16
## treatment 4 63.101 350.42 2.258 0.688397
## whole.mean 1 160.948 454.27 100.105 < 2.2e-16 ***
## alive 1 67.616 360.93 6.773 0.009253 **
## duration 1 63.907 357.22 3.064 0.080034 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
brood3 <- update(brood1, .~. -duration)
anova(brood1, brood3, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: brood_cells
## Model theta Resid. df 2 x log-lik.
## 1 treatment + whole.mean + alive 16.00719 38 -343.1629
## 2 treatment + whole.mean + alive + duration 17.62812 37 -340.1606
## Test df LR stat. Pr(Chi)
## 1
## 2 1 vs 2 1 3.002336 0.08314454
AIC(brood1, brood3)
## df AIC
## brood1 9 358.1606
## brood3 8 359.1629
ab <- setDT(as.data.frame(Anova(brood3)))
ab
## LR Chisq Df Pr(>Chisq)
## 1: 2.091982 4 7.188455e-01
## 2: 92.661567 1 6.204688e-22
## 3: 8.357010 1 3.842023e-03
Anova(brood3)
## Analysis of Deviance Table (Type II tests)
##
## Response: brood_cells
## LR Chisq Df Pr(>Chisq)
## treatment 2.092 4 0.718846
## whole.mean 92.662 1 < 2.2e-16 ***
## alive 8.357 1 0.003842 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
brood3
##
## Call: glm.nb(formula = brood_cells ~ treatment + whole.mean + alive,
## data = brood, init.theta = 16.00718545, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 1.75174 0.04015 0.06645 -0.04033 -0.12599 2.67494
## alive
## 0.10534
##
## Degrees of Freedom: 44 Total (i.e. Null); 38 Residual
## Null Deviance: 195.5
## Residual Deviance: 61.09 AIC: 359.2
summary(brood3)
##
## Call:
## glm.nb(formula = brood_cells ~ treatment + whole.mean + alive,
## data = brood, init.theta = 16.00718545, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.7761 -0.5725 -0.0396 0.4577 2.0208
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.75174 0.19242 9.104 < 2e-16 ***
## treatment2 0.04015 0.14762 0.272 0.78561
## treatment3 0.06645 0.14891 0.446 0.65541
## treatment4 -0.04033 0.14887 -0.271 0.78647
## treatment5 -0.12599 0.15411 -0.818 0.41360
## whole.mean 2.67494 0.27388 9.767 < 2e-16 ***
## alive 0.10534 0.03729 2.825 0.00473 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(16.0072) family taken to be 1)
##
## Null deviance: 195.494 on 44 degrees of freedom
## Residual deviance: 61.088 on 38 degrees of freedom
## AIC: 359.16
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 16.01
## Std. Err.: 5.89
##
## 2 x log-likelihood: -343.163
emb1 <- emmeans(brood3, "treatment", type = "response")
emb <- setDT(as.data.frame(emb1))
emb
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 32.14020 3.432741 Inf 26.06968 39.62427
## 2: 2 33.45700 3.386669 Inf 27.43624 40.79900
## 3: 3 34.34845 3.502438 Inf 28.12626 41.94714
## 4: 4 30.86983 3.225520 Inf 25.15325 37.88562
## 5: 5 28.33545 3.070770 Inf 22.91309 35.04100
pemb <- pairs(emb1)
pemb <- setDT(as.data.frame(pemb))
pemb
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 0.9606418 0.1418075 Inf 1 -0.2720116 0.9988017
## 2: treatment1 / treatment3 0.9357102 0.1393322 Inf 1 -0.4462529 0.9918070
## 3: treatment1 / treatment4 1.0411524 0.1549990 Inf 1 0.2708909 0.9988210
## 4: treatment1 / treatment5 1.1342752 0.1747998 Inf 1 0.8175732 0.9253307
## 5: treatment2 / treatment3 0.9740470 0.1383405 Inf 1 -0.1851468 0.9997380
## 6: treatment2 / treatment4 1.0838092 0.1567959 Inf 1 0.5563091 0.9811878
## 7: treatment2 / treatment5 1.1807472 0.1745650 Inf 1 1.1238118 0.7940119
## 8: treatment3 / treatment4 1.1126868 0.1605357 Inf 1 0.7400852 0.9470905
## 9: treatment3 / treatment5 1.2122077 0.1788611 Inf 1 1.3042588 0.6885789
## 10: treatment4 / treatment5 1.0894420 0.1648596 Inf 1 0.5661043 0.9799283
brood_sum <- brood %>%
group_by(treatment) %>%
summarise(mb = mean(brood_cells),
nb = length(brood_cells),
sdb = sd(brood_cells)) %>%
mutate(seb = (sdb/sqrt(nb)))
brood_sum
## # A tibble: 5 × 5
## treatment mb nb sdb seb
## <fct> <dbl> <int> <dbl> <dbl>
## 1 1 33.8 9 22.6 7.53
## 2 2 36.9 9 11.2 3.74
## 3 3 45.6 9 26.2 8.73
## 4 4 36.7 9 18.3 6.09
## 5 5 29.6 9 17.5 5.82
bsdt <- setDT(brood_sum)
bsdt
## treatment mb nb sdb seb
## 1: 1 33.77778 9 22.59855 7.532850
## 2: 2 36.88889 9 11.21878 3.739595
## 3: 3 45.55556 9 26.19690 8.732301
## 4: 4 36.66667 9 18.27567 6.091889
## 5: 5 29.55556 9 17.45072 5.816908
plot(brood$treatment, brood$brood_cells)

ggplot(brood, aes(x = treatment, y = brood_cells, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5, outlier.shape = NA) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count of Brood Cells", title = "Count of Brood Cells by Treatment") +
theme_minimal() +
theme(legend.position = "right")

Eggs
e1 <- glm.nb(eggs ~ treatment + whole.mean + alive + duration + replicate, data = brood)
## Warning in glm.nb(eggs ~ treatment + whole.mean + alive + duration + replicate,
## : alternation limit reached
e2 <- glm.nb(eggs ~ treatment*whole.mean + alive + duration + replicate, data = brood)
## Warning: glm.fit: algorithm did not converge
## Warning in glm.nb(eggs ~ treatment * whole.mean + alive + duration + replicate,
## : alternation limit reached
e3 <- glm(eggs~treatment + whole.mean + alive + duration + replicate, data = brood, family = "poisson") #overdispersed
summary(e3)
##
## Call:
## glm(formula = eggs ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -4.5537 -2.2550 -0.5861 1.2984 5.3899
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.894359 0.507357 3.734 0.000189 ***
## treatment2 -0.388560 0.150247 -2.586 0.009706 **
## treatment3 -1.040768 0.199456 -5.218 1.81e-07 ***
## treatment4 -0.784893 0.163062 -4.813 1.48e-06 ***
## treatment5 -1.006576 0.213488 -4.715 2.42e-06 ***
## whole.mean 2.403583 0.593611 4.049 5.14e-05 ***
## alive -0.038265 0.060951 -0.628 0.530139
## duration -0.016010 0.011323 -1.414 0.157373
## replicate2 0.234687 0.270782 0.867 0.386106
## replicate3 0.648496 0.238550 2.718 0.006558 **
## replicate4 0.793796 0.277157 2.864 0.004182 **
## replicate5 1.054106 0.262475 4.016 5.92e-05 ***
## replicate7 -0.829084 0.326095 -2.542 0.011007 *
## replicate9 -0.180211 0.299257 -0.602 0.547044
## replicate11 0.004415 0.313806 0.014 0.988774
## replicate12 -17.311783 865.142466 -0.020 0.984035
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 624.61 on 44 degrees of freedom
## Residual deviance: 251.66 on 29 degrees of freedom
## AIC: 404.05
##
## Number of Fisher Scoring iterations: 14
anova(e1, e2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: eggs
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 1.192160 29
## 2 treatment * whole.mean + alive + duration + replicate 1.315937 25
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -235.0951
## 2 -231.5166 1 vs 2 4 3.578446 0.4660511
AIC(e1, e2)
## df AIC
## e1 17 269.0951
## e2 21 273.5166
drop1(e1, test = "Chisq")
## Single term deletions
##
## Model:
## eggs ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 48.088 267.10
## treatment 4 52.134 263.14 4.0458 0.399840
## whole.mean 1 51.318 268.32 3.2300 0.072303 .
## alive 1 48.127 265.13 0.0386 0.844310
## duration 1 48.505 265.51 0.4169 0.518509
## replicate 8 70.089 273.10 22.0012 0.004914 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
e4 <- update(e1, .~. -duration)
drop1(e4, test = "Chisq")
## Single term deletions
##
## Model:
## eggs ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 48.073 265.51
## treatment 4 52.420 261.86 4.3470 0.361082
## whole.mean 1 50.999 266.44 2.9252 0.087205 .
## alive 1 48.200 263.64 0.1270 0.721554
## replicate 8 69.903 271.34 21.8294 0.005242 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
e5 <- update(e4, .~. -alive)
drop1(e5, test = "Chisq")
## Single term deletions
##
## Model:
## eggs ~ treatment + whole.mean + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 48.236 263.64
## treatment 4 52.463 259.86 4.2268 0.376181
## whole.mean 1 52.985 266.38 4.7488 0.029319 *
## replicate 8 72.558 271.96 24.3217 0.002024 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(e4, e5, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: eggs
## Model theta Resid. df 2 x log-lik.
## 1 treatment + whole.mean + replicate 1.176454 31 -235.6367
## 2 treatment + whole.mean + alive + replicate 1.175057 30 -235.5097
## Test df LR stat. Pr(Chi)
## 1
## 2 1 vs 2 1 0.1269932 0.7215702
summary(e5)
##
## Call:
## glm.nb(formula = eggs ~ treatment + whole.mean + replicate, data = brood,
## init.theta = 1.176453787, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3494 -0.8863 -0.1968 0.1865 1.5841
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.005e+00 7.882e-01 1.275 0.2024
## treatment2 -3.134e-01 4.951e-01 -0.633 0.5268
## treatment3 -1.054e+00 5.178e-01 -2.035 0.0419 *
## treatment4 -6.496e-01 5.045e-01 -1.288 0.1979
## treatment5 -7.712e-01 5.090e-01 -1.515 0.1297
## whole.mean 2.813e+00 1.120e+00 2.511 0.0120 *
## replicate2 -4.899e-02 6.584e-01 -0.074 0.9407
## replicate3 2.015e-01 6.370e-01 0.316 0.7517
## replicate4 8.315e-01 6.236e-01 1.333 0.1824
## replicate5 5.359e-01 6.424e-01 0.834 0.4042
## replicate7 -8.671e-01 6.651e-01 -1.304 0.1923
## replicate9 -4.226e-01 6.646e-01 -0.636 0.5248
## replicate11 -3.532e-01 6.845e-01 -0.516 0.6059
## replicate12 -2.902e+01 2.843e+05 0.000 0.9999
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(1.1765) family taken to be 1)
##
## Null deviance: 101.645 on 44 degrees of freedom
## Residual deviance: 48.236 on 31 degrees of freedom
## AIC: 265.64
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 1.176
## Std. Err.: 0.361
##
## 2 x log-likelihood: -235.637
e5
##
## Call: glm.nb(formula = eggs ~ treatment + whole.mean + replicate, data = brood,
## init.theta = 1.176453787, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 1.00464 -0.31336 -1.05374 -0.64957 -0.77117 2.81308
## replicate2 replicate3 replicate4 replicate5 replicate7 replicate9
## -0.04899 0.20151 0.83148 0.53588 -0.86709 -0.42264
## replicate11 replicate12
## -0.35318 -29.01904
##
## Degrees of Freedom: 44 Total (i.e. Null); 31 Residual
## Null Deviance: 101.6
## Residual Deviance: 48.24 AIC: 265.6
ea <- setDT(as.data.frame(Anova(e5)))
ea
## LR Chisq Df Pr(>Chisq)
## 1: 4.226801 4 0.376180930
## 2: 4.748774 1 0.029319182
## 3: 24.321709 8 0.002023676
em <- emmeans(e5, pairwise ~ "treatment", type = "response")
emc <- setDT(as.data.frame(em$contrasts))
emc
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 1.3680194 0.6773142 Inf 1 0.6329234 0.9697591
## 2: treatment1 / treatment3 2.8683698 1.4852865 Inf 1 2.0349791 0.2491906
## 3: treatment1 / treatment4 1.9147148 0.9659637 Inf 1 1.2875626 0.6989347
## 4: treatment1 / treatment5 2.1623017 1.1004965 Inf 1 1.5152336 0.5524816
## 5: treatment2 / treatment3 2.0967318 1.0836294 Inf 1 1.4325728 0.6065132
## 6: treatment2 / treatment4 1.3996255 0.7058982 Inf 1 0.6666126 0.9635174
## 7: treatment2 / treatment5 1.5806075 0.8106724 Inf 1 0.8926131 0.8997519
## 8: treatment3 / treatment4 0.6675272 0.3477535 Inf 1 -0.7758308 0.9376329
## 9: treatment3 / treatment5 0.7538434 0.4054990 Inf 1 -0.5253133 0.9848121
## 10: treatment4 / treatment5 1.1293075 0.5917516 Inf 1 0.2320720 0.9993591
emm <- setDT(as.data.frame(em$emmeans))
emm
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 0.4140861 13082.711 Inf 2.220446e-16 Inf
## 2: 2 0.3026902 9563.250 Inf 2.220446e-16 Inf
## 3: 3 0.1443629 4561.027 Inf 2.220446e-16 Inf
## 4: 4 0.2162652 6832.720 Inf 2.220446e-16 Inf
## 5: 5 0.1915025 6050.363 Inf 2.220446e-16 Inf
e5
##
## Call: glm.nb(formula = eggs ~ treatment + whole.mean + replicate, data = brood,
## init.theta = 1.176453787, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 1.00464 -0.31336 -1.05374 -0.64957 -0.77117 2.81308
## replicate2 replicate3 replicate4 replicate5 replicate7 replicate9
## -0.04899 0.20151 0.83148 0.53588 -0.86709 -0.42264
## replicate11 replicate12
## -0.35318 -29.01904
##
## Degrees of Freedom: 44 Total (i.e. Null); 31 Residual
## Null Deviance: 101.6
## Residual Deviance: 48.24 AIC: 265.6
ggplot(brood, aes(x = treatment, y = eggs, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5, outlier.shape = NA) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count of Eggs", title = "Count of Eggs by Treatment") +
theme_minimal() +
theme(legend.position = "right")

range(brood$eggs)
## [1] 0 87
brood.sub <- brood[brood$eggs <= 50, ]
range(brood.sub$eggs)
## [1] 0 36
ggplot(brood.sub, aes(x = treatment, y = eggs, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5, outlier.shape = NA) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count of Eggs", title = "Count of Eggs by Treatment") +
theme_minimal() +
theme(legend.position = "right")

egg_sum1 <- brood %>%
group_by(treatment) %>%
summarise(me = mean(eggs),
sde = sd(eggs),
ne = length(eggs)) %>%
mutate(see = sde/sqrt(ne))
egg_sum1
## # A tibble: 5 × 5
## treatment me sde ne see
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 14.8 27.7 9 9.22
## 2 2 9.11 11.7 9 3.91
## 3 3 5.56 6.56 9 2.19
## 4 4 6.56 5.90 9 1.97
## 5 5 4.33 4.39 9 1.46
ggplot(egg_sum1, aes(x = treatment, y = me)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = me - see, ymax = me + see), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Eggs", title = "Average Egg Count by Treatment (with the outlier of 87 eggs in T1.5)") +
theme_minimal()

egg_sum <- brood.sub %>%
group_by(treatment) %>%
summarise(me = mean(eggs),
sde = sd(eggs),
ne = length(eggs)) %>%
mutate(see = sde/sqrt(ne))
egg_sum
## # A tibble: 5 × 5
## treatment me sde ne see
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 5.75 6.04 8 2.14
## 2 2 9.11 11.7 9 3.91
## 3 3 5.56 6.56 9 2.19
## 4 4 6.56 5.90 9 1.97
## 5 5 4.33 4.39 9 1.46
ggplot(egg_sum, aes(x = treatment, y = me)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = me - see, ymax = me + see), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Eggs", title = "Average Egg Count by Treatment (without the outlier of 87 eggs in T1.5)") +
theme_minimal()

e1 <- glm.nb(eggs ~ treatment + whole.mean, data = brood.sub)
Anova(e1)
## Analysis of Deviance Table (Type II tests)
##
## Response: eggs
## LR Chisq Df Pr(>Chisq)
## treatment 3.5454 4 0.471015
## whole.mean 8.0630 1 0.004518 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Honey Pots
hp1 <- glm.nb(honey_pot ~ treatment + whole.mean + alive + duration + replicate, data = brood)
hp2 <- glm.nb(honey_pot ~ treatment*whole.mean + alive + duration + replicate, data=brood)
hp3 <- glm(honey_pot ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = "poisson")
summary(hp3)
##
## Call:
## glm(formula = honey_pot ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.4469 -0.7689 0.0119 0.6527 1.9703
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.081264 0.548234 0.148 0.882163
## treatment2 0.446092 0.217885 2.047 0.040621 *
## treatment3 -0.011160 0.229815 -0.049 0.961269
## treatment4 0.292450 0.215335 1.358 0.174428
## treatment5 0.326042 0.230873 1.412 0.157886
## whole.mean 2.357772 0.649379 3.631 0.000283 ***
## alive 0.121849 0.075997 1.603 0.108860
## duration -0.006831 0.011287 -0.605 0.545063
## replicate2 0.434568 0.254640 1.707 0.087897 .
## replicate3 -0.058640 0.267579 -0.219 0.826534
## replicate4 -0.062013 0.282330 -0.220 0.826146
## replicate5 -0.135362 0.293118 -0.462 0.644224
## replicate7 -0.338401 0.269152 -1.257 0.208650
## replicate9 0.118576 0.255525 0.464 0.642613
## replicate11 0.230020 0.276332 0.832 0.405180
## replicate12 0.551983 0.290656 1.899 0.057552 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 112.507 on 44 degrees of freedom
## Residual deviance: 60.294 on 29 degrees of freedom
## AIC: 244.5
##
## Number of Fisher Scoring iterations: 5
anova(hp1, hp2, test ="Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: honey_pot
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 27.64214 29
## 2 treatment * whole.mean + alive + duration + replicate 49.49511 25
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -211.6986
## 2 -208.5299 1 vs 2 4 3.168705 0.5300005
descdist(brood$honey_pot, discrete = TRUE)

## summary statistics
## ------
## min: 0 max: 14
## median: 6
## mean: 6.177778
## estimated sd: 3.644977
## estimated skewness: 0.03338406
## estimated kurtosis: 2.152788
plot(hp3)




plot(hp1)




Anova(hp1)
## Analysis of Deviance Table (Type II tests)
##
## Response: honey_pot
## LR Chisq Df Pr(>Chisq)
## treatment 7.2933 4 0.1211773
## whole.mean 12.2932 1 0.0004546 ***
## alive 2.1703 1 0.1406976
## duration 0.4834 1 0.4868768
## replicate 9.7900 8 0.2800754
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(hp3)
## Analysis of Deviance Table (Type II tests)
##
## Response: honey_pot
## LR Chisq Df Pr(>Chisq)
## treatment 8.5329 4 0.0738968 .
## whole.mean 13.6596 1 0.0002191 ***
## alive 2.6712 1 0.1021768
## duration 0.3645 1 0.5460071
## replicate 10.4087 8 0.2375013
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(hp1, hp3)
## df AIC
## hp1 17 245.6986
## hp3 16 244.5038
drop1(hp1, test = "Chisq")
## Single term deletions
##
## Model:
## honey_pot ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 50.623 243.70
## treatment 4 57.916 242.99 7.2933 0.1211773
## whole.mean 1 62.916 253.99 12.2932 0.0004546 ***
## alive 1 52.793 243.87 2.1703 0.1406976
## duration 1 51.106 242.18 0.4834 0.4868768
## replicate 8 60.413 237.49 9.7900 0.2800754
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(hp3, test = "Chisq")
## Single term deletions
##
## Model:
## honey_pot ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 60.294 244.50
## treatment 4 68.827 245.04 8.5329 0.0738968 .
## whole.mean 1 73.954 256.16 13.6596 0.0002191 ***
## alive 1 62.965 245.18 2.6712 0.1021768
## duration 1 60.658 242.87 0.3645 0.5460071
## replicate 8 70.703 238.91 10.4087 0.2375013
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
hp5 <- update(hp3, .~. -duration)
drop1(hp5, test = "Chisq")
## Single term deletions
##
## Model:
## honey_pot ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 60.658 242.87
## treatment 4 68.857 243.07 8.1983 0.0845796 .
## whole.mean 1 75.223 255.43 14.5649 0.0001354 ***
## alive 1 64.231 244.44 3.5727 0.0587382 .
## replicate 8 70.833 237.04 10.1747 0.2529745
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
hp4 <- update(hp5, .~. -replicate)
drop1(hp4, test = "Chisq")
## Single term deletions
##
## Model:
## honey_pot ~ treatment + whole.mean + alive
## Df Deviance AIC LRT Pr(>Chi)
## <none> 70.833 237.04
## treatment 4 80.497 238.71 9.6635 0.0464935 *
## whole.mean 1 84.118 248.33 13.2844 0.0002676 ***
## alive 1 77.688 241.90 6.8547 0.0088408 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(hp4)
## Analysis of Deviance Table (Type II tests)
##
## Response: honey_pot
## LR Chisq Df Pr(>Chisq)
## treatment 9.6635 4 0.0464935 *
## whole.mean 13.2844 1 0.0002676 ***
## alive 6.8547 1 0.0088408 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(hp5)
## Analysis of Deviance Table (Type II tests)
##
## Response: honey_pot
## LR Chisq Df Pr(>Chisq)
## treatment 8.1983 4 0.0845796 .
## whole.mean 14.5649 1 0.0001354 ***
## alive 3.5727 1 0.0587382 .
## replicate 10.1747 8 0.2529745
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ha <- setDT(as.data.frame(Anova(hp4)))
ha
## LR Chisq Df Pr(>Chisq)
## 1: 9.663523 4 0.0464935193
## 2: 13.284449 1 0.0002676167
## 3: 6.854713 1 0.0088407739
hp4
##
## Call: glm(formula = honey_pot ~ treatment + whole.mean + alive, family = "poisson",
## data = brood)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 0.27744 0.49895 0.05398 0.37111 0.31416 1.33003
## alive
## 0.13938
##
## Degrees of Freedom: 44 Total (i.e. Null); 38 Residual
## Null Deviance: 112.5
## Residual Deviance: 70.83 AIC: 237
ggplot(brood, aes(x = treatment, y = honey_pot, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5, outlier.shape = NA) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count of Honey Pots", title = "Count of Honey Pots by Treatment") +
theme_minimal() +
theme(legend.position = "right")

hp_sum <- brood %>%
group_by(treatment) %>%
summarise(mhp = mean(honey_pot),
sdhp = sd(honey_pot),
nhp = length(honey_pot)) %>%
mutate(sehp = sdhp/sqrt(nhp))
hp.means <- emmeans(object = hp4,
specs = "treatment",
adjust = "Tukey",
type = "response")
hpem <- setDT(as.data.frame(hp.means))
hpem
## treatment rate SE df asymp.LCL asymp.UCL
## 1: 1 4.435043 0.7228102 Inf 2.917969 6.740855
## 2: 2 7.304510 0.8826030 Inf 5.355417 9.962971
## 3: 3 4.681045 0.6894722 Inf 3.206461 6.833761
## 4: 4 6.427907 0.8382044 Inf 4.598270 8.985551
## 5: 5 6.072032 0.8349689 Inf 4.265080 8.644519
hpa <- setDT(as.data.frame(pairs(hp.means)))
hpa
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 0.6071651 0.1232310 Inf 1 -2.4583742 0.1002765
## 2: treatment1 / treatment3 0.9474472 0.2074110 Inf 1 -0.2465978 0.9991856
## 3: treatment1 / treatment4 0.6899669 0.1429589 Inf 1 -1.7911079 0.3786974
## 4: treatment1 / treatment5 0.7304051 0.1569572 Inf 1 -1.4619346 0.5873534
## 5: treatment2 / treatment3 1.5604442 0.2898881 Inf 1 2.3952402 0.1165246
## 6: treatment2 / treatment4 1.1363745 0.1982245 Inf 1 0.7328936 0.9488752
## 7: treatment2 / treatment5 1.2029762 0.2165561 Inf 1 1.0265628 0.8431815
## 8: treatment3 / treatment4 0.7282379 0.1384305 Inf 1 -1.6683054 0.4537171
## 9: treatment3 / treatment5 0.7709191 0.1526869 Inf 1 -1.3136129 0.6827362
## 10: treatment4 / treatment5 1.0586089 0.1996727 Inf 1 0.3019633 0.9981946
hp.cld.model <- cld(object = hp.means,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
hp.cld.model
## treatment rate SE df asymp.LCL asymp.UCL .group
## 1 4.44 0.723 Inf 2.92 6.74 a
## 3 4.68 0.689 Inf 3.21 6.83 a
## 5 6.07 0.835 Inf 4.27 8.64 a
## 4 6.43 0.838 Inf 4.60 8.99 a
## 2 7.30 0.883 Inf 5.36 9.96 a
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the log scale
## P value adjustment: tukey method for comparing a family of 5 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.
ggplot(hp_sum, aes(x = treatment, y = mhp)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = mhp - sehp, ymax = mhp + sehp), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Honey Pot Count", title = "Average Honey Pots by Treatment") +
theme_minimal()

Larvae and Pupae
brood$larvae <- brood$dead_larvae + brood$live_larvae
brood$pupae <- brood$dead_lp + brood$live_pupae
#total count of larvae
bl1 <- glm.nb(larvae ~ treatment + whole.mean + alive + duration + replicate, data = brood)
bl2 <- glm.nb(larvae ~ treatment*whole.mean + alive + duration + replicate, data = brood)
bl3 <- glm(larvae ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = "poisson") #overdispersed
anova(bl1, bl2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: larvae
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 5.134394 29
## 2 treatment * whole.mean + alive + duration + replicate 5.942634 25
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -318.2426
## 2 -312.2052 1 vs 2 4 6.037416 0.1963714
AIC(bl1, bl2)
## df AIC
## bl1 17 352.2426
## bl2 21 354.2052
summary(bl3)
##
## Call:
## glm(formula = larvae ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -4.5491 -1.7547 -0.3083 1.1231 3.9389
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.721034 0.243064 7.081 1.44e-12 ***
## treatment2 -0.494871 0.108687 -4.553 5.28e-06 ***
## treatment3 0.092196 0.091689 1.006 0.314639
## treatment4 -0.555477 0.108195 -5.134 2.84e-07 ***
## treatment5 -0.318242 0.115551 -2.754 0.005885 **
## whole.mean 3.924155 0.328016 11.963 < 2e-16 ***
## alive 0.045215 0.035384 1.278 0.201309
## duration -0.013495 0.005234 -2.579 0.009920 **
## replicate2 0.343073 0.137230 2.500 0.012420 *
## replicate3 -0.428521 0.147310 -2.909 0.003626 **
## replicate4 0.578145 0.132030 4.379 1.19e-05 ***
## replicate5 -0.225943 0.146147 -1.546 0.122107
## replicate7 -0.492747 0.146603 -3.361 0.000776 ***
## replicate9 -0.123788 0.147970 -0.837 0.402832
## replicate11 0.133836 0.151083 0.886 0.375701
## replicate12 -0.202278 0.197818 -1.023 0.306524
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 837.19 on 44 degrees of freedom
## Residual deviance: 193.10 on 29 degrees of freedom
## AIC: 425.09
##
## Number of Fisher Scoring iterations: 5
drop1(bl1, test = "Chisq")
## Single term deletions
##
## Model:
## larvae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 50.143 350.24
## treatment 4 57.298 349.40 7.155 0.12792
## whole.mean 1 86.814 384.91 36.671 1.398e-09 ***
## alive 1 54.495 352.60 4.353 0.03695 *
## duration 1 52.331 350.43 2.188 0.13905
## replicate 8 84.080 368.18 33.938 4.170e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bl5 <- update(bl1, .~. -duration)
drop1(bl5, test = "Chisq")
## Single term deletions
##
## Model:
## larvae ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 50.710 350.40
## treatment 4 59.365 351.06 8.655 0.0703334 .
## whole.mean 1 85.541 383.24 34.831 3.595e-09 ***
## alive 1 55.947 353.64 5.237 0.0221147 *
## replicate 8 82.085 365.78 31.375 0.0001204 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(bl5)
## Analysis of Deviance Table (Type II tests)
##
## Response: larvae
## LR Chisq Df Pr(>Chisq)
## treatment 8.655 4 0.0703334 .
## whole.mean 34.831 1 3.595e-09 ***
## alive 5.237 1 0.0221147 *
## replicate 31.375 8 0.0001204 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ple <- emmeans(bl5, pairwise ~ treatment, type = "response")
pairs(ple)
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 1.717 0.435 Inf 1 2.134 0.2057
## treatment1 / treatment3 0.972 0.244 Inf 1 -0.111 1.0000
## treatment1 / treatment4 1.429 0.369 Inf 1 1.383 0.6389
## treatment1 / treatment5 1.521 0.412 Inf 1 1.546 0.5323
## treatment2 / treatment3 0.566 0.138 Inf 1 -2.337 0.1333
## treatment2 / treatment4 0.832 0.211 Inf 1 -0.723 0.9512
## treatment2 / treatment5 0.885 0.234 Inf 1 -0.461 0.9907
## treatment3 / treatment4 1.470 0.364 Inf 1 1.556 0.5256
## treatment3 / treatment5 1.564 0.394 Inf 1 1.776 0.3878
## treatment4 / treatment5 1.064 0.291 Inf 1 0.226 0.9994
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log scale
#Larvae slightly different
larv_sum <- brood %>%
group_by(treatment) %>%
summarise(mhp = mean(larvae),
sdhp = sd(larvae),
nhp = length(larvae)) %>%
mutate(sehp = sdhp/sqrt(nhp))
L <- ggplot(larv_sum, aes(x = treatment, y = mhp)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = mhp - sehp, ymax = mhp + sehp), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Larvae Count", title = "Average Larvae by Treatment") +
theme_minimal()
#total count of pupae
bp1 <- glm.nb(pupae ~ treatment + whole.mean + alive + duration + replicate, data = brood)
bp2 <- glm.nb(pupae ~treatment*whole.mean + alive + duration + replicate, data = brood)
bp3 <- glm(pupae ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = "poisson") #overdispersed
anova(bp1, bp2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: pupae
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 6.284063 29
## 2 treatment * whole.mean + alive + duration + replicate 7.482878 25
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -267.2530
## 2 -262.9448 1 vs 2 4 4.308145 0.3659062
AIC(bp1, bp2)
## df AIC
## bp1 17 301.2530
## bp2 21 304.9448
summary(bp3)
##
## Call:
## glm(formula = pupae ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.8550 -1.4743 0.0304 0.9046 4.0282
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.543721 0.353902 -1.536 0.124449
## treatment2 0.665474 0.150918 4.410 1.04e-05 ***
## treatment3 0.504268 0.145607 3.463 0.000534 ***
## treatment4 0.080382 0.161299 0.498 0.618245
## treatment5 0.014864 0.182757 0.081 0.935180
## whole.mean 3.429036 0.459106 7.469 8.08e-14 ***
## alive 0.132069 0.055394 2.384 0.017118 *
## duration 0.001370 0.006757 0.203 0.839330
## replicate2 0.251974 0.219849 1.146 0.251743
## replicate3 -0.039746 0.207143 -0.192 0.847838
## replicate4 0.737360 0.198223 3.720 0.000199 ***
## replicate5 0.192326 0.211251 0.910 0.362603
## replicate7 0.566513 0.180957 3.131 0.001744 **
## replicate9 -0.258795 0.229260 -1.129 0.258971
## replicate11 0.346251 0.220613 1.569 0.116532
## replicate12 0.671969 0.227904 2.948 0.003194 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 468.91 on 44 degrees of freedom
## Residual deviance: 124.00 on 29 degrees of freedom
## AIC: 331.74
##
## Number of Fisher Scoring iterations: 5
drop1(bp1, test = "Chisq")
## Single term deletions
##
## Model:
## pupae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 48.086 299.25
## treatment 4 58.090 301.26 10.0036 0.04037 *
## whole.mean 1 68.645 317.81 20.5586 5.783e-06 ***
## alive 1 50.561 299.73 2.4746 0.11570
## duration 1 48.296 297.46 0.2101 0.64666
## replicate 8 62.477 297.64 14.3914 0.07212 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bp4 <- update(bp1, .~. -duration)
drop1(bp4, test = "Chisq")
## Single term deletions
##
## Model:
## pupae ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 48.273 297.46
## treatment 4 58.061 299.25 9.7877 0.04416 *
## whole.mean 1 71.912 319.10 23.6384 1.162e-06 ***
## alive 1 51.223 298.41 2.9495 0.08591 .
## replicate 8 64.251 297.44 15.9783 0.04269 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bp5 <- update(bp4, .~. -alive)
drop1(bp5, test ="Chisq")
## Single term deletions
##
## Model:
## pupae ~ treatment + whole.mean + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 49.768 298.39
## treatment 4 59.181 299.80 9.413 0.05156 .
## whole.mean 1 95.179 341.80 45.411 1.597e-11 ***
## replicate 8 64.684 297.30 14.916 0.06080 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(bp5)
## Analysis of Deviance Table (Type II tests)
##
## Response: pupae
## LR Chisq Df Pr(>Chisq)
## treatment 9.413 4 0.05156 .
## whole.mean 45.411 1 1.597e-11 ***
## replicate 14.916 8 0.06080 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pe <- emmeans(bp5, pairwise ~ treatment, type = "response")
pairs(pe)
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 0.579 0.145 Inf 1 -2.177 0.1885
## treatment1 / treatment3 0.617 0.157 Inf 1 -1.903 0.3158
## treatment1 / treatment4 0.996 0.265 Inf 1 -0.013 1.0000
## treatment1 / treatment5 0.945 0.253 Inf 1 -0.210 0.9996
## treatment2 / treatment3 1.066 0.249 Inf 1 0.274 0.9988
## treatment2 / treatment4 1.722 0.425 Inf 1 2.201 0.1792
## treatment2 / treatment5 1.634 0.411 Inf 1 1.950 0.2907
## treatment3 / treatment4 1.615 0.398 Inf 1 1.944 0.2938
## treatment3 / treatment5 1.532 0.393 Inf 1 1.664 0.4562
## treatment4 / treatment5 0.949 0.255 Inf 1 -0.196 0.9997
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log scale
pup_sum <- brood %>%
group_by(treatment) %>%
summarise(mhp = mean(pupae),
sdhp = sd(pupae),
nhp = length(pupae)) %>%
mutate(sehp = sdhp/sqrt(nhp))
P <- ggplot(pup_sum, aes(x = treatment, y = mhp)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = mhp - sehp, ymax = mhp + sehp), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Pupae Count", title = "Average Pupae by Treatment") +
theme_minimal()
library(ggpubr)
plot_grid(L, P, ncol=2, nrow =1)

#total count of dead larvae
bdlfinal<- glm.nb(dead_larvae ~ treatment + whole.mean, data = brood)
drop1(bdlfinal, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment + whole.mean
## Df Deviance AIC LRT Pr(>Chi)
## <none> 48.238 208.25
## treatment 4 51.267 203.28 3.0291 0.55297
## whole.mean 1 58.610 216.62 10.3713 0.00128 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bdlfinal)
##
## Call:
## glm.nb(formula = dead_larvae ~ treatment + whole.mean, data = brood,
## init.theta = 0.792423091, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.84279 -1.22817 -0.39041 0.09372 1.61744
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.82224 0.69691 -1.180 0.23807
## treatment2 0.33558 0.62504 0.537 0.59134
## treatment3 0.77610 0.61558 1.261 0.20739
## treatment4 0.70957 0.61708 1.150 0.25019
## treatment5 -0.09738 0.65349 -0.149 0.88155
## whole.mean 3.04280 1.08342 2.809 0.00498 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(0.7924) family taken to be 1)
##
## Null deviance: 68.205 on 44 degrees of freedom
## Residual deviance: 48.238 on 39 degrees of freedom
## AIC: 210.25
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 0.792
## Std. Err.: 0.244
##
## 2 x log-likelihood: -196.248
bdl1 <- glm.nb(dead_larvae ~ treatment + whole.mean + alive + duration + replicate, 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(dead_larvae ~ treatment + whole.mean + alive + duration + :
## alternation limit reached
drop1(bdl1, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 61.008 186.08
## treatment 4 69.691 186.76 8.683 0.0695204 .
## whole.mean 1 109.941 233.01 48.933 2.649e-12 ***
## alive 1 63.357 186.43 2.349 0.1253760
## duration 1 73.490 196.56 12.482 0.0004108 ***
## replicate 8 191.163 300.24 130.155 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdl11 <- update(bdl1, .~. -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
## 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 = dead_larvae ~ treatment + whole.mean + duration + :
## alternation limit reached
drop1(bdl11, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment + whole.mean + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 63.363 186.43
## treatment 4 72.843 187.91 9.479 0.05017 .
## whole.mean 1 192.893 313.96 129.530 < 2.2e-16 ***
## duration 1 83.253 204.32 19.890 8.203e-06 ***
## replicate 8 191.733 298.80 128.370 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bdl11)
##
## Call:
## glm.nb(formula = dead_larvae ~ treatment + whole.mean + duration +
## replicate, data = brood, init.theta = 1878.543274, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.4153 -1.1046 -0.3949 0.6783 2.3237
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.76626 0.73021 -3.788 0.000152 ***
## treatment2 0.65094 0.33373 1.951 0.051116 .
## treatment3 0.85055 0.31865 2.669 0.007604 **
## treatment4 0.72229 0.32918 2.194 0.028219 *
## treatment5 0.23371 0.37731 0.619 0.535648
## whole.mean 8.40032 0.97570 8.610 < 2e-16 ***
## duration -0.06566 0.01502 -4.372 1.23e-05 ***
## replicate2 2.65754 0.55614 4.779 1.77e-06 ***
## replicate3 1.35722 0.53605 2.532 0.011344 *
## replicate4 1.77072 0.48422 3.657 0.000255 ***
## replicate5 0.98136 0.51853 1.893 0.058414 .
## replicate7 -0.04842 0.59214 -0.082 0.934827
## replicate9 0.03335 0.85148 0.039 0.968757
## replicate11 1.46738 0.71608 2.049 0.040444 *
## replicate12 4.02330 0.57285 7.023 2.17e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(1878.543) family taken to be 1)
##
## Null deviance: 358.159 on 44 degrees of freedom
## Residual deviance: 63.363 on 30 degrees of freedom
## AIC: 188.43
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 1879
## Std. Err.: 7724
## Warning while fitting theta: alternation limit reached
##
## 2 x log-likelihood: -156.427
bdl2 <- glm.nb(dead_larvae ~ treatment*whole.mean + alive + duration, data = brood)
drop1(bdl2, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment * whole.mean + alive + duration
## Df Deviance AIC LRT Pr(>Chi)
## <none> 47.357 216.17
## alive 1 47.835 214.65 0.47759 0.4895
## duration 1 48.639 215.46 1.28242 0.2574
## treatment:whole.mean 4 49.579 210.40 2.22216 0.6950
bdl3 <- glm(dead_larvae ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = "poisson") #overdispersed
summary(bdl3)
##
## Call:
## glm(formula = dead_larvae ~ treatment + whole.mean + alive +
## duration + replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5868 -0.9221 -0.1131 0.6191 2.3624
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.36620 0.84554 -3.981 6.86e-05 ***
## treatment2 0.50556 0.34739 1.455 0.145577
## treatment3 0.72413 0.32661 2.217 0.026618 *
## treatment4 0.59061 0.34716 1.701 0.088888 .
## treatment5 -0.02830 0.40984 -0.069 0.944955
## whole.mean 7.33603 1.16797 6.281 3.36e-10 ***
## alive 0.20174 0.13489 1.496 0.134755
## duration -0.05595 0.01603 -3.491 0.000482 ***
## replicate2 2.66426 0.55416 4.808 1.53e-06 ***
## replicate3 1.33109 0.53183 2.503 0.012320 *
## replicate4 1.96788 0.50247 3.916 8.99e-05 ***
## replicate5 1.25484 0.55095 2.278 0.022751 *
## replicate7 0.05880 0.58910 0.100 0.920494
## replicate9 -0.04179 0.85072 -0.049 0.960825
## replicate11 1.22121 0.72543 1.683 0.092292 .
## replicate12 3.78320 0.58159 6.505 7.77e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 359.502 on 44 degrees of freedom
## Residual deviance: 61.086 on 29 degrees of freedom
## AIC: 186.06
##
## Number of Fisher Scoring iterations: 6
drop1(bdl3, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 61.086 186.06
## treatment 4 69.811 186.78 8.725 0.0683460 .
## whole.mean 1 110.197 233.17 49.111 2.419e-12 ***
## alive 1 63.436 186.41 2.350 0.1252938
## duration 1 73.619 196.59 12.533 0.0003998 ***
## replicate 8 191.852 300.82 130.766 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(bdl1, bdl2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: dead_larvae
## Model theta Resid. df
## 1 treatment * whole.mean + alive + duration 0.8889151 33
## 2 treatment + whole.mean + alive + duration + replicate 1725.8040828 29
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -192.1742
## 2 -154.0793 1 vs 2 4 38.09492 1.071158e-07
AIC(bdl1, bdl2)
## df AIC
## bdl1 17 188.0793
## bdl2 13 218.1742
AIC(bdl2, bdl3)
## df AIC
## bdl2 13 218.1742
## bdl3 16 186.0589
drop1(bdl3, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 61.086 186.06
## treatment 4 69.811 186.78 8.725 0.0683460 .
## whole.mean 1 110.197 233.17 49.111 2.419e-12 ***
## alive 1 63.436 186.41 2.350 0.1252938
## duration 1 73.619 196.59 12.533 0.0003998 ***
## replicate 8 191.852 300.82 130.766 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdl4 <- update(bdl3, .~. -alive)
drop1(bdl4, test = "Chisq")
## Single term deletions
##
## Model:
## dead_larvae ~ treatment + whole.mean + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 63.436 186.41
## treatment 4 72.962 187.94 9.526 0.04922 *
## whole.mean 1 193.657 314.63 130.221 < 2.2e-16 ***
## duration 1 83.408 204.38 19.972 7.859e-06 ***
## replicate 8 192.365 299.34 128.929 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bdl4)
##
## Call:
## glm(formula = dead_larvae ~ treatment + whole.mean + duration +
## replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.4167 -1.1046 -0.3942 0.6719 2.3249
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.76884 0.72929 -3.797 0.000147 ***
## treatment2 0.65230 0.33332 1.957 0.050351 .
## treatment3 0.85141 0.31835 2.674 0.007485 **
## treatment4 0.72341 0.32884 2.200 0.027815 *
## treatment5 0.23440 0.37701 0.622 0.534128
## whole.mean 8.40447 0.97452 8.624 < 2e-16 ***
## duration -0.06570 0.01500 -4.381 1.18e-05 ***
## replicate2 2.65912 0.55582 4.784 1.72e-06 ***
## replicate3 1.35850 0.53559 2.536 0.011197 *
## replicate4 1.77275 0.48373 3.665 0.000248 ***
## replicate5 0.98197 0.51815 1.895 0.058073 .
## replicate7 -0.04841 0.59187 -0.082 0.934819
## replicate9 0.03424 0.85133 0.040 0.967919
## replicate11 1.46906 0.71578 2.052 0.040131 *
## replicate12 4.02488 0.57235 7.032 2.03e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 359.502 on 44 degrees of freedom
## Residual deviance: 63.436 on 30 degrees of freedom
## AIC: 186.41
##
## Number of Fisher Scoring iterations: 6
Anova(bdl4)
## Analysis of Deviance Table (Type II tests)
##
## Response: dead_larvae
## LR Chisq Df Pr(>Chisq)
## treatment 9.526 4 0.04922 *
## whole.mean 130.221 1 < 2.2e-16 ***
## duration 19.972 1 7.859e-06 ***
## replicate 128.929 8 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdlfinal
##
## Call: glm.nb(formula = dead_larvae ~ treatment + whole.mean, data = brood,
## init.theta = 0.792423091, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## -0.82224 0.33558 0.77610 0.70957 -0.09738 3.04280
##
## Degrees of Freedom: 44 Total (i.e. Null); 39 Residual
## Null Deviance: 68.2
## Residual Deviance: 48.24 AIC: 210.2
bdlA <- setDT(as.data.frame(Anova(bdlfinal)))
bdlA
## LR Chisq Df Pr(>Chisq)
## 1: 3.02909 4 0.552969096
## 2: 10.37128 1 0.001279908
dle <- emmeans(bdlfinal, pairwise ~ treatment, type = "response")
dlem <- setDT(as.data.frame(dle$emmeans))
dlcm <- setDT(as.data.frame(dle$contrasts))
dlem
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 1.896145 0.8666032 Inf 0.7741826 4.644081
## 2: 2 2.652240 1.1318814 Inf 1.1490800 6.121745
## 3: 3 4.120289 1.7025401 Inf 1.8331738 9.260869
## 4: 4 3.855088 1.6005338 Inf 1.7085877 8.698240
## 5: 5 1.720212 0.8029721 Inf 0.6890523 4.294489
dlcm
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 0.7149223 0.4468521 Inf 1 -0.5368994 0.9835202
## 2: treatment1 / treatment3 0.4601971 0.2832879 Inf 1 -1.2607639 0.7153436
## 3: treatment1 / treatment4 0.4918552 0.3035139 Inf 1 -1.1498851 0.7798050
## 4: treatment1 / treatment5 1.1022745 0.7203230 Inf 1 0.1490093 0.9998895
## 5: treatment2 / treatment3 0.6437023 0.3803548 Inf 1 -0.7455225 0.9457151
## 6: treatment2 / treatment4 0.6879841 0.4081662 Inf 1 -0.6303776 0.9701994
## 7: treatment2 / treatment5 1.5418101 0.9769794 Inf 1 0.6832669 0.9601389
## 8: treatment3 / treatment4 1.0687924 0.6213916 Inf 1 0.1144305 0.9999614
## 9: treatment3 / treatment5 2.3952224 1.4990178 Inf 1 1.3956935 0.6304429
## 10: treatment4 / treatment5 2.2410547 1.4036874 Inf 1 1.2883293 0.6984613
#total count of dead pupae
bdp1 <- glm.nb(dead_pupae ~ treatment + whole.mean + alive + duration + replicate, data = brood)
## Warning in glm.nb(dead_pupae ~ treatment + whole.mean + alive + duration + :
## alternation limit reached
bdp2 <- glm.nb(dead_pupae ~ treatment*whole.mean + alive + duration + replicate,data = brood)
## Warning in glm.nb(dead_pupae ~ treatment * whole.mean + alive + duration + :
## alternation limit reached
bdp3 <- glm(dead_pupae ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = "poisson") #overdispersed
summary(bdp3)
##
## Call:
## glm(formula = dead_pupae ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.7154 -1.1301 -0.7252 0.9052 4.0550
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.96440 0.68622 -4.320 1.56e-05 ***
## treatment2 1.26175 0.27991 4.508 6.55e-06 ***
## treatment3 1.24460 0.26808 4.643 3.44e-06 ***
## treatment4 0.19734 0.31513 0.626 0.5312
## treatment5 0.52716 0.31276 1.686 0.0919 .
## whole.mean 1.82449 0.72818 2.506 0.0122 *
## alive 0.30695 0.11402 2.692 0.0071 **
## duration 0.02194 0.01002 2.190 0.0285 *
## replicate2 -0.35914 0.42981 -0.836 0.4034
## replicate3 0.24153 0.33662 0.717 0.4731
## replicate4 0.56288 0.37384 1.506 0.1321
## replicate5 0.45903 0.37027 1.240 0.2151
## replicate7 1.42483 0.28489 5.001 5.69e-07 ***
## replicate9 -0.18614 0.37102 -0.502 0.6159
## replicate11 0.50577 0.33620 1.504 0.1325
## replicate12 0.27495 0.38583 0.713 0.4761
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 309.89 on 44 degrees of freedom
## Residual deviance: 101.43 on 29 degrees of freedom
## AIC: 251.93
##
## Number of Fisher Scoring iterations: 6
anova(bdp1, bdp2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: dead_pupae
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 3.677605 29
## 2 treatment * whole.mean + alive + duration + replicate 5.128443 25
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -201.2192
## 2 -194.4874 1 vs 2 4 6.731801 0.1507585
AIC(bdp1, bdp2)
## df AIC
## bdp1 17 235.2192
## bdp2 21 236.4874
drop1(bdp1, test = "Chisq")
## Single term deletions
##
## Model:
## dead_pupae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 51.471 233.22
## treatment 4 65.856 239.60 14.3851 0.006162 **
## whole.mean 1 57.008 236.76 5.5369 0.018619 *
## alive 1 53.693 233.44 2.2219 0.136069
## duration 1 51.589 231.34 0.1179 0.731276
## replicate 8 66.016 231.76 14.5451 0.068619 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4 <- update(bdp1, .~. -duration)
drop1(bdp4, test = "Chisq")
## Single term deletions
##
## Model:
## dead_pupae ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 51.137 231.34
## treatment 4 66.304 238.50 15.1673 0.004366 **
## whole.mean 1 58.934 237.13 7.7971 0.005233 **
## alive 1 53.216 231.41 2.0791 0.149324
## replicate 8 66.476 230.67 15.3390 0.052879 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4 <- update(bdp4, .~. -alive)
drop1(bdp4, test = "Chisq")
## Single term deletions
##
## Model:
## dead_pupae ~ treatment + whole.mean + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 50.937 231.35
## treatment 4 67.705 240.12 16.768 0.002144 **
## whole.mean 1 67.527 245.94 16.590 4.64e-05 ***
## replicate 8 69.929 234.34 18.992 0.014902 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(bdp4)
## Analysis of Deviance Table (Type II tests)
##
## Response: dead_pupae
## LR Chisq Df Pr(>Chisq)
## treatment 16.768 4 0.002144 **
## whole.mean 16.590 1 4.64e-05 ***
## replicate 18.992 8 0.014902 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4
##
## Call: glm.nb(formula = dead_pupae ~ treatment + whole.mean + replicate,
## data = brood, init.theta = 3.226827913, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## -1.38870 1.10498 1.28291 0.13733 0.82066 3.56233
## replicate2 replicate3 replicate4 replicate5 replicate7 replicate9
## -0.37439 -0.04334 -0.01480 -0.03361 1.10661 -0.25760
## replicate11 replicate12
## 0.82322 0.39737
##
## Degrees of Freedom: 44 Total (i.e. Null); 31 Residual
## Null Deviance: 124.1
## Residual Deviance: 50.94 AIC: 233.3
summary(bdp4)
##
## Call:
## glm.nb(formula = dead_pupae ~ treatment + whole.mean + replicate,
## data = brood, init.theta = 3.226827913, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1077 -0.9027 -0.3928 0.5463 2.0500
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.38870 0.67264 -2.065 0.038965 *
## treatment2 1.10498 0.40221 2.747 0.006010 **
## treatment3 1.28291 0.39987 3.208 0.001335 **
## treatment4 0.13733 0.44162 0.311 0.755829
## treatment5 0.82066 0.41991 1.954 0.050658 .
## whole.mean 3.56233 0.94539 3.768 0.000164 ***
## replicate2 -0.37439 0.56843 -0.659 0.510122
## replicate3 -0.04334 0.52089 -0.083 0.933690
## replicate4 -0.01480 0.50092 -0.030 0.976434
## replicate5 -0.03361 0.52663 -0.064 0.949111
## replicate7 1.10661 0.46213 2.395 0.016640 *
## replicate9 -0.25760 0.54066 -0.476 0.633746
## replicate11 0.82322 0.50433 1.632 0.102616
## replicate12 0.39737 0.57530 0.691 0.489741
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(3.2268) family taken to be 1)
##
## Null deviance: 124.069 on 44 degrees of freedom
## Residual deviance: 50.937 on 31 degrees of freedom
## AIC: 233.35
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 3.23
## Std. Err.: 1.32
##
## 2 x log-likelihood: -203.349
bdpa <- setDT(as.data.frame(Anova(bdp4)))
bdpa
## LR Chisq Df Pr(>Chisq)
## 1: 16.76820 4 0.0021439953
## 2: 16.58993 1 0.0000463967
## 3: 18.99205 8 0.0149022003
dpe <- emmeans(bdp4, pairwise ~ treatment, type = "response")
pairs(dpe)
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 0.331 0.133 Inf 1 -2.747 0.0474
## treatment1 / treatment3 0.277 0.111 Inf 1 -3.208 0.0117
## treatment1 / treatment4 0.872 0.385 Inf 1 -0.311 0.9980
## treatment1 / treatment5 0.440 0.185 Inf 1 -1.954 0.2887
## treatment2 / treatment3 0.837 0.279 Inf 1 -0.533 0.9839
## treatment2 / treatment4 2.632 1.012 Inf 1 2.516 0.0872
## treatment2 / treatment5 1.329 0.478 Inf 1 0.791 0.9333
## treatment3 / treatment4 3.144 1.185 Inf 1 3.039 0.0201
## treatment3 / treatment5 1.588 0.576 Inf 1 1.274 0.7075
## treatment4 / treatment5 0.505 0.208 Inf 1 -1.660 0.4589
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log scale
dpem <- setDT(as.data.frame(dpe$emmeans))
dpcm <- setDT(as.data.frame(dpe$contrasts))
dpem
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 1.650629 0.5404879 Inf 0.8688184 3.135956
## 2: 2 4.983503 1.1925755 Inf 3.1177276 7.965833
## 3: 3 5.954019 1.4311728 Inf 3.7171165 9.537055
## 4: 4 1.893608 0.5832919 Inf 1.0353630 3.463278
## 5: 5 3.750216 1.0080822 Inf 2.2143583 6.351331
dpem1 <- as.data.frame(dpem)
dpcm
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 0.3312187 0.1332210 Inf 1 -2.7472311 0.04738761
## 2: treatment1 / treatment3 0.2772294 0.1108560 Inf 1 -3.2083091 0.01166982
## 3: treatment1 / treatment4 0.8716849 0.3849534 Inf 1 -0.3109627 0.99797470
## 4: treatment1 / treatment5 0.4401424 0.1848199 Inf 1 -1.9543675 0.28866615
## 5: treatment2 / treatment3 0.8369981 0.2792995 Inf 1 -0.5332268 0.98393767
## 6: treatment2 / treatment4 2.6317503 1.0123641 Inf 1 2.5155090 0.08716140
## 7: treatment2 / treatment5 1.3288574 0.4775639 Inf 1 0.7911401 0.93327965
## 8: treatment3 / treatment4 3.1442728 1.1851403 Inf 1 3.0393232 0.02006760
## 9: treatment3 / treatment5 1.5876468 0.5762364 Inf 1 1.2735996 0.70751859
## 10: treatment4 / treatment5 0.5049329 0.2078462 Inf 1 -1.6600526 0.45892854
ggplot(brood, aes(x = treatment, y = dead_pupae, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count", title = "Average Count of Dead Pupae by Treatment") +
theme_minimal() +
theme(legend.position = "right")

#One seemingly outlier in treatment 2
brood.sub1 <- brood[brood$dead_pupae <= 30, ]
bdp1 <- glm.nb(dead_pupae ~ treatment + whole.mean + alive + duration + replicate, data = brood.sub1)
## Warning in glm.nb(dead_pupae ~ treatment + whole.mean + alive + duration + :
## alternation limit reached
bdp2 <- glm.nb(dead_pupae ~ treatment*whole.mean + alive + duration + replicate, data = brood.sub1)
## 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(dead_pupae ~ treatment * whole.mean + alive + duration + :
## alternation limit reached
bdp3 <- glm(dead_pupae ~ treatment + whole.mean + alive + duration + replicate, data = brood.sub1, family = "poisson") #not super overdispersed
summary(bdp3)
##
## Call:
## glm(formula = dead_pupae ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = brood.sub1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6752 -1.0123 -0.5019 0.7087 2.3550
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.44150 0.72685 -1.983 0.04734 *
## treatment2 0.71523 0.30935 2.312 0.02077 *
## treatment3 1.12282 0.27157 4.135 3.56e-05 ***
## treatment4 0.06611 0.32989 0.200 0.84116
## treatment5 0.82218 0.31770 2.588 0.00966 **
## whole.mean 4.36389 0.90497 4.822 1.42e-06 ***
## alive 0.13371 0.11926 1.121 0.26222
## duration -0.02109 0.01304 -1.617 0.10589
## replicate2 -0.10244 0.42906 -0.239 0.81129
## replicate3 0.29625 0.34887 0.849 0.39579
## replicate4 0.16354 0.38279 0.427 0.66922
## replicate5 -0.12767 0.39025 -0.327 0.74356
## replicate7 0.11941 0.38614 0.309 0.75713
## replicate9 -0.01849 0.37427 -0.049 0.96059
## replicate11 0.80945 0.34439 2.350 0.01875 *
## replicate12 0.75297 0.40503 1.859 0.06302 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 213.773 on 43 degrees of freedom
## Residual deviance: 70.261 on 28 degrees of freedom
## AIC: 215.26
##
## Number of Fisher Scoring iterations: 6
anova(bdp1, bdp2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: dead_pupae
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 12.13437 28
## 2 treatment * whole.mean + alive + duration + replicate 11914.91841 24
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -182.0387
## 2 -172.7351 1 vs 2 4 9.303574 0.05394365
AIC(bdp1, bdp2)
## df AIC
## bdp1 17 216.0387
## bdp2 21 214.7351
AIC(bdp3)
## [1] 215.2611
drop1(bdp3, test = "Chisq")
## Single term deletions
##
## Model:
## dead_pupae ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 70.261 215.26
## treatment 4 101.903 238.90 31.642 2.264e-06 ***
## whole.mean 1 95.621 238.62 25.360 4.758e-07 ***
## alive 1 71.594 214.59 1.332 0.2484
## duration 1 72.896 215.90 2.635 0.1045
## replicate 8 81.387 210.39 11.126 0.1947
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4 <- update(bdp1, .~. -alive)
drop1(bdp4, test = "Chisq")
## Single term deletions
##
## Model:
## dead_pupae ~ treatment + whole.mean + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 56.836 213.07
## treatment 4 79.702 227.94 22.866 0.0001347 ***
## whole.mean 1 89.842 244.08 33.006 9.187e-09 ***
## duration 1 59.193 213.43 2.356 0.1247773
## replicate 8 68.950 209.19 12.113 0.1462153
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4 <- update(bdp4, .~. -replicate)
drop1(bdp4, test = "Chisq")
## Single term deletions
##
## Model:
## dead_pupae ~ treatment + whole.mean + duration
## Df Deviance AIC LRT Pr(>Chi)
## <none> 56.366 207.87
## treatment 4 74.986 218.49 18.620 0.0009334 ***
## whole.mean 1 91.314 240.82 34.947 3.388e-09 ***
## duration 1 58.611 208.12 2.245 0.1340736
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4 <- update(bdp4, .~. -duration)
Anova(bdp4)
## Analysis of Deviance Table (Type II tests)
##
## Response: dead_pupae
## LR Chisq Df Pr(>Chisq)
## treatment 16.099 4 0.002889 **
## whole.mean 29.798 1 4.794e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
bdp4
##
## Call: glm.nb(formula = dead_pupae ~ treatment + whole.mean, data = brood.sub1,
## init.theta = 3.856673118, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## -0.9665 0.5707 1.2242 0.1234 0.6465 3.3559
##
## Degrees of Freedom: 43 Total (i.e. Null); 38 Residual
## Null Deviance: 108.7
## Residual Deviance: 55.14 AIC: 210
bdpa <- setDT(as.data.frame(Anova(bdp4)))
bdpa
## LR Chisq Df Pr(>Chisq)
## 1: 16.09929 4 2.888779e-03
## 2: 29.79834 1 4.794013e-08
dpe <- emmeans(bdp4, pairwise ~ treatment, type = "response")
pairs(dpe)
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 0.565 0.224 Inf 1 -1.443 0.6000
## treatment1 / treatment3 0.294 0.108 Inf 1 -3.342 0.0074
## treatment1 / treatment4 0.884 0.359 Inf 1 -0.304 0.9981
## treatment1 / treatment5 0.524 0.206 Inf 1 -1.646 0.4681
## treatment2 / treatment3 0.520 0.175 Inf 1 -1.942 0.2949
## treatment2 / treatment4 1.564 0.593 Inf 1 1.180 0.7627
## treatment2 / treatment5 0.927 0.338 Inf 1 -0.208 0.9996
## treatment3 / treatment4 3.006 1.041 Inf 1 3.179 0.0129
## treatment3 / treatment5 1.782 0.597 Inf 1 1.724 0.4188
## treatment4 / treatment5 0.593 0.224 Inf 1 -1.383 0.6386
##
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log scale
dpem <- setDT(as.data.frame(dpe$emmeans))
dpcm <- setDT(as.data.frame(dpe$contrasts))
dpem
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 1.900793 0.5703361 Inf 1.055676 3.422467
## 2: 2 3.363506 0.8791113 Inf 2.015189 5.613952
## 3: 3 6.465131 1.4128247 Inf 4.212737 9.921798
## 4: 4 2.150438 0.6028137 Inf 1.241415 3.725091
## 5: 5 3.628471 0.9191513 Inf 2.208515 5.961382
dpcm
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 0.5651226 0.2235670 Inf 1 -1.4426219 0.599963871
## 2: treatment1 / treatment3 0.2940069 0.1076995 Inf 1 -3.3417911 0.007433944
## 3: treatment1 / treatment4 0.8839097 0.3585032 Inf 1 -0.3042506 0.998140424
## 4: treatment1 / treatment5 0.5238552 0.2058267 Inf 1 -1.6455268 0.468142948
## 5: treatment2 / treatment3 0.5202533 0.1750351 Inf 1 -1.9422052 0.294922881
## 6: treatment2 / treatment4 1.5641025 0.5927310 Inf 1 1.1803705 0.762700993
## 7: treatment2 / treatment5 0.9269762 0.3375810 Inf 1 -0.2082173 0.999582670
## 8: treatment3 / treatment4 3.0064249 1.0410593 Inf 1 3.1788074 0.012858176
## 9: treatment3 / treatment5 1.7817785 0.5968296 Inf 1 1.7244062 0.418809227
## 10: treatment4 / treatment5 0.5926569 0.2241653 Inf 1 -1.3830967 0.638567576
ggplot(brood.sub1, aes(x = treatment, y = dead_pupae, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count", title = "Average Count of Dead Pupae by Treatment") +
theme_minimal() +
theme(legend.position = "right")

deadpupmeans <- emmeans(object = bdp4,
specs = "treatment",
adjust = "Tukey",
type = "response")
deadpup.cld.model <- cld(object = deadpupmeans,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
deadpup.cld.model
## treatment response SE df asymp.LCL asymp.UCL .group
## 1 1.90 0.570 Inf 0.879 4.11 a
## 4 2.15 0.603 Inf 1.047 4.42 a
## 2 3.36 0.879 Inf 1.719 6.58 ab
## 5 3.63 0.919 Inf 1.893 6.96 ab
## 3 6.47 1.413 Inf 3.688 11.33 b
##
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the log scale
## P value adjustment: tukey method for comparing a family of 5 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.
deadpup.means <- as.data.frame(deadpupmeans)
dp_max <- brood.sub1 %>%
group_by(treatment) %>%
summarize(maxdp = max((dead_pupae)))
dpsum <- brood.sub1 %>%
group_by(treatment) %>%
summarise(mean = mean(dead_pupae),
sd = sd(dead_pupae),
n = length(dead_pupae)) %>%
mutate(se = sd/sqrt(n))
dpsum
## # A tibble: 5 × 5
## treatment mean sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 2 2.06 9 0.687
## 2 2 4 3.55 8 1.25
## 3 3 8.89 7.27 9 2.42
## 4 4 2.89 3.02 9 1.01
## 5 5 3.89 4.28 9 1.43
ggplot(dpsum, aes(x = treatment, y = mean)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Dead Pupae Count", title = "Average Dead Pupae by Treatment") +
theme_minimal()

ggplot(dpem1, aes(x = treatment, y = response, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
geom_errorbar(aes(ymin = response - SE, ymax = response + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Dead Pupae", title = "Count of Dead Pupae by Treatment") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0,7.4)) +
annotate(geom = "text",
x = 1, y = 7,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c((dpem1$response + dpem1$SE) + 0.3) ,
label = c("a", "ab", "b", "a", "ab"),
size = 8) +
theme(legend.position = "none")

cbind larvae and pupae
mod1 <- glm(cbind(alive_lp, dead_lp) ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = binomial("logit"))
summary(mod1)
##
## Call:
## glm(formula = cbind(alive_lp, dead_lp) ~ treatment + whole.mean +
## alive + duration + replicate, family = binomial("logit"),
## data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -4.6967 -1.4846 0.1905 1.2651 3.2779
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 5.404021 0.597024 9.052 < 2e-16 ***
## treatment2 -1.518589 0.245644 -6.182 6.33e-10 ***
## treatment3 -0.716487 0.228851 -3.131 0.001743 **
## treatment4 -0.785087 0.256538 -3.060 0.002211 **
## treatment5 -0.537735 0.283219 -1.899 0.057610 .
## whole.mean -1.674925 0.689915 -2.428 0.015194 *
## alive -0.399663 0.095550 -4.183 2.88e-05 ***
## duration 0.005419 0.009372 0.578 0.563104
## replicate2 -1.094777 0.351108 -3.118 0.001820 **
## replicate3 -1.173594 0.329035 -3.567 0.000361 ***
## replicate4 -1.391974 0.310790 -4.479 7.51e-06 ***
## replicate5 -0.793646 0.328610 -2.415 0.015728 *
## replicate7 -1.176230 0.289198 -4.067 4.76e-05 ***
## replicate9 0.058596 0.376854 0.155 0.876436
## replicate11 -0.987903 0.353103 -2.798 0.005146 **
## replicate12 -3.708534 0.472799 -7.844 4.37e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 411.27 on 42 degrees of freedom
## Residual deviance: 198.04 on 27 degrees of freedom
## AIC: 351.13
##
## Number of Fisher Scoring iterations: 5
qqnorm(resid(mod1));qqline(resid(mod1))

Anova(mod1)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(alive_lp, dead_lp)
## LR Chisq Df Pr(>Chisq)
## treatment 45.553 4 3.051e-09 ***
## whole.mean 5.997 1 0.01433 *
## alive 19.512 1 9.999e-06 ***
## duration 0.334 1 0.56337
## replicate 115.265 8 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(mod1)




drop1(mod1, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(alive_lp, dead_lp) ~ treatment + whole.mean + alive + duration +
## replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 198.04 351.13
## treatment 4 243.59 388.69 45.553 3.051e-09 ***
## whole.mean 1 204.03 355.13 5.997 0.01433 *
## alive 1 217.55 368.64 19.512 9.999e-06 ***
## duration 1 198.37 349.47 0.334 0.56337
## replicate 8 313.30 450.40 115.265 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3 <- update(mod1, .~. -duration)
drop1(mod3, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(alive_lp, dead_lp) ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 198.37 349.47
## treatment 4 244.39 387.48 46.018 2.442e-09 ***
## whole.mean 1 204.29 353.38 5.917 0.015 *
## alive 1 218.37 367.46 19.994 7.767e-06 ***
## replicate 8 313.72 448.81 115.347 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3
##
## Call: glm(formula = cbind(alive_lp, dead_lp) ~ treatment + whole.mean +
## alive + replicate, family = binomial("logit"), data = brood)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 5.53936 -1.48326 -0.69908 -0.78275 -0.50613 -1.50844
## alive replicate2 replicate3 replicate4 replicate5 replicate7
## -0.40258 -1.07001 -1.13066 -1.38922 -0.81199 -1.22897
## replicate9 replicate11 replicate12
## 0.06513 -0.96521 -3.67922
##
## Degrees of Freedom: 42 Total (i.e. Null); 28 Residual
## Null Deviance: 411.3
## Residual Deviance: 198.4 AIC: 349.5
me <- emmeans(mod3, pairwise~treatment, type = "response")
me
## $emmeans
## treatment prob SE df asymp.LCL asymp.UCL
## 1 0.883 0.0205 Inf 0.837 0.918
## 2 0.632 0.0342 Inf 0.563 0.696
## 3 0.790 0.0237 Inf 0.740 0.833
## 4 0.776 0.0333 Inf 0.704 0.834
## 5 0.820 0.0295 Inf 0.755 0.871
##
## Results are averaged over the levels of: 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
## treatment1 / treatment2 4.407 1.0486 Inf 1 6.234 <.0001
## treatment1 / treatment3 2.012 0.4570 Inf 1 3.078 0.0178
## treatment1 / treatment4 2.187 0.5603 Inf 1 3.056 0.0190
## treatment1 / treatment5 1.659 0.4618 Inf 1 1.818 0.3629
## treatment2 / treatment3 0.456 0.0872 Inf 1 -4.103 0.0004
## treatment2 / treatment4 0.496 0.1130 Inf 1 -3.076 0.0179
## treatment2 / treatment5 0.376 0.0893 Inf 1 -4.117 0.0004
## treatment3 / treatment4 1.087 0.2173 Inf 1 0.419 0.9936
## treatment3 / treatment5 0.825 0.1897 Inf 1 -0.839 0.9186
## treatment4 / treatment5 0.758 0.1866 Inf 1 -1.124 0.7937
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio scale
mem <- setDT(as.data.frame(me$emmeans))
mcm <- setDT(as.data.frame(me$contrasts))
mem
## treatment prob SE df asymp.LCL asymp.UCL
## 1: 1 0.8834025 0.02047532 Inf 0.8369138 0.9179387
## 2: 2 0.6322289 0.03423278 Inf 0.5629712 0.6964294
## 3: 3 0.7901742 0.02372859 Inf 0.7399045 0.8329220
## 4: 4 0.7759639 0.03325733 Inf 0.7041933 0.8344157
## 5: 5 0.8203801 0.02952631 Inf 0.7551370 0.8712043
mcm
## contrast odds.ratio SE df null z.ratio
## 1: treatment1 / treatment2 4.4073011 1.04863664 Inf 1 6.2339843
## 2: treatment1 / treatment3 2.0118960 0.45698349 Inf 1 3.0777292
## 3: treatment1 / treatment4 2.1874895 0.56029103 Inf 1 3.0560321
## 4: treatment1 / treatment5 1.6588569 0.46175618 Inf 1 1.8182651
## 5: treatment2 / treatment3 0.4564916 0.08724460 Inf 1 -4.1031063
## 6: treatment2 / treatment4 0.4963331 0.11302487 Inf 1 -3.0761840
## 7: treatment2 / treatment5 0.3763884 0.08932419 Inf 1 -4.1173815
## 8: treatment3 / treatment4 1.0872776 0.21725973 Inf 1 0.4187619
## 9: treatment3 / treatment5 0.8245242 0.18969904 Inf 1 -0.8386494
## 10: treatment4 / treatment5 0.7583382 0.18656523 Inf 1 -1.1244106
## p.value
## 1: 4.543999e-09
## 2: 1.779215e-02
## 3: 1.904787e-02
## 4: 3.628690e-01
## 5: 3.924124e-04
## 6: 1.787909e-02
## 7: 3.691927e-04
## 8: 9.935769e-01
## 9: 9.185974e-01
## 10: 7.936902e-01
alp <- setDT(as.data.frame(Anova(mod3)))
alp
## LR Chisq Df Pr(>Chisq)
## 1: 46.017647 4 2.442113e-09
## 2: 5.916555 1 1.499926e-02
## 3: 19.994386 1 7.766987e-06
## 4: 115.347073 8 3.021756e-21
mem$plot <- mem$prob + mem$SE
mem
## treatment prob SE df asymp.LCL asymp.UCL plot
## 1: 1 0.8834025 0.02047532 Inf 0.8369138 0.9179387 0.9038779
## 2: 2 0.6322289 0.03423278 Inf 0.5629712 0.6964294 0.6664617
## 3: 3 0.7901742 0.02372859 Inf 0.7399045 0.8329220 0.8139028
## 4: 4 0.7759639 0.03325733 Inf 0.7041933 0.8344157 0.8092212
## 5: 5 0.8203801 0.02952631 Inf 0.7551370 0.8712043 0.8499064
mod3
##
## Call: glm(formula = cbind(alive_lp, dead_lp) ~ treatment + whole.mean +
## alive + replicate, family = binomial("logit"), data = brood)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 5.53936 -1.48326 -0.69908 -0.78275 -0.50613 -1.50844
## alive replicate2 replicate3 replicate4 replicate5 replicate7
## -0.40258 -1.07001 -1.13066 -1.38922 -0.81199 -1.22897
## replicate9 replicate11 replicate12
## 0.06513 -0.96521 -3.67922
##
## Degrees of Freedom: 42 Total (i.e. Null); 28 Residual
## Null Deviance: 411.3
## Residual Deviance: 198.4 AIC: 349.5
sum <- brood %>%
group_by(treatment) %>%
summarise(mean.l = mean(alive_lp),
mean.d = mean(dead_lp))
sum$prob.alive <- (sum$mean.l)/(sum$mean.d + sum$mean.l)
sum
## # A tibble: 5 × 4
## treatment mean.l mean.d prob.alive
## <fct> <dbl> <dbl> <dbl>
## 1 1 31.4 3.78 0.893
## 2 2 19.3 11.1 0.635
## 3 3 35.3 14.7 0.707
## 4 4 20.6 9.56 0.683
## 5 5 19.3 5.44 0.780
cldb <- cld(object = me,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldb
## treatment prob SE df asymp.LCL asymp.UCL .group
## 2 0.632 0.0342 Inf 0.541 0.715 a
## 4 0.776 0.0333 Inf 0.679 0.850 b
## 3 0.790 0.0237 Inf 0.723 0.845 b
## 5 0.820 0.0295 Inf 0.732 0.884 bc
## 1 0.883 0.0205 Inf 0.820 0.927 c
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the logit scale
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio 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.
ggplot(mem, aes(x = treatment, y = prob, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
geom_errorbar(aes(ymin = prob - SE, ymax = prob + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Probability", title = "Probability of Brood Being Alive Upon Dissection") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0.5,1)) +
annotate(geom = "text",
x = 3, y = 1 ,
label = "P < 0.001",
size = 12) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(mem$plot + 0.05),
label = c("c", "a", "ab", "ab", "bc"),
size = 12) +
theme(legend.position = "none")

Pupae cbind
mod1 <- glm(cbind(live_pupae, dead_pupae) ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = binomial("logit"))
summary(mod1)
##
## Call:
## glm(formula = cbind(live_pupae, dead_pupae) ~ treatment + whole.mean +
## alive + duration + replicate, family = binomial("logit"),
## data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.3141 -0.8636 0.0000 1.0110 2.5445
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 3.86364 1.13056 3.417 0.000632 ***
## treatment2 -1.55955 0.39839 -3.915 9.06e-05 ***
## treatment3 -1.61891 0.39620 -4.086 4.39e-05 ***
## treatment4 -0.97992 0.44120 -2.221 0.026350 *
## treatment5 -1.54960 0.48832 -3.173 0.001507 **
## whole.mean -1.05135 1.22370 -0.859 0.390253
## alive -0.39844 0.17490 -2.278 0.022717 *
## duration 0.01105 0.01900 0.581 0.560943
## replicate2 -0.26340 0.61272 -0.430 0.667270
## replicate3 -1.64889 0.54008 -3.053 0.002265 **
## replicate4 -1.30972 0.63112 -2.075 0.037966 *
## replicate5 -0.40066 0.51992 -0.771 0.440930
## replicate7 -1.30307 0.40147 -3.246 0.001172 **
## replicate9 -0.14636 0.50617 -0.289 0.772461
## replicate11 -1.12182 0.53730 -2.088 0.036808 *
## replicate12 -18.82428 1641.31456 -0.011 0.990849
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 172.648 on 40 degrees of freedom
## Residual deviance: 89.591 on 25 degrees of freedom
## AIC: 191.36
##
## Number of Fisher Scoring iterations: 16
qqnorm(resid(mod1));qqline(resid(mod1))

Anova(mod1)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(live_pupae, dead_pupae)
## LR Chisq Df Pr(>Chisq)
## treatment 22.075 4 0.0001937 ***
## whole.mean 0.745 1 0.3881772
## alive 5.644 1 0.0175158 *
## duration 0.344 1 0.5577133
## replicate 36.303 8 1.546e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(mod1, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(live_pupae, dead_pupae) ~ treatment + whole.mean + alive +
## duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 89.591 191.36
## treatment 4 111.665 205.43 22.075 0.0001937 ***
## whole.mean 1 90.335 190.10 0.745 0.3881772
## alive 1 95.235 195.00 5.644 0.0175158 *
## duration 1 89.934 189.70 0.344 0.5577133
## replicate 8 125.893 211.66 36.303 1.546e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3 <- update(mod1, .~. -alive)
drop1(mod3, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(live_pupae, dead_pupae) ~ treatment + whole.mean + duration +
## replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 95.235 195.00
## treatment 4 123.678 215.44 28.444 1.014e-05 ***
## whole.mean 1 97.767 195.53 2.533 0.1115
## duration 1 95.672 193.44 0.438 0.5082
## replicate 8 145.296 229.06 50.061 3.978e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3 <- update(mod3, .~. -duration)
drop1(mod3, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(live_pupae, dead_pupae) ~ treatment + whole.mean + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 95.672 193.44
## treatment 4 123.967 213.73 28.295 1.087e-05 ***
## whole.mean 1 97.767 193.53 2.095 0.1478
## replicate 8 146.250 228.01 50.577 3.165e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3 <- update(mod3, .~. -whole.mean)
drop1(mod3, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(live_pupae, dead_pupae) ~ treatment + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 97.767 193.53
## treatment 4 125.854 213.62 28.086 1.198e-05 ***
## replicate 8 146.259 226.03 48.492 7.954e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(mod3)




Anova(mod3)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(live_pupae, dead_pupae)
## LR Chisq Df Pr(>Chisq)
## treatment 28.086 4 1.198e-05 ***
## replicate 48.492 8 7.954e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
me <- emmeans(mod3, pairwise ~treatment, type = "response")
me
## $emmeans
## treatment prob SE df asymp.LCL asymp.UCL
## 1 0.3311 40.1 Inf 2.22e-16 1
## 2 0.1032 16.8 Inf 2.22e-16 1
## 3 0.0797 13.3 Inf 2.22e-16 1
## 4 0.1336 21.0 Inf 2.22e-16 1
## 5 0.0723 12.1 Inf 2.22e-16 1
##
## Results are averaged over the levels of: 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
## treatment1 / treatment2 4.300 1.589 Inf 1 3.948 0.0008
## treatment1 / treatment3 5.714 2.148 Inf 1 4.637 <.0001
## treatment1 / treatment4 3.210 1.361 Inf 1 2.751 0.0468
## treatment1 / treatment5 6.348 2.808 Inf 1 4.178 0.0003
## treatment2 / treatment3 1.329 0.409 Inf 1 0.924 0.8879
## treatment2 / treatment4 0.747 0.271 Inf 1 -0.806 0.9287
## treatment2 / treatment5 1.476 0.545 Inf 1 1.055 0.8296
## treatment3 / treatment4 0.562 0.213 Inf 1 -1.520 0.5496
## treatment3 / treatment5 1.111 0.418 Inf 1 0.279 0.9987
## treatment4 / treatment5 1.977 0.838 Inf 1 1.608 0.4920
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio scale
mem <- setDT(as.data.frame(me$emmeans))
mcm <- setDT(as.data.frame(me$contrasts))
mem
## treatment prob SE df asymp.LCL asymp.UCL
## 1: 1 0.33110289 40.09654 Inf 2.220446e-16 1
## 2: 2 0.10323282 16.76030 Inf 2.220446e-16 1
## 3: 3 0.07971717 13.28181 Inf 2.220446e-16 1
## 4: 4 0.13359273 20.95509 Inf 2.220446e-16 1
## 5: 5 0.07233526 12.14858 Inf 2.220446e-16 1
mcm
## contrast odds.ratio SE df null z.ratio
## 1: treatment1 / treatment2 4.2999716 1.5885958 Inf 1 3.9481250
## 2: treatment1 / treatment3 5.7144321 2.1480634 Inf 1 4.6368400
## 3: treatment1 / treatment4 3.2102800 1.3608448 Inf 1 2.7514794
## 4: treatment1 / treatment5 6.3481127 2.8081958 Inf 1 4.1778827
## 5: treatment2 / treatment3 1.3289465 0.4092201 Inf 1 0.9235481
## 6: treatment2 / treatment4 0.7465817 0.2705478 Inf 1 -0.8064699
## 7: treatment2 / treatment5 1.4763150 0.5452997 Inf 1 1.0546443
## 8: treatment3 / treatment4 0.5617846 0.2131772 Inf 1 -1.5196075
## 9: treatment3 / treatment5 1.1108913 0.4184223 Inf 1 0.2792018
## 10: treatment4 / treatment5 1.9774327 0.8383028 Inf 1 1.6082641
## p.value
## 1: 7.506251e-04
## 2: 3.481478e-05
## 3: 4.683279e-02
## 4: 2.844270e-04
## 5: 8.879109e-01
## 6: 9.287367e-01
## 7: 8.296374e-01
## 8: 5.496209e-01
## 9: 9.986723e-01
## 10: 4.919975e-01
alp <- setDT(as.data.frame(Anova(mod3)))
alp
## LR Chisq Df Pr(>Chisq)
## 1: 28.08640 4 1.197998e-05
## 2: 48.49202 8 7.954480e-08
mem$plot <- mem$prob + mem$SE
mem
## treatment prob SE df asymp.LCL asymp.UCL plot
## 1: 1 0.33110289 40.09654 Inf 2.220446e-16 1 40.42764
## 2: 2 0.10323282 16.76030 Inf 2.220446e-16 1 16.86353
## 3: 3 0.07971717 13.28181 Inf 2.220446e-16 1 13.36153
## 4: 4 0.13359273 20.95509 Inf 2.220446e-16 1 21.08868
## 5: 5 0.07233526 12.14858 Inf 2.220446e-16 1 12.22092
mod3
##
## Call: glm(formula = cbind(live_pupae, dead_pupae) ~ treatment + replicate,
## family = binomial("logit"), data = brood)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 replicate2
## 1.8324 -1.4586 -1.7430 -1.1664 -1.8482 0.3932
## replicate3 replicate4 replicate5 replicate7 replicate9 replicate11
## -1.6566 -0.2455 -0.2179 -1.4463 -0.1393 -0.9328
## replicate12
## -18.5751
##
## Degrees of Freedom: 40 Total (i.e. Null); 28 Residual
## Null Deviance: 172.6
## Residual Deviance: 97.77 AIC: 193.5
sum <- brood %>%
group_by(treatment) %>%
summarise(mean.l = mean(live_pupae),
mean.d = mean(dead_pupae),
sd.l = sd(live_pupae),
sd.d = sd(dead_pupae),
n.l = length(live_pupae),
n.d = length(dead_pupae)) %>%
mutate(se.l = sd.l/sqrt(n.l),
se.d = sd.d/sqrt(n.d))
sum$prob.alive <- (sum$mean.l)/(sum$mean.d + sum$mean.l)
sum
## # A tibble: 5 × 10
## treatment mean.l mean.d sd.l sd.d n.l n.d se.l se.d prob.alive
## <fct> <dbl> <dbl> <dbl> <dbl> <int> <int> <dbl> <dbl> <dbl>
## 1 1 4.78 2 4.60 2.06 9 9 1.53 0.687 0.705
## 2 2 5.56 7.89 5.00 12.1 9 9 1.67 4.04 0.413
## 3 3 4.11 8.89 5.75 7.27 9 9 1.92 2.42 0.316
## 4 4 3 2.89 2.87 3.02 9 9 0.957 1.01 0.509
## 5 5 2.89 3.89 2.98 4.28 9 9 0.992 1.43 0.426
cldb <- cld(object = me,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldb
## treatment prob SE df asymp.LCL asymp.UCL .group
## 5 0.0723 12.1 Inf 2.22e-16 1 a
## 3 0.0797 13.3 Inf 2.22e-16 1 a
## 2 0.1032 16.8 Inf 2.22e-16 1 a
## 4 0.1336 21.0 Inf 2.22e-16 1 a
## 1 0.3311 40.1 Inf 2.22e-16 1 b
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the logit scale
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio 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.
ggplot(mem, aes(x = treatment, y = prob, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Probability", title = "Probability of Pupae Being Alive Upon Dissection") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0,0.5)) +
annotate(geom = "text",
x = 1, y = 1.1 ,
label = "P < 0.001",
size = 12) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(0.4, 0.4, 0.4, 0.4, 0.4),
label = c("b", "ab", "ab", "a", "ab"),
size = 12) +
theme(legend.position = "none")

Larvae cbind
mod1 <- glm(cbind(live_larvae, dead_larvae) ~ treatment + whole.mean + alive + duration + replicate, data = brood, family = binomial("logit"))
summary(mod1)
##
## Call:
## glm(formula = cbind(live_larvae, dead_larvae) ~ treatment + whole.mean +
## alive + duration + replicate, family = binomial("logit"),
## data = brood)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.5998 -1.2715 0.4021 0.9750 2.8305
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.03883 0.93464 6.461 1.04e-10 ***
## treatment2 -0.86334 0.39793 -2.170 0.030038 *
## treatment3 -0.62981 0.37013 -1.702 0.088835 .
## treatment4 -1.15179 0.40030 -2.877 0.004010 **
## treatment5 -0.20107 0.45000 -0.447 0.655006
## whole.mean -5.01187 1.23621 -4.054 5.03e-05 ***
## alive -0.27113 0.14896 -1.820 0.068733 .
## duration 0.05460 0.01702 3.207 0.001340 **
## replicate2 -2.92470 0.60605 -4.826 1.39e-06 ***
## replicate3 -1.77858 0.57654 -3.085 0.002036 **
## replicate4 -1.97646 0.52979 -3.731 0.000191 ***
## replicate5 -1.47198 0.57815 -2.546 0.010896 *
## replicate7 -0.19353 0.63378 -0.305 0.760091
## replicate9 -0.24365 0.88605 -0.275 0.783326
## replicate11 -1.38848 0.76434 -1.817 0.069283 .
## replicate12 -5.69275 0.71672 -7.943 1.98e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 329.89 on 42 degrees of freedom
## Residual deviance: 124.40 on 27 degrees of freedom
## AIC: 227.4
##
## Number of Fisher Scoring iterations: 5
qqnorm(resid(mod1));qqline(resid(mod1))

Anova(mod1)
## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(live_larvae, dead_larvae)
## LR Chisq Df Pr(>Chisq)
## treatment 11.897 4 0.018130 *
## whole.mean 18.659 1 1.563e-05 ***
## alive 3.446 1 0.063397 .
## duration 10.753 1 0.001041 **
## replicate 147.015 8 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(mod1)



## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

drop1(mod1, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(live_larvae, dead_larvae) ~ treatment + whole.mean + alive +
## duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 124.40 227.40
## treatment 4 136.30 231.30 11.897 0.018130 *
## whole.mean 1 143.06 244.06 18.659 1.563e-05 ***
## alive 1 127.85 228.84 3.446 0.063397 .
## duration 1 135.16 236.15 10.753 0.001041 **
## replicate 8 271.42 358.41 147.015 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3 <- update(mod1, .~. -alive)
drop1(mod3, test = "Chisq")
## Single term deletions
##
## Model:
## cbind(live_larvae, dead_larvae) ~ treatment + whole.mean + duration +
## replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 127.85 228.84
## treatment 4 146.85 239.84 18.997 0.0007869 ***
## whole.mean 1 161.35 260.34 33.499 7.13e-09 ***
## duration 1 142.69 241.69 14.843 0.0001168 ***
## replicate 8 273.54 358.53 145.690 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(mod3)




me <- emmeans(mod3, pairwise ~treatment, type = "response")
me
## $emmeans
## treatment prob SE df asymp.LCL asymp.UCL
## 1 0.965 0.0107 Inf 0.937 0.981
## 2 0.907 0.0245 Inf 0.847 0.945
## 3 0.923 0.0174 Inf 0.881 0.951
## 4 0.864 0.0339 Inf 0.783 0.918
## 5 0.940 0.0187 Inf 0.891 0.968
##
## Results are averaged over the levels of: 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
## treatment1 / treatment2 2.796 1.084 Inf 1 2.651 0.0615
## treatment1 / treatment3 2.290 0.829 Inf 1 2.289 0.1483
## treatment1 / treatment4 4.304 1.560 Inf 1 4.026 0.0005
## treatment1 / treatment5 1.751 0.723 Inf 1 1.358 0.6547
## treatment2 / treatment3 0.819 0.274 Inf 1 -0.597 0.9756
## treatment2 / treatment4 1.539 0.583 Inf 1 1.140 0.7854
## treatment2 / treatment5 0.626 0.249 Inf 1 -1.174 0.7660
## treatment3 / treatment4 1.880 0.583 Inf 1 2.035 0.2490
## treatment3 / treatment5 0.765 0.287 Inf 1 -0.714 0.9534
## treatment4 / treatment5 0.407 0.166 Inf 1 -2.202 0.1789
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio scale
mem <- setDT(as.data.frame(me$emmeans))
mcm <- setDT(as.data.frame(me$contrasts))
mem
## treatment prob SE df asymp.LCL asymp.UCL
## 1: 1 0.9647340 0.01065203 Inf 0.9367481 0.9805940
## 2: 2 0.9072783 0.02451302 Inf 0.8468015 0.9454199
## 3: 3 0.9227626 0.01742428 Inf 0.8809359 0.9507177
## 4: 4 0.8640648 0.03390217 Inf 0.7830883 0.9179779
## 5: 5 0.9398269 0.01867889 Inf 0.8910106 0.9675741
mcm
## contrast odds.ratio SE df null z.ratio
## 1: treatment1 / treatment2 2.7957078 1.0841160 Inf 1 2.6512164
## 2: treatment1 / treatment3 2.2897535 0.8287044 Inf 1 2.2890346
## 3: treatment1 / treatment4 4.3036429 1.5599222 Inf 1 4.0264844
## 4: treatment1 / treatment5 1.7514791 0.7229100 Inf 1 1.3578940
## 5: treatment2 / treatment3 0.8190246 0.2739677 Inf 1 -0.5968258
## 6: treatment2 / treatment4 1.5393751 0.5826962 Inf 1 1.1396167
## 7: treatment2 / treatment5 0.6264886 0.2494370 Inf 1 -1.1744911
## 8: treatment3 / treatment4 1.8795223 0.5827088 Inf 1 2.0353424
## 9: treatment3 / treatment5 0.7649204 0.2871633 Inf 1 -0.7138309
## 10: treatment4 / treatment5 0.4069759 0.1661563 Inf 1 -2.2019744
## p.value
## 1: 0.0614830706
## 2: 0.1483294047
## 3: 0.0005424497
## 4: 0.6547271400
## 5: 0.9756035165
## 6: 0.7854480508
## 7: 0.7660393002
## 8: 0.2490207528
## 9: 0.9534173008
## 10: 0.1788564451
alp <- setDT(as.data.frame(Anova(mod3)))
alp
## LR Chisq Df Pr(>Chisq)
## 1: 18.99742 4 7.868611e-04
## 2: 33.49905 1 7.129898e-09
## 3: 14.84331 1 1.168215e-04
## 4: 145.68963 8 1.552204e-27
mem$plot <- mem$prob + mem$SE
mem
## treatment prob SE df asymp.LCL asymp.UCL plot
## 1: 1 0.9647340 0.01065203 Inf 0.9367481 0.9805940 0.9753860
## 2: 2 0.9072783 0.02451302 Inf 0.8468015 0.9454199 0.9317913
## 3: 3 0.9227626 0.01742428 Inf 0.8809359 0.9507177 0.9401868
## 4: 4 0.8640648 0.03390217 Inf 0.7830883 0.9179779 0.8979670
## 5: 5 0.9398269 0.01867889 Inf 0.8910106 0.9675741 0.9585058
mod3
##
## Call: glm(formula = cbind(live_larvae, dead_larvae) ~ treatment + whole.mean +
## duration + replicate, family = binomial("logit"), data = brood)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 5.27463 -1.02809 -0.82844 -1.45946 -0.56046 -6.04538
## duration replicate2 replicate3 replicate4 replicate5 replicate7
## 0.06325 -3.00087 -1.85006 -1.70939 -1.24675 -0.16670
## replicate9 replicate11 replicate12
## -0.40235 -1.65855 -5.98046
##
## Degrees of Freedom: 42 Total (i.e. Null); 28 Residual
## Null Deviance: 329.9
## Residual Deviance: 127.9 AIC: 228.8
sum <- brood %>%
group_by(treatment) %>%
summarise(mean.l = mean(live_larvae),
mean.d = mean(dead_larvae),
sd.l = sd(live_larvae),
sd.d = sd(dead_larvae),
n.l = length(live_larvae),
n.d = length(dead_larvae)) %>%
mutate(se.l = sd.l/sqrt(n.l),
se.d = sd.d/sqrt(n.d))
sum$prob.alive <- (sum$mean.l)/(sum$mean.d + sum$mean.l)
sum
## # A tibble: 5 × 10
## treatment mean.l mean.d sd.l sd.d n.l n.d se.l se.d prob.alive
## <fct> <dbl> <dbl> <dbl> <dbl> <int> <int> <dbl> <dbl> <dbl>
## 1 1 26.7 1.78 26.6 1.99 9 9 8.88 0.662 0.938
## 2 2 13.8 3.22 9.72 5.26 9 9 3.24 1.75 0.810
## 3 3 31.2 5.78 23.1 6.22 9 9 7.70 2.07 0.844
## 4 4 17.6 6.67 14.3 14.8 9 9 4.75 4.94 0.725
## 5 5 16.4 1.56 13.4 1.88 9 9 4.47 0.626 0.914
cldb <- cld(object = me,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldb
## treatment prob SE df asymp.LCL asymp.UCL .group
## 4 0.864 0.0339 Inf 0.752 0.930 a
## 2 0.907 0.0245 Inf 0.822 0.954 ab
## 3 0.923 0.0174 Inf 0.864 0.957 ab
## 5 0.940 0.0187 Inf 0.870 0.973 ab
## 1 0.965 0.0107 Inf 0.924 0.984 b
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the logit scale
## P value adjustment: tukey method for comparing a family of 5 estimates
## Tests are performed on the log odds ratio 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.
ggplot(mem, aes(x = treatment, y = prob, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Probability", title = "Probability of Larvae Being Alive Upon Dissection") +
geom_errorbar(aes(ymin = prob - SE, ymax = prob + SE), width = 0.2, position = position_dodge(0.9)) +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0.8,1.1)) +
annotate(geom = "text",
x = 3, y = 1.1 ,
label = "P < 0.001",
size = 12) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(mem$plot + 0.05),
label = c("c", "a", "ab", "ab", "bc"),
size = 12) +
theme(legend.position = "none")

Drone Count
drone.ce$sqr <- (drone.ce$count)^2
dc1 <- glm.nb(count ~ treatment + whole.mean + alive + duration + replicate, data = drone.ce)
## Warning in glm.nb(count ~ treatment + whole.mean + alive + duration +
## replicate, : alternation limit reached
dc2 <- glm.nb(count ~ treatment*whole.mean + alive + duration + replicate, data = drone.ce)
## Warning in glm.nb(count ~ treatment * whole.mean + alive + duration +
## replicate, : alternation limit reached
dc3 <- glm(count ~ treatment + whole.mean + alive + duration + replicate, data = drone.ce, family = "poisson")
summary(dc3) #overdispersed
##
## Call:
## glm(formula = count ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = drone.ce)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9722 -1.0601 -0.3165 0.7621 2.2854
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.77558 0.71298 -1.088 0.276685
## treatment2 -0.03635 0.16107 -0.226 0.821479
## treatment3 -0.36343 0.16560 -2.195 0.028186 *
## treatment4 0.08370 0.17064 0.490 0.623790
## treatment5 0.20407 0.17129 1.191 0.233509
## whole.mean 2.80299 0.45461 6.166 7.02e-10 ***
## alive 0.13425 0.06796 1.975 0.048235 *
## duration 0.02925 0.01533 1.908 0.056342 .
## replicate2 0.32594 0.19870 1.640 0.100935
## replicate3 -0.04694 0.18762 -0.250 0.802451
## replicate4 -0.06918 0.19777 -0.350 0.726471
## replicate5 -0.32560 0.21152 -1.539 0.123725
## replicate7 -0.27885 0.18060 -1.544 0.122577
## replicate9 -0.27318 0.20180 -1.354 0.175837
## replicate11 -0.57746 0.24643 -2.343 0.019115 *
## replicate12 -1.40686 0.38401 -3.664 0.000249 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 275.44 on 44 degrees of freedom
## Residual deviance: 79.40 on 29 degrees of freedom
## AIC: 273.4
##
## Number of Fisher Scoring iterations: 6
dc1sq <- glm.nb(sqr ~ treatment + whole.mean + alive + duration + replicate, data = drone.ce)
dc2sq <- glm.nb(sqr ~ treatment*whole.mean + alive + duration + replicate, data = drone.ce)
## Warning: glm.fit: algorithm did not converge
## Warning in glm.nb(sqr ~ treatment * whole.mean + alive + duration + replicate,
## : alternation limit reached
dc3sq <- glm(sqr ~ treatment + whole.mean + alive + duration + replicate, data = drone.ce, family = "poisson")
summary(dc3sq)
##
## Call:
## glm(formula = sqr ~ treatment + whole.mean + alive + duration +
## replicate, family = "poisson", data = drone.ce)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -11.181 -5.918 -2.122 2.237 17.194
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.48417 0.20396 2.374 0.0176 *
## treatment2 -0.03144 0.04322 -0.728 0.4669
## treatment3 -0.53267 0.04563 -11.673 < 2e-16 ***
## treatment4 0.24822 0.04454 5.573 2.51e-08 ***
## treatment5 0.41218 0.04646 8.872 < 2e-16 ***
## whole.mean 4.45172 0.12654 35.179 < 2e-16 ***
## alive 0.02628 0.01838 1.430 0.1527
## duration 0.05409 0.00436 12.406 < 2e-16 ***
## replicate2 0.23553 0.05204 4.526 6.01e-06 ***
## replicate3 -0.09203 0.04911 -1.874 0.0609 .
## replicate4 -0.20187 0.04803 -4.203 2.64e-05 ***
## replicate5 -0.56618 0.05276 -10.732 < 2e-16 ***
## replicate7 -0.37640 0.04639 -8.113 4.94e-16 ***
## replicate9 -0.42743 0.05358 -7.978 1.49e-15 ***
## replicate11 -1.16656 0.08743 -13.343 < 2e-16 ***
## replicate12 -2.75411 0.18700 -14.728 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 7659.1 on 44 degrees of freedom
## Residual deviance: 2143.3 on 29 degrees of freedom
## AIC: 2424
##
## Number of Fisher Scoring iterations: 6
anova(dc1, dc2, test = "Chisq")
## Likelihood ratio tests of Negative Binomial Models
##
## Response: count
## Model theta Resid. df
## 1 treatment + whole.mean + alive + duration + replicate 18.38429 29
## 2 treatment * whole.mean + alive + duration + replicate 31.97521 25
## 2 x log-lik. Test df LR stat. Pr(Chi)
## 1 -237.8697
## 2 -229.3870 1 vs 2 4 8.482753 0.07541174
AIC(dc1, dc2)
## df AIC
## dc1 17 271.8697
## dc2 21 271.3870
drop1(dc1, test = "Chisq")
## Single term deletions
##
## Model:
## count ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 57.249 269.87
## treatment 4 66.473 271.09 9.224 0.05573 .
## whole.mean 1 84.576 295.20 27.327 1.718e-07 ***
## alive 1 61.532 272.15 4.283 0.03850 *
## duration 1 59.403 270.02 2.155 0.14215
## replicate 8 90.275 286.90 33.026 6.093e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dc4 <- update(dc1, .~. -duration)
## Warning in glm.nb(formula = count ~ treatment + whole.mean + alive + replicate,
## : alternation limit reached
drop1(dc4, test = "Chisq")
## Single term deletions
##
## Model:
## count ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 55.843 269.91
## treatment 4 63.096 269.17 7.253 0.12311
## whole.mean 1 79.374 291.44 23.531 1.229e-06 ***
## alive 1 65.681 277.75 9.838 0.00171 **
## replicate 8 90.932 289.00 35.089 2.576e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(dc4)
##
## Call:
## glm.nb(formula = count ~ treatment + whole.mean + alive + replicate,
## data = drone.ce, init.theta = 14.68324431, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3007 -0.8804 -0.2948 0.5265 2.1204
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.09323 0.41684 0.224 0.82302
## treatment2 -0.15144 0.20786 -0.729 0.46624
## treatment3 -0.46195 0.21536 -2.145 0.03195 *
## treatment4 -0.07613 0.21094 -0.361 0.71815
## treatment5 0.04504 0.21202 0.212 0.83177
## whole.mean 2.83003 0.58163 4.866 1.14e-06 ***
## alive 0.23588 0.07720 3.055 0.00225 **
## replicate2 0.54340 0.25150 2.161 0.03072 *
## replicate3 -0.15243 0.25519 -0.597 0.55028
## replicate4 0.02448 0.28370 0.086 0.93123
## replicate5 -0.38163 0.29723 -1.284 0.19916
## replicate7 -0.37317 0.24662 -1.513 0.13024
## replicate9 -0.23196 0.26640 -0.871 0.38391
## replicate11 -0.62453 0.30246 -2.065 0.03894 *
## replicate12 -1.15649 0.41832 -2.765 0.00570 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(14.6832) family taken to be 1)
##
## Null deviance: 182.707 on 44 degrees of freedom
## Residual deviance: 55.843 on 30 degrees of freedom
## AIC: 271.91
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 14.68
## Std. Err.: 8.33
## Warning while fitting theta: alternation limit reached
##
## 2 x log-likelihood: -239.912
dc4 <- update(dc4, .~. -replicate)
Anova(dc4)
## Analysis of Deviance Table (Type II tests)
##
## Response: count
## LR Chisq Df Pr(>Chisq)
## treatment 4.413 4 0.352943
## whole.mean 32.573 1 1.148e-08 ***
## alive 7.466 1 0.006289 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(dc4)
##
## Call:
## glm.nb(formula = count ~ treatment + whole.mean + alive, data = drone.ce,
## init.theta = 4.343667636, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.061 -1.065 -0.510 0.620 1.737
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.12758 0.39976 -0.319 0.74962
## treatment2 -0.19039 0.28634 -0.665 0.50612
## treatment3 -0.50990 0.29434 -1.732 0.08322 .
## treatment4 -0.06357 0.28568 -0.223 0.82391
## treatment5 0.02116 0.29086 0.073 0.94201
## whole.mean 3.12514 0.53234 5.871 4.34e-09 ***
## alive 0.21788 0.07792 2.796 0.00517 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(4.3437) family taken to be 1)
##
## Null deviance: 109.163 on 44 degrees of freedom
## Residual deviance: 56.648 on 38 degrees of freedom
## AIC: 283.48
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 4.34
## Std. Err.: 1.58
##
## 2 x log-likelihood: -267.481
Anova(dc4)
## Analysis of Deviance Table (Type II tests)
##
## Response: count
## LR Chisq Df Pr(>Chisq)
## treatment 4.413 4 0.352943
## whole.mean 32.573 1 1.148e-08 ***
## alive 7.466 1 0.006289 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(dc4)




drop1(dc1sq, test = "Chisq")
## Warning: glm.fit: algorithm did not converge
## Single term deletions
##
## Model:
## sqr ~ treatment + whole.mean + alive + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 51.577 503.29
## treatment 4 58.759 502.47 7.1820 0.1265750
## whole.mean 1 74.579 524.29 23.0016 1.619e-06 ***
## alive 1 57.808 507.52 6.2306 0.0125560 *
## duration 1 52.211 501.92 0.6334 0.4261035
## replicate 8 82.399 518.11 30.8217 0.0001511 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dc4sq <- update(dc1sq, .~. -duration)
drop1(dc4sq, test = "Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 51.597 501.91
## treatment 4 58.153 500.47 6.556 0.161296
## whole.mean 1 74.405 522.72 22.809 1.790e-06 ***
## alive 1 61.557 509.88 9.961 0.001599 **
## replicate 8 89.496 523.81 37.900 7.856e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
sum <- drone.ce %>%
group_by(treatment) %>%
summarise(mean = mean(count),
sd = sd(count),
n = length(count)) %>%
mutate(se = sd/sqrt(n))
sum
## # A tibble: 5 × 5
## treatment mean sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 9.67 7.47 9 2.49
## 2 2 9.78 6.67 9 2.22
## 3 3 8.67 6.76 9 2.25
## 4 4 12.2 9.13 9 3.04
## 5 5 10.9 6.92 9 2.31
ggplot(sum, aes(x = treatment, y = mean)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Drone Count", title = "Average Drones Produced by Treatment") +
theme_minimal()

dc4
##
## Call: glm.nb(formula = count ~ treatment + whole.mean + alive, data = drone.ce,
## init.theta = 4.343667636, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## -0.12758 -0.19039 -0.50990 -0.06357 0.02116 3.12514
## alive
## 0.21788
##
## Degrees of Freedom: 44 Total (i.e. Null); 38 Residual
## Null Deviance: 109.2
## Residual Deviance: 56.65 AIC: 283.5
da <- setDT(as.data.frame(Anova(dc4)))
da
## LR Chisq Df Pr(>Chisq)
## 1: 4.413376 4 3.529428e-01
## 2: 32.573373 1 1.147765e-08
## 3: 7.465608 1 6.288880e-03
Anova(dc4)
## Analysis of Deviance Table (Type II tests)
##
## Response: count
## LR Chisq Df Pr(>Chisq)
## treatment 4.413 4 0.352943
## whole.mean 32.573 1 1.148e-08 ***
## alive 7.466 1 0.006289 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emdc <- emmeans(dc4, pairwise ~ "treatment", type = "response")
em <- setDT(as.data.frame(emdc$emmeans))
emc <- setDT(as.data.frame(emdc$contrasts))
em
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 9.677313 1.979361 Inf 6.481168 14.44962
## 2: 2 7.999655 1.592026 Inf 5.415917 11.81600
## 3: 3 5.811774 1.222578 Inf 3.848115 8.77747
## 4: 4 9.081289 1.824547 Inf 6.125340 13.46371
## 5: 5 9.884230 1.992752 Inf 6.657831 14.67415
emc
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 1.2097164 0.3463931 Inf 1 0.66488897 0.9638558
## 2: treatment1 / treatment3 1.6651222 0.4901177 Inf 1 1.73232562 0.4139619
## 3: treatment1 / treatment4 1.0656321 0.3044289 Inf 1 0.22251595 0.9994572
## 4: treatment1 / treatment5 0.9790660 0.2847679 Inf 1 -0.07273777 0.9999937
## 5: treatment2 / treatment3 1.3764567 0.3914798 Inf 1 1.12341767 0.7942236
## 6: treatment2 / treatment4 0.8808942 0.2466719 Inf 1 -0.45288099 0.9913331
## 7: treatment2 / treatment5 0.8093351 0.2270304 Inf 1 -0.75412165 0.9434938
## 8: treatment3 / treatment4 0.6399723 0.1823405 Inf 1 -1.56651464 0.5190203
## 9: treatment3 / treatment5 0.5879844 0.1690929 Inf 1 -1.84662909 0.3466784
## 10: treatment4 / treatment5 0.9187654 0.2617942 Inf 1 -0.29733999 0.9983004
Drone Emerge Time
drone.ce.na <- na.omit(drone.ce)
drone.ce.na$sqr <- (drone.ce.na$emerge)^2
descdist(drone.ce.na$emerge, discrete = TRUE)

## summary statistics
## ------
## min: 30 max: 51
## median: 35
## mean: 36.225
## estimated sd: 4.822424
## estimated skewness: 1.752133
## estimated kurtosis: 6.441673
de1 <- glm(emerge ~ treatment + whole.mean + alive + replicate, data = drone.ce.na, family ="quasipoisson")
summary(de1)
##
## Call:
## glm(formula = emerge ~ treatment + whole.mean + alive + replicate,
## family = "quasipoisson", data = drone.ce.na)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.03644 -0.25674 0.00545 0.27912 1.22483
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.653544 0.144688 25.251 <2e-16 ***
## treatment2 -0.061728 0.053350 -1.157 0.2582
## treatment3 -0.011945 0.051512 -0.232 0.8185
## treatment4 -0.108524 0.053852 -2.015 0.0548 .
## treatment5 -0.050911 0.055578 -0.916 0.3684
## whole.mean -0.281800 0.153605 -1.835 0.0785 .
## alive 0.025129 0.026192 0.959 0.3465
## replicate2 0.096293 0.066346 1.451 0.1591
## replicate3 -0.046442 0.067200 -0.691 0.4959
## replicate4 -0.011912 0.078839 -0.151 0.8811
## replicate5 -0.012218 0.082368 -0.148 0.8833
## replicate7 -0.048032 0.065540 -0.733 0.4705
## replicate9 -0.000324 0.066942 -0.005 0.9962
## replicate11 -0.055262 0.065482 -0.844 0.4067
## replicate12 0.147685 0.071870 2.055 0.0505 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for quasipoisson family taken to be 0.3456089)
##
## Null deviance: 23.5381 on 39 degrees of freedom
## Residual deviance: 8.6337 on 25 degrees of freedom
## AIC: NA
##
## Number of Fisher Scoring iterations: 4
de2 <- glm.nb(emerge ~ treatment*whole.mean + alive + replicate , data = drone.ce.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(de2)
##
## Call:
## glm.nb(formula = emerge ~ treatment * whole.mean + alive + replicate,
## data = drone.ce.na, init.theta = 4725554.577, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.79664 -0.27250 0.02079 0.27948 0.80747
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 4.0176503 0.3825969 10.501 <2e-16 ***
## treatment2 -0.4346588 0.3545593 -1.226 0.220
## treatment3 -0.2153216 0.2746982 -0.784 0.433
## treatment4 -0.5276330 0.3344305 -1.578 0.115
## treatment5 -0.0992442 0.3020398 -0.329 0.742
## whole.mean -0.7555286 0.4736934 -1.595 0.111
## alive -0.0068433 0.0559705 -0.122 0.903
## replicate2 0.0812390 0.1165699 0.697 0.486
## replicate3 -0.0159312 0.1268114 -0.126 0.900
## replicate4 -0.0522011 0.1494804 -0.349 0.727
## replicate5 0.0210630 0.1454255 0.145 0.885
## replicate7 0.0006727 0.1150434 0.006 0.995
## replicate9 0.0019656 0.1139552 0.017 0.986
## replicate11 -0.0427379 0.1171277 -0.365 0.715
## replicate12 0.1557526 0.1274373 1.222 0.222
## treatment2:whole.mean 0.7603007 0.6747551 1.127 0.260
## treatment3:whole.mean 0.4369394 0.5131426 0.851 0.394
## treatment4:whole.mean 0.8322939 0.6325692 1.316 0.188
## treatment5:whole.mean 0.1027956 0.6080925 0.169 0.866
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(4725555) family taken to be 1)
##
## Null deviance: 23.5379 on 39 degrees of freedom
## Residual deviance: 5.6963 on 21 degrees of freedom
## AIC: 262.68
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 4725555
## Std. Err.: 159271303
## Warning while fitting theta: iteration limit reached
##
## 2 x log-likelihood: -222.68
de22 <- glm.nb(sqr ~ treatment + whole.mean + alive + replicate + drones, data = drone.ce.na)
summary(de22)
##
## Call:
## glm.nb(formula = sqr ~ treatment + whole.mean + alive + replicate +
## drones, data = drone.ce.na, init.theta = 52.65876732, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.47597 -0.34149 -0.04262 0.52348 2.54332
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 7.306666 0.205243 35.600 < 2e-16 ***
## treatment2 -0.087298 0.077534 -1.126 0.260194
## treatment3 0.045342 0.079906 0.567 0.570415
## treatment4 -0.234213 0.077478 -3.023 0.002503 **
## treatment5 -0.118206 0.080852 -1.462 0.143741
## whole.mean -0.908862 0.267878 -3.393 0.000692 ***
## alive 0.055251 0.037141 1.488 0.136856
## replicate2 0.129295 0.102869 1.257 0.208794
## replicate3 -0.113273 0.095388 -1.187 0.235034
## replicate4 -0.068489 0.114248 -0.599 0.548857
## replicate5 -0.030703 0.115995 -0.265 0.791249
## replicate7 -0.108434 0.092224 -1.176 0.239689
## replicate9 -0.021383 0.096531 -0.222 0.824692
## replicate11 -0.093616 0.094562 -0.990 0.322174
## replicate12 0.331779 0.108331 3.063 0.002194 **
## drones 0.014854 0.006574 2.259 0.023861 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(52.6588) family taken to be 1)
##
## Null deviance: 132.233 on 39 degrees of freedom
## Residual deviance: 39.894 on 24 degrees of freedom
## AIC: 563.75
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 52.7
## Std. Err.: 12.2
##
## 2 x log-likelihood: -529.748
plot(de22)




plot(de1)




de4 <- glm(emerge ~ treatment + whole.mean + alive + replicate + qro, data = drone.ce.na, family = "poisson")
summary(de2) #underdispersed
##
## Call:
## glm.nb(formula = emerge ~ treatment * whole.mean + alive + replicate,
## data = drone.ce.na, init.theta = 4725554.577, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.79664 -0.27250 0.02079 0.27948 0.80747
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 4.0176503 0.3825969 10.501 <2e-16 ***
## treatment2 -0.4346588 0.3545593 -1.226 0.220
## treatment3 -0.2153216 0.2746982 -0.784 0.433
## treatment4 -0.5276330 0.3344305 -1.578 0.115
## treatment5 -0.0992442 0.3020398 -0.329 0.742
## whole.mean -0.7555286 0.4736934 -1.595 0.111
## alive -0.0068433 0.0559705 -0.122 0.903
## replicate2 0.0812390 0.1165699 0.697 0.486
## replicate3 -0.0159312 0.1268114 -0.126 0.900
## replicate4 -0.0522011 0.1494804 -0.349 0.727
## replicate5 0.0210630 0.1454255 0.145 0.885
## replicate7 0.0006727 0.1150434 0.006 0.995
## replicate9 0.0019656 0.1139552 0.017 0.986
## replicate11 -0.0427379 0.1171277 -0.365 0.715
## replicate12 0.1557526 0.1274373 1.222 0.222
## treatment2:whole.mean 0.7603007 0.6747551 1.127 0.260
## treatment3:whole.mean 0.4369394 0.5131426 0.851 0.394
## treatment4:whole.mean 0.8322939 0.6325692 1.316 0.188
## treatment5:whole.mean 0.1027956 0.6080925 0.169 0.866
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(4725555) family taken to be 1)
##
## Null deviance: 23.5379 on 39 degrees of freedom
## Residual deviance: 5.6963 on 21 degrees of freedom
## AIC: 262.68
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 4725555
## Std. Err.: 159271303
## Warning while fitting theta: iteration limit reached
##
## 2 x log-likelihood: -222.68
AIC(de1, de4)
## df AIC
## de1 15 NA
## de4 15 255.6173
AIC(de1, de22)
## df AIC
## de1 15 NA
## de22 17 563.7475
drop1(de22, test ="Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + whole.mean + alive + replicate + drones
## Df Deviance AIC LRT Pr(>Chi)
## <none> 39.894 561.75
## treatment 4 55.154 569.01 15.2600 0.0041912 **
## whole.mean 1 51.058 570.91 11.1644 0.0008338 ***
## alive 1 42.041 561.89 2.1472 0.1428345
## replicate 8 65.871 571.72 25.9772 0.0010598 **
## drones 1 44.992 564.85 5.0980 0.0239535 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
de2 <- update(de22, .~. -alive)
drop1(de2, test = "Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + whole.mean + replicate + drones
## Df Deviance AIC LRT Pr(>Chi)
## <none> 39.938 561.84
## treatment 4 54.675 568.58 14.7372 0.005279 **
## whole.mean 1 49.674 569.58 9.7352 0.001808 **
## replicate 8 62.896 568.80 22.9574 0.003419 **
## drones 1 45.007 564.91 5.0691 0.024356 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(de2)
## Analysis of Deviance Table (Type II tests)
##
## Response: sqr
## LR Chisq Df Pr(>Chisq)
## treatment 14.7372 4 0.005279 **
## whole.mean 9.7352 1 0.001808 **
## replicate 22.9574 8 0.003419 **
## drones 5.0691 1 0.024356 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ggplot(drone.ce.na, aes(x = treatment, y = emerge, fill = treatment)) +
geom_boxplot(alpha = 0.8, width = 0.5, outlier.shape = NA) +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Mean Count of Days", title = "Days Until First Drone Emergence by Treatment") +
theme_minimal() +
theme(legend.position = "right")

plot(de2)




Anova(de2)
## Analysis of Deviance Table (Type II tests)
##
## Response: sqr
## LR Chisq Df Pr(>Chisq)
## treatment 14.7372 4 0.005279 **
## whole.mean 9.7352 1 0.001808 **
## replicate 22.9574 8 0.003419 **
## drones 5.0691 1 0.024356 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
de2
##
## Call: glm.nb(formula = sqr ~ treatment + whole.mean + replicate + drones,
## data = drone.ce.na, init.theta = 49.93446301, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 7.53798 -0.06360 0.07134 -0.22691 -0.07296 -0.86857
## replicate2 replicate3 replicate4 replicate5 replicate7 replicate9
## 0.07829 -0.10785 -0.15136 -0.08726 -0.11242 -0.03911
## replicate11 replicate12 drones
## -0.08568 0.31153 0.01518
##
## Degrees of Freedom: 39 Total (i.e. Null); 25 Residual
## Null Deviance: 125.6
## Residual Deviance: 39.94 AIC: 563.8
ea <- setDT(as.data.frame(Anova(de2)))
ea
## LR Chisq Df Pr(>Chisq)
## 1: 14.737161 4 0.005278589
## 2: 9.735202 1 0.001807722
## 3: 22.957367 8 0.003419415
## 4: 5.069106 1 0.024355939
de2
##
## Call: glm.nb(formula = sqr ~ treatment + whole.mean + replicate + drones,
## data = drone.ce.na, init.theta = 49.93446301, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 7.53798 -0.06360 0.07134 -0.22691 -0.07296 -0.86857
## replicate2 replicate3 replicate4 replicate5 replicate7 replicate9
## 0.07829 -0.10785 -0.15136 -0.08726 -0.11242 -0.03911
## replicate11 replicate12 drones
## -0.08568 0.31153 0.01518
##
## Degrees of Freedom: 39 Total (i.e. Null); 25 Residual
## Null Deviance: 125.6
## Residual Deviance: 39.94 AIC: 563.8
summary(de2)
##
## Call:
## glm.nb(formula = sqr ~ treatment + whole.mean + replicate + drones,
## data = drone.ce.na, init.theta = 49.93446301, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.26612 -0.51200 -0.03185 0.68127 2.65984
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 7.537977 0.136348 55.285 < 2e-16 ***
## treatment2 -0.063604 0.077606 -0.820 0.41246
## treatment3 0.071336 0.079603 0.896 0.37018
## treatment4 -0.226910 0.079343 -2.860 0.00424 **
## treatment5 -0.072957 0.076848 -0.949 0.34244
## whole.mean -0.868574 0.273349 -3.178 0.00149 **
## replicate2 0.078295 0.099402 0.788 0.43089
## replicate3 -0.107847 0.097800 -1.103 0.27015
## replicate4 -0.151364 0.101425 -1.492 0.13560
## replicate5 -0.087258 0.112626 -0.775 0.43848
## replicate7 -0.112418 0.094542 -1.189 0.23441
## replicate9 -0.039112 0.098226 -0.398 0.69049
## replicate11 -0.085681 0.096901 -0.884 0.37658
## replicate12 0.311534 0.110046 2.831 0.00464 **
## drones 0.015183 0.006743 2.252 0.02435 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(49.9345) family taken to be 1)
##
## Null deviance: 125.622 on 39 degrees of freedom
## Residual deviance: 39.938 on 25 degrees of freedom
## AIC: 563.84
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 49.9
## Std. Err.: 11.5
##
## 2 x log-likelihood: -531.841
egm <- emmeans(de2, pairwise ~ treatment, type = "response")
eg <- setDT(as.data.frame(egm$emmeans))
eg
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 1382.809 78.16087 Inf 1237.7975 1544.810
## 2: 2 1297.596 67.45006 Inf 1171.9074 1436.764
## 3: 3 1485.057 79.43264 Inf 1337.2541 1649.195
## 4: 4 1102.088 61.32555 Inf 988.2149 1229.084
## 5: 5 1285.516 68.89925 Inf 1157.3268 1427.904
cg <- setDT(as.data.frame(egm$contrasts))
cg
## contrast ratio SE df null z.ratio
## 1: treatment1 / treatment2 1.0656703 0.08270227 Inf 1 0.8195770
## 2: treatment1 / treatment3 0.9311493 0.07412272 Inf 1 -0.8961379
## 3: treatment1 / treatment4 1.2547173 0.09955321 Inf 1 2.8598600
## 4: treatment1 / treatment5 1.0756842 0.08266459 Inf 1 0.9493617
## 5: treatment2 / treatment3 0.8737686 0.06386258 Inf 1 -1.8462462
## 6: treatment2 / treatment4 1.1773973 0.09039076 Inf 1 2.1271684
## 7: treatment2 / treatment5 1.0093968 0.07645755 Inf 1 0.1234779
## 8: treatment3 / treatment4 1.3474932 0.10990443 Inf 1 3.6566715
## 9: treatment3 / treatment5 1.1552221 0.09131884 Inf 1 1.8253627
## 10: treatment4 / treatment5 0.8573120 0.06591653 Inf 1 -2.0023212
## p.value
## 1: 0.924705664
## 2: 0.898440689
## 3: 0.034428527
## 4: 0.877458404
## 5: 0.346894499
## 6: 0.208432279
## 7: 0.999947706
## 8: 0.002373999
## 9: 0.358784060
## 10: 0.264759847
em_sum <- drone.ce.na %>%
group_by(treatment) %>%
summarise(mean = mean(emerge),
sd = sd(emerge),
n = length(emerge)) %>%
mutate(se = sd/sqrt(n))
em_sum
## # A tibble: 5 × 5
## treatment mean sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 36.7 6.82 7 2.58
## 2 2 35.9 1.89 8 0.666
## 3 3 37.6 5.08 9 1.69
## 4 4 33.8 2.55 8 0.901
## 5 5 37.1 6.29 8 2.22
em_sum$plot <- (em_sum$mean + em_sum$se)
cldemer <- cld(object = egm,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldemer
## treatment response SE df asymp.LCL asymp.UCL .group
## 4 1102 61.3 Inf 955 1271 a
## 5 1286 68.9 Inf 1120 1475 ab
## 2 1298 67.5 Inf 1135 1483 ab
## 1 1383 78.2 Inf 1196 1599 b
## 3 1485 79.4 Inf 1294 1704 b
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## Intervals are back-transformed from the log scale
## P value adjustment: tukey method for comparing a family of 5 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.
ggplot(em_sum, aes(x = treatment, y = mean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Days", title = "Average Time Until First Drone Emergence by Treatment") +
theme_minimal()+ coord_cartesian(ylim = c(30,41)) +
annotate(geom = "text",
label = "P < 0.05",
x = 1, y = 41) +
annotate(geom = "text",
label = c("b", "ab", "b", "a", "ab"),
x = c(1, 2, 3, 4, 5),
y = c(em_sum$plot + 0.4)) +
theme(legend.position = "none")

ggplot(drone.ce.na, aes(x = whole.mean, y = emerge, color = treatment)) +
geom_point(size = 3) +
labs(x = "Average Pollen Consumed(g)", y = "Days", title = "Days Until First Drone Emergence by Average Pollen Consumed") +
theme_minimal() +
scale_color_viridis_d() +
geom_smooth(method = "lm", color = "pink", size = 1)

Drone Radial Cell
shapiro.test(drone.h$radial)
##
## Shapiro-Wilk normality test
##
## data: drone.h$radial
## W = 0.98636, p-value = 0.0006497
n <- is.na(drone.h$radial)
unique(n)
## [1] TRUE FALSE
drone.rad <- na.omit(drone.h)
ggplot(drone.rad, aes(x=radial, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.05 ,col=I("black")) +
scale_fill_manual(values = c("gray90", "gray70", "gray50" , "gray30","gray10"),
name = "Pristine Level",
labels = c("Treatment 1 (control)", "Treatment 2",
"Treatment 3", "Treatment 4", "Treatment 5")) +
ggtitle("Drone Radial Cell Length(mm)") +
labs(y = "Count", x = "Length")

shapiro.test(drone.rad$radial)
##
## Shapiro-Wilk normality test
##
## data: drone.rad$radial
## W = 0.98323, p-value = 0.0002138
drone.rad$sqr <- (drone.rad$radial)^2
shapiro.test(drone.rad$sqr)
##
## Shapiro-Wilk normality test
##
## data: drone.rad$sqr
## W = 0.99177, p-value = 0.03349
ggplot(drone.rad, aes(x=sqr, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.5 ,col=I("black")) +
scale_fill_manual(values = c("gray90", "gray70", "gray50" , "gray30","gray10"),
name = "Pristine Level",
labels = c("Treatment 1 (control)", "Treatment 2",
"Treatment 3", "Treatment 4", "Treatment 5")) +
ggtitle("Drone Radial Cell Length(mm)") +
labs(y = "Count", x = "Length")

dr1 <- lmer(radial ~ treatment + whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
summary(dr1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: radial ~ treatment + whole.mean + alive + duration + replicate +
## (1 | colony)
## Data: drone.rad
##
## REML criterion at convergence: -112
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.9170 -0.4960 0.0595 0.6197 3.6570
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 0.00373 0.06108
## Residual 0.03517 0.18753
## Number of obs: 380, groups: colony, 39
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 2.177888 0.175065 12.440
## treatment2 -0.018231 0.050443 -0.361
## treatment3 -0.109883 0.049445 -2.222
## treatment4 0.026604 0.048903 0.544
## treatment5 -0.004263 0.048568 -0.088
## whole.mean 0.020339 0.161441 0.126
## aliveTRUE 0.357346 0.147065 2.430
## duration -0.002068 0.002524 -0.819
## replicate2 0.085313 0.057761 1.477
## replicate3 0.037381 0.061071 0.612
## replicate4 0.058093 0.059040 0.984
## replicate5 0.035371 0.067440 0.524
## replicate7 0.022353 0.062131 0.360
## replicate9 -0.053065 0.061205 -0.867
## replicate11 -0.055463 0.069602 -0.797
## replicate12 0.131757 0.101195 1.302
dr2 <- lmer(radial ~ treatment + whole.mean + alive + duration + (1|colony), data = drone.rad)
anova(dr1, dr2, test = "Chisq")
## Data: drone.rad
## Models:
## dr2: radial ~ treatment + whole.mean + alive + duration + (1 | colony)
## dr1: radial ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dr2 10 -153.64 -114.234 86.818 -173.64
## dr1 18 -152.84 -81.915 94.419 -188.84 15.202 8 0.05533 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dr3 <- lmer(radial ~ treatment*whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
anova(dr1, dr3)
## Data: drone.rad
## Models:
## dr1: radial ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## dr3: radial ~ treatment * whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dr1 18 -152.84 -81.915 94.419 -188.84
## dr3 22 -150.28 -63.600 97.142 -194.28 5.4461 4 0.2445
dr1 <- lmer(sqr ~ treatment + whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
dr2 <- lmer(sqr ~ treatment + whole.mean + alive + duration + (1|colony), data = drone.rad)
anova(dr1, dr2, test = "Chisq")
## Data: drone.rad
## Models:
## dr2: sqr ~ treatment + whole.mean + alive + duration + (1 | colony)
## dr1: sqr ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dr2 10 1050.2 1089.6 -515.09 1030.2
## dr1 18 1050.2 1121.2 -507.13 1014.2 15.923 8 0.04349 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dr3 <- lmer(sqr~ treatment*whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
anova(dr1, dr3)
## Data: drone.rad
## Models:
## dr1: sqr ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## dr3: sqr ~ treatment * whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dr1 18 1050.2 1121.2 -507.13 1014.2
## dr3 22 1052.4 1139.1 -504.21 1008.4 5.8287 4 0.2123
drop1(dr1, test = "Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + whole.mean + alive + duration + replicate +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1050.2
## treatment 4 1055.2 12.9856 0.011347 *
## whole.mean 1 1048.3 0.0160 0.899393
## alive 1 1055.1 6.8606 0.008812 **
## duration 1 1049.1 0.8879 0.346052
## replicate 8 1050.2 15.9234 0.043489 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dr4 <- update(dr1, .~. -whole.mean)
drop1(dr4, test = "Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + alive + duration + replicate + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1048.3
## treatment 4 1053.3 13.0743 0.010918 *
## alive 1 1053.1 6.8558 0.008835 **
## duration 1 1047.5 1.2548 0.262637
## replicate 8 1048.2 15.9149 0.043614 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dr5 <- update(dr4, .~. -duration)
drop1(dr5, test = "Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + alive + replicate + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1047.5
## treatment 4 1053.1 13.5734 0.008789 **
## alive 1 1052.0 6.4439 0.011133 *
## replicate 8 1047.0 15.4568 0.050849 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dr6 <- update(dr5, .~. -replicate)
drop1(dr6, test = "Chisq")
## Single term deletions
##
## Model:
## sqr ~ treatment + alive + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1047.0
## treatment 4 1047.1 8.1371 0.08668 .
## alive 1 1049.1 4.1445 0.04177 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(dr5, dr6)
## Data: drone.rad
## Models:
## dr6: sqr ~ treatment + alive + (1 | colony)
## dr5: sqr ~ treatment + alive + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dr6 8 1047.0 1078.5 -515.49 1031.0
## dr5 16 1047.5 1110.6 -507.76 1015.5 15.457 8 0.05085 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(dr5)

qqnorm(resid(dr5));qqline(resid(dr5))

plot(dr6)

qqnorm(resid(dr6));qqline(resid(dr6)) #keep dr6

dr6
## Linear mixed model fit by REML ['lmerMod']
## Formula: sqr ~ treatment + alive + (1 | colony)
## Data: drone.rad
## REML criterion at convergence: 1039.559
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 0.3076
## Residual 0.9143
## Number of obs: 380, groups: colony, 39
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4 treatment5 aliveTRUE
## 4.93404 -0.22463 -0.53431 0.06062 -0.16712 1.34903
Anova(dr6)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: sqr
## Chisq Df Pr(>Chisq)
## treatment 7.7819 4 0.09990 .
## alive 3.9012 1 0.04825 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(dr5)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: sqr
## Chisq Df Pr(>Chisq)
## treatment 9.9768 4 0.04082 *
## alive 5.2496 1 0.02195 *
## replicate 11.8906 8 0.15615
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dra <- setDT(as.data.frame(Anova(dr6)))
dra
## Chisq Df Pr(>Chisq)
## 1: 7.781905 4 0.09990201
## 2: 3.901150 1 0.04825306
dre <- emmeans(dr6, pairwise ~ treatment, type = "response")
edr <- setDT(as.data.frame(dre$emmeans))
edr
## treatment emmean SE df lower.CL upper.CL
## 1: 1 5.608551 0.3790441 219.7407 4.861524 6.355578
## 2: 2 5.383923 0.3651304 241.3460 4.664673 6.103172
## 3: 3 5.074238 0.3641745 278.0490 4.357349 5.791127
## 4: 4 5.669166 0.3760726 220.2848 4.928005 6.410327
## 5: 5 5.441428 0.3758816 223.1548 4.700697 6.182160
cdr <- setDT(as.data.frame(dre$contrasts))
cdr
## contrast estimate SE df t.ratio p.value
## 1: treatment1 - treatment2 0.22462827 0.2254278 29.89555 0.9964535 0.8548414
## 2: treatment1 - treatment3 0.53431316 0.2392040 32.04111 2.2337130 0.1934558
## 3: treatment1 - treatment4 -0.06061503 0.2251593 26.42854 -0.2692096 0.9987686
## 4: treatment1 - treatment5 0.16712285 0.2248400 26.95165 0.7432966 0.9442026
## 5: treatment2 - treatment3 0.30968489 0.2335989 34.37651 1.3257122 0.6774385
## 6: treatment2 - treatment4 -0.28524329 0.2203947 28.12215 -1.2942382 0.6967801
## 7: treatment2 - treatment5 -0.05750541 0.2200686 28.71958 -0.2613068 0.9989103
## 8: treatment3 - treatment4 -0.59492818 0.2344669 30.38141 -2.5373651 0.1086566
## 9: treatment3 - treatment5 -0.36719031 0.2341604 30.97321 -1.5681145 0.5280746
## 10: treatment4 - treatment5 0.22773788 0.2197936 25.29950 1.0361444 0.8362544
sum <- drone.rad %>%
group_by(treatment) %>%
summarise(mean = mean(radial),
sd = sd(radial),
n = length(radial)) %>%
mutate(se = sd/sqrt(n))
edr$plot <- (edr$emmean + edr$SE) + 0.5
edr
## treatment emmean SE df lower.CL upper.CL plot
## 1: 1 5.608551 0.3790441 219.7407 4.861524 6.355578 6.487595
## 2: 2 5.383923 0.3651304 241.3460 4.664673 6.103172 6.249053
## 3: 3 5.074238 0.3641745 278.0490 4.357349 5.791127 5.938412
## 4: 4 5.669166 0.3760726 220.2848 4.928005 6.410327 6.545239
## 5: 5 5.441428 0.3758816 223.1548 4.700697 6.182160 6.317310
rad.cld <- cld(object =dre,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
rad.cld
## treatment emmean SE df lower.CL upper.CL .group
## 3 5.07 0.364 278 4.13 6.02 a
## 2 5.38 0.365 241 4.44 6.33 a
## 5 5.44 0.376 223 4.47 6.42 a
## 1 5.61 0.379 220 4.63 6.59 a
## 4 5.67 0.376 220 4.69 6.64 a
##
## Results are averaged over the levels of: alive
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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(edr, aes(x = treatment, y = emmean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
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 = "Squared Radial Cell Length(mm)", title = "Average Drone Radial Cell Length by Treatment (squared)") +
theme_classic(base_size = 25) +
coord_cartesian(ylim=c(0,7)) +
annotate(geom = "text",
x = 3, y = 7,
label = "P > 0.05",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(edr$plot),
label = c("a", "a", "a", "a", "a"),
size = 8) +
theme(legend.position = "none")

Drone Dry Weight
shapiro.test(drone.rad$dry_weight)
##
## Shapiro-Wilk normality test
##
## data: drone.rad$dry_weight
## W = 0.99386, p-value = 0.1279
ggplot(drone.rad, aes(x=dry_weight, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.001 ,col=I("black")) +
scale_fill_manual(values = c("gray90", "gray70", "gray50" , "gray30","gray10"),
name = "Pristine Level",
labels = c("Treatment 1 (control)", "Treatment 2",
"Treatment 3", "Treatment 4", "Treatment 5")) +
ggtitle("Drone Radial Cell Length(mm)") +
labs(y = "Count", x = "Length")

dd1 <- lmer(dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
dd8 <- lmer(dry_weight ~ treatment + whole.mean + alive + duration + (1|colony:replicate), data = drone.rad)
dd9 <- lmer(dry_weight ~ treatment + whole.mean + alive + duration + qro + (1|colony:replicate), data = drone.rad)
plot(dd8)

anova(dd1, dd8)
## Data: drone.rad
## Models:
## dd8: dry_weight ~ treatment + whole.mean + alive + duration + (1 | colony:replicate)
## dd1: dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd8 10 -2582.7 -2543.3 1301.3 -2602.7
## dd1 18 -2590.2 -2519.3 1313.1 -2626.2 23.54 8 0.002735 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(dd8, dd9, dd1)
## Data: drone.rad
## Models:
## dd8: dry_weight ~ treatment + whole.mean + alive + duration + (1 | colony:replicate)
## dd9: dry_weight ~ treatment + whole.mean + alive + duration + qro + (1 | colony:replicate)
## dd1: dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd8 10 -2582.7 -2543.3 1301.3 -2602.7
## dd9 13 -2586.1 -2534.9 1306.1 -2612.1 9.4593 3 0.02377 *
## dd1 18 -2590.2 -2519.3 1313.1 -2626.2 14.0811 5 0.01510 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(dd1, dd9)
## Data: drone.rad
## Models:
## dd9: dry_weight ~ treatment + whole.mean + alive + duration + qro + (1 | colony:replicate)
## dd1: dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd9 13 -2586.1 -2534.9 1306.1 -2612.1
## dd1 18 -2590.2 -2519.3 1313.1 -2626.2 14.081 5 0.0151 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(dd8));qqline(resid(dd8))

drop1(dd8, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ treatment + whole.mean + alive + duration + (1 |
## colony:replicate)
## npar AIC LRT Pr(Chi)
## <none> -2582.7
## treatment 4 -2575.8 14.8725 0.004973 **
## whole.mean 1 -2582.8 1.8645 0.172111
## alive 1 -2579.7 5.0084 0.025224 *
## duration 1 -2583.4 1.2458 0.264350
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dd81 <- update(dd8, .~. -duration)
drop1(dd81, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ treatment + whole.mean + alive + (1 | colony:replicate)
## npar AIC LRT Pr(Chi)
## <none> -2583.4
## treatment 4 -2575.6 15.8684 0.003201 **
## whole.mean 1 -2584.2 1.2003 0.273253
## alive 1 -2580.5 4.9128 0.026659 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dd82 <- update(dd81, .~. -whole.mean)
Anova(dd82)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: dry_weight
## Chisq Df Pr(>Chisq)
## treatment 16.1421 4 0.002834 **
## alive 5.4468 1 0.019604 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(dd82));qqline(resid(dd81))

plot(dd82)

dd2 <- lmer(dry_weight ~ treatment*whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
dd3 <- lmer(dry_weight ~ treatment + whole.mean + alive + duration + (1|colony), data = drone.rad)
dd6 <- lmer(dry_weight ~ treatment + whole.mean + alive + duration + qro + (1|colony), data = drone.rad)
anova(dd1, dd6)
## Data: drone.rad
## Models:
## dd6: dry_weight ~ treatment + whole.mean + alive + duration + qro + (1 | colony)
## dd1: dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd6 13 -2586.1 -2534.9 1306.1 -2612.1
## dd1 18 -2590.2 -2519.3 1313.1 -2626.2 14.081 5 0.0151 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(dd1, dd2)
## Data: drone.rad
## Models:
## dd1: dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## dd2: dry_weight ~ treatment * whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd1 18 -2590.2 -2519.3 1313.1 -2626.2
## dd2 22 -2585.6 -2498.9 1314.8 -2629.6 3.3862 4 0.4954
anova(dd1, dd3)
## Data: drone.rad
## Models:
## dd3: dry_weight ~ treatment + whole.mean + alive + duration + (1 | colony)
## dd1: dry_weight ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd3 10 -2582.7 -2543.3 1301.3 -2602.7
## dd1 18 -2590.2 -2519.3 1313.1 -2626.2 23.54 8 0.002735 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(dd3, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ treatment + whole.mean + alive + duration + (1 |
## colony)
## npar AIC LRT Pr(Chi)
## <none> -2582.7
## treatment 4 -2575.8 14.8725 0.004973 **
## whole.mean 1 -2582.8 1.8645 0.172111
## alive 1 -2579.7 5.0084 0.025224 *
## duration 1 -2583.4 1.2458 0.264350
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dd4 <- update(dd3, .~. -duration)
drop1(dd4, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ treatment + whole.mean + alive + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -2583.4
## treatment 4 -2575.6 15.8684 0.003201 **
## whole.mean 1 -2584.2 1.2003 0.273253
## alive 1 -2580.5 4.9128 0.026659 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dd5 <- update(dd4, .~. -whole.mean)
anova(dd4, dd5)
## Data: drone.rad
## Models:
## dd5: dry_weight ~ treatment + alive + (1 | colony)
## dd4: dry_weight ~ treatment + whole.mean + alive + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd5 8 -2584.2 -2552.7 1300.1 -2600.2
## dd4 9 -2583.4 -2548.0 1300.7 -2601.4 1.2003 1 0.2733
drop1(dd6, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ treatment + whole.mean + alive + duration + qro +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -2586.1
## treatment 4 -2574.8 19.3478 0.0006714 ***
## whole.mean 1 -2588.1 0.0157 0.9002031
## alive 1 -2583.1 4.9910 0.0254790 *
## duration 1 -2585.9 2.2603 0.1327298
## qro 3 -2582.7 9.4593 0.0237686 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dd7 <- update(dd6, .~. -duration)
drop1(dd7, test = "Chisq")
## Single term deletions
##
## Model:
## dry_weight ~ treatment + whole.mean + alive + qro + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -2585.9
## treatment 4 -2573.9 19.9478 0.0005114 ***
## whole.mean 1 -2587.8 0.0694 0.7922432
## alive 1 -2583.0 4.8350 0.0278881 *
## qro 3 -2583.4 8.4448 0.0376598 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dd8 <- update(dd7, .~. -whole.mean)
anova(dd7, dd8)
## Data: drone.rad
## Models:
## dd8: dry_weight ~ treatment + alive + qro + (1 | colony)
## dd7: dry_weight ~ treatment + whole.mean + alive + qro + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd8 11 -2587.8 -2544.5 1304.9 -2609.8
## dd7 12 -2585.9 -2538.6 1304.9 -2609.9 0.0694 1 0.7922
anova(dd5, dd8) #with only one difference in variables (qro) dd5 is significantly better so we will stick with leaving out qro
## Data: drone.rad
## Models:
## dd5: dry_weight ~ treatment + alive + (1 | colony)
## dd8: dry_weight ~ treatment + alive + qro + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## dd5 8 -2584.2 -2552.7 1300.1 -2600.2
## dd8 11 -2587.8 -2544.5 1304.9 -2609.8 9.5758 3 0.02254 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(resid(dd5));qqline(resid(dd5))

qqnorm(resid(dd8));qqline(resid(dd8))

dd5
## Linear mixed model fit by REML ['lmerMod']
## Formula: dry_weight ~ treatment + alive + (1 | colony)
## Data: drone.rad
## REML criterion at convergence: -2533.881
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 0.002351
## Residual 0.007728
## Number of obs: 380, groups: colony, 39
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4 treatment5 aliveTRUE
## 0.030342 -0.004220 -0.006928 -0.001690 -0.001656 0.013378
Anova(dd5)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: dry_weight
## Chisq Df Pr(>Chisq)
## treatment 16.1421 4 0.002834 **
## alive 5.4468 1 0.019604 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dda <- setDT(as.data.frame(Anova(dd5)))
dda
## Chisq Df Pr(>Chisq)
## 1: 16.142146 4 0.002834237
## 2: 5.446793 1 0.019604287
dem <- emmeans(dd5, pairwise ~ treatment, type = "response")
de <- setDT(as.data.frame(dem$emmeans))
ce <- setDT(as.data.frame(dem$contrasts))
de
## treatment emmean SE df lower.CL upper.CL
## 1: 1 0.03703052 0.003155463 232.4260 0.03081356 0.04324749
## 2: 2 0.03281009 0.003043623 255.5910 0.02681632 0.03880386
## 3: 3 0.03010298 0.003042070 289.1300 0.02411557 0.03609039
## 4: 4 0.03534020 0.003130613 232.5106 0.02917221 0.04150819
## 5: 5 0.03537462 0.003129857 236.6559 0.02920868 0.04154056
ce
## contrast estimate SE df t.ratio
## 1: treatment1 - treatment2 4.220431e-03 0.001811605 29.71440 2.32966467
## 2: treatment1 - treatment3 6.927545e-03 0.001925518 31.60841 3.59775671
## 3: treatment1 - treatment4 1.690321e-03 0.001802925 25.83646 0.93754381
## 4: treatment1 - treatment5 1.655903e-03 0.001801612 26.64604 0.91912271
## 5: treatment2 - treatment3 2.707114e-03 0.001883886 34.13507 1.43698394
## 6: treatment2 - treatment4 -2.530110e-03 0.001767964 27.68154 -1.43108633
## 7: treatment2 - treatment5 -2.564528e-03 0.001766626 28.61025 -1.45165355
## 8: treatment3 - treatment4 -5.237224e-03 0.001884518 29.71425 -2.77907922
## 9: treatment3 - treatment5 -5.271642e-03 0.001883262 30.61945 -2.79920871
## 10: treatment4 - treatment5 -3.441855e-05 0.001757724 24.76012 -0.01958132
## p.value
## 1: 0.16382512
## 2: 0.00888931
## 3: 0.87958072
## 4: 0.88699038
## 5: 0.60883100
## 6: 0.61363373
## 7: 0.60072396
## 8: 0.06568513
## 9: 0.06219965
## 10: 0.99999996
de$plot <- de$emmean + de$SE
dd.cld <- cld(object =dem,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
dd.cld
## treatment emmean SE df lower.CL upper.CL .group
## 3 0.0301 0.00304 289 0.0222 0.0380 a
## 2 0.0328 0.00304 256 0.0249 0.0407 ab
## 4 0.0353 0.00313 233 0.0272 0.0434 ab
## 5 0.0354 0.00313 237 0.0273 0.0435 ab
## 1 0.0370 0.00316 232 0.0289 0.0452 b
##
## Results are averaged over the levels of: alive
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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.
de
## treatment emmean SE df lower.CL upper.CL plot
## 1: 1 0.03703052 0.003155463 232.4260 0.03081356 0.04324749 0.04018599
## 2: 2 0.03281009 0.003043623 255.5910 0.02681632 0.03880386 0.03585371
## 3: 3 0.03010298 0.003042070 289.1300 0.02411557 0.03609039 0.03314505
## 4: 4 0.03534020 0.003130613 232.5106 0.02917221 0.04150819 0.03847081
## 5: 5 0.03537462 0.003129857 236.6559 0.02920868 0.04154056 0.03850448
ggplot(de, aes(x = treatment, y = emmean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
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 = "Dry Weight(g)", title = "Average Drone Dry Weight by Treatment") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0.02, 0.042)) +
annotate(geom = "text",
x = 3, y = 0.0425 ,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(de$plot+0.001),
label = c("b", "ab", "a", "ab", "ab"),
size = 8) +
theme(legend.position = "none")

Drone Relative Fat
shapiro.test(drone.rad$relative_fat)
##
## Shapiro-Wilk normality test
##
## data: drone.rad$relative_fat
## W = 0.80183, p-value < 2.2e-16
drone.rad$logrf <- log(drone.rad$relative_fat)
shapiro.test(drone.rad$logrf)
##
## Shapiro-Wilk normality test
##
## data: drone.rad$logrf
## W = 0.93346, p-value = 5.464e-12
ggplot(drone.rad, aes(x=relative_fat, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.0001 ,col=I("black")) +
scale_fill_manual(values = c("gray90", "gray70", "gray50" , "gray30","gray10"),
name = "Pristine Level",
labels = c("Treatment 1 (control)", "Treatment 2",
"Treatment 3", "Treatment 4", "Treatment 5")) +
ggtitle("Drone Relative Fat") +
labs(y = "Count", x = "Relative Fat(g)")

ggplot(drone.rad, aes(x=logrf, fill = treatment)) +
geom_histogram(position = "identity", binwidth = 0.1 ,col=I("black")) +
scale_fill_manual(values = c("gray90", "gray70", "gray50" , "gray30","gray10"),
name = "Pristine Level",
labels = c("Treatment 1 (control)", "Treatment 2",
"Treatment 3", "Treatment 4", "Treatment 5")) +
ggtitle("(Log) Drone Relative Fat") +
labs(y = "Count", x = "log(Realtive Fat)(g)")

rf1 <- lmer(logrf ~ treatment + whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
rf4 <- lmer(relative_fat ~ treatment + whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
rf2 <- lmer(logrf ~ treatment*whole.mean + alive + duration + replicate + (1|colony), data = drone.rad)
anova(rf1,rf2)
## Data: drone.rad
## Models:
## rf1: logrf ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## rf2: logrf ~ treatment * whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## rf1 18 444.64 515.56 -204.32 408.64
## rf2 22 445.62 532.30 -200.81 401.62 7.017 4 0.135
Anova(rf4)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: relative_fat
## Chisq Df Pr(>Chisq)
## treatment 23.6413 4 9.424e-05 ***
## whole.mean 2.7684 1 0.09615 .
## alive 1.7114 1 0.19081
## duration 3.3316 1 0.06796 .
## replicate 10.8442 8 0.21068
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(rf1, test = "Chisq")
## Single term deletions
##
## Model:
## logrf ~ treatment + whole.mean + alive + duration + replicate +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 444.64
## treatment 4 466.28 29.6448 5.781e-06 ***
## whole.mean 1 447.09 4.4530 0.034840 *
## alive 1 449.73 7.0904 0.007750 **
## duration 1 451.17 8.5298 0.003494 **
## replicate 8 446.05 17.4195 0.026025 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
drop1(rf4, test = "Chisq")
## Single term deletions
##
## Model:
## relative_fat ~ treatment + whole.mean + alive + duration + replicate +
## (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -4298.3
## treatment 4 -4280.7 25.5902 3.827e-05 ***
## whole.mean 1 -4296.8 3.4138 0.06465 .
## alive 1 -4298.5 1.7673 0.18371
## duration 1 -4295.8 4.4158 0.03561 *
## replicate 8 -4300.1 14.1249 0.07857 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf11 <- update(rf1, .~. -replicate)
Anova(rf1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: logrf
## Chisq Df Pr(>Chisq)
## treatment 30.7846 4 3.387e-06 ***
## whole.mean 3.8186 1 0.050686 .
## alive 6.8258 1 0.008985 **
## duration 7.0314 1 0.008009 **
## replicate 14.9221 8 0.060678 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(rf11)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: logrf
## Chisq Df Pr(>Chisq)
## treatment 23.5609 4 9.781e-05 ***
## whole.mean 3.9919 1 0.045718 *
## alive 6.1539 1 0.013112 *
## duration 7.0345 1 0.007995 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(rf11, rf1, test = "Chisq")
## Data: drone.rad
## Models:
## rf11: logrf ~ treatment + whole.mean + alive + duration + (1 | colony)
## rf1: logrf ~ treatment + whole.mean + alive + duration + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## rf11 10 446.05 485.46 -213.03 426.05
## rf1 18 444.64 515.56 -204.32 408.64 17.419 8 0.02603 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
rf1
## Linear mixed model fit by REML ['lmerMod']
## Formula: logrf ~ treatment + whole.mean + alive + duration + replicate +
## (1 | colony)
## Data: drone.rad
## REML criterion at convergence: 465.7012
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 0.05535
## Residual 0.42119
## Number of obs: 380, groups: colony, 39
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## -7.045140 -0.042750 -0.290856 -0.097777 0.166494 0.542720
## aliveTRUE duration replicate2 replicate3 replicate4 replicate5
## 0.828742 -0.010935 0.149181 -0.102403 -0.113340 0.049114
## replicate7 replicate9 replicate11 replicate12
## -0.075739 -0.059192 0.004751 0.304848
Anova(rf1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: logrf
## Chisq Df Pr(>Chisq)
## treatment 30.7846 4 3.387e-06 ***
## whole.mean 3.8186 1 0.050686 .
## alive 6.8258 1 0.008985 **
## duration 7.0314 1 0.008009 **
## replicate 14.9221 8 0.060678 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dda <- setDT(as.data.frame(Anova(rf1)))
dda
## Chisq Df Pr(>Chisq)
## 1: 30.784633 4 3.387211e-06
## 2: 3.818633 1 5.068556e-02
## 3: 6.825769 1 8.985186e-03
## 4: 7.031415 1 8.009203e-03
## 5: 14.922124 8 6.067751e-02
qqnorm(resid(rf1));qqline(resid(rf1))

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

plot(rf1)

plot(rf4)

dem <- emmeans(rf1, pairwise ~ treatment, type = "response")
de <- setDT(as.data.frame(dem$emmeans))
ce <- setDT(as.data.frame(dem$contrasts))
de
## treatment emmean SE df lower.CL upper.CL
## 1: 1 -6.767951 0.1686007 224.2147 -7.100195 -6.435706
## 2: 2 -6.810701 0.1638271 223.8188 -7.133542 -6.487860
## 3: 3 -7.058807 0.1625854 271.0471 -7.378898 -6.738716
## 4: 4 -6.865728 0.1642999 225.4283 -7.189488 -6.541968
## 5: 5 -6.601456 0.1673482 222.0688 -6.931250 -6.271663
ce
## contrast estimate SE df t.ratio
## 1: treatment1 - treatment2 0.04275016 0.08669690 20.65598 0.4930990
## 2: treatment1 - treatment3 0.29085597 0.08498726 18.85338 3.4223480
## 3: treatment1 - treatment4 0.09777690 0.08252367 18.33189 1.1848347
## 4: treatment1 - treatment5 -0.16649435 0.08160746 17.20449 -2.0401855
## 5: treatment2 - treatment3 0.24810581 0.08660005 23.29604 2.8649614
## 6: treatment2 - treatment4 0.05502675 0.08385598 18.45465 0.6562054
## 7: treatment2 - treatment5 -0.20924451 0.07891604 19.22875 -2.6514826
## 8: treatment3 - treatment4 -0.19307907 0.08528781 19.21967 -2.2638531
## 9: treatment3 - treatment5 -0.45735032 0.08511939 19.34558 -5.3730452
## 10: treatment4 - treatment5 -0.26427126 0.08496850 18.22361 -3.1102263
## p.value
## 1: 0.987140602
## 2: 0.021309903
## 3: 0.759689234
## 4: 0.289170507
## 5: 0.060210763
## 6: 0.963262164
## 7: 0.099662358
## 8: 0.199276104
## 9: 0.000283778
## 10: 0.041727139
dd.cld <- cld(object =dem,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
predicted_log <-predict(rf1, newdata = drone.rad)
predicted_original <- exp(predicted_log)
result_df <- data.frame(predictors = drone.rad$treatment, predicted_original)
sum <- result_df %>%
group_by(predictors) %>%
summarise(mean = mean(predicted_original),
sd = sd(predicted_original),
n=(length(predicted_original))) %>%
mutate(se = sd/sqrt(n))
sum$plot <- (sum$mean + sum$se)
sum
## # A tibble: 5 × 6
## predictors mean sd n se plot
## <fct> <dbl> <dbl> <int> <dbl> <dbl>
## 1 1 0.00179 0.000280 74 0.0000326 0.00183
## 2 2 0.00160 0.000221 75 0.0000256 0.00163
## 3 3 0.00130 0.000181 59 0.0000236 0.00132
## 4 4 0.00155 0.000119 89 0.0000126 0.00156
## 5 5 0.00196 0.000262 83 0.0000287 0.00199
ggplot(sum, aes(x = predictors, y = mean, fill = predictors)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Relative Fat (g)", title = "Average Drone Abdominal Relative Fat by Treatment") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0.001, 0.002)) +
annotate(geom = "text",
x = 3, y = 0.002 ,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(sum$plot + 3e-05),
label = c("bc", "abc", "a", "ab", "c"),
size = 8) +
theme(legend.position = "none")

ggplot(drone.rad, aes(x = whole.mean, y = radial, color = treatment)) +
geom_point(size = 3) +
labs(x = "Average Pollen Consumed(g)", y = "Relative Fat(g)", title = "Drone Abdominal Relative Fat by Average Pollen Consumed") +
theme_minimal() +
scale_color_viridis_d() +
geom_smooth(method = "lm", color = "pink", size = 1)

Colony Duration
dur1 <- glm(duration ~ treatment + whole.mean + alive + replicate + drones, data = drone.ce)
summary(dur1)
##
## Call:
## glm(formula = duration ~ treatment + whole.mean + alive + replicate +
## drones, data = drone.ce)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -7.8885 -2.2841 0.4456 1.9661 10.7613
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 40.20958 3.88789 10.342 3.06e-11 ***
## treatment2 -4.05819 2.27490 -1.784 0.084909 .
## treatment3 -2.05436 2.47282 -0.831 0.412889
## treatment4 -6.54041 2.19230 -2.983 0.005732 **
## treatment5 -6.08143 2.25836 -2.693 0.011647 *
## whole.mean -14.77238 8.24584 -1.791 0.083656 .
## alive 2.50540 0.66815 3.750 0.000786 ***
## replicate2 4.32732 3.20428 1.350 0.187307
## replicate3 -4.00625 2.96210 -1.353 0.186667
## replicate4 2.01988 3.34628 0.604 0.550790
## replicate5 0.06567 3.35106 0.020 0.984500
## replicate7 -1.76342 2.98341 -0.591 0.559049
## replicate9 3.32749 2.95444 1.126 0.269287
## replicate11 -1.78481 3.04298 -0.587 0.562056
## replicate12 7.22386 3.15575 2.289 0.029543 *
## drones 0.18956 0.20307 0.933 0.358286
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 21.11888)
##
## Null deviance: 1883.20 on 44 degrees of freedom
## Residual deviance: 612.45 on 29 degrees of freedom
## AIC: 279.19
##
## Number of Fisher Scoring iterations: 2
dur3 <- glm(duration ~ treatment*whole.mean + alive + replicate, data = drone.ce)
drop1(dur1, test = "Chisq")
## Single term deletions
##
## Model:
## duration ~ treatment + whole.mean + alive + replicate + drones
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 612.45 279.19
## treatment 4 868.53 286.91 15.7201 0.003419 **
## whole.mean 1 680.23 281.91 4.7234 0.029755 *
## alive 1 909.40 294.98 17.7894 2.468e-05 ***
## replicate 8 1024.06 286.32 23.1328 0.003198 **
## drones 1 630.85 278.52 1.3322 0.248415
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dur2 <- update(dur1, .~. -whole.mean)
anova(dur1, dur2, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: duration ~ treatment + whole.mean + alive + replicate + drones
## Model 2: duration ~ treatment + alive + replicate + drones
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 29 612.45
## 2 30 680.23 -1 -67.78 0.07321 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(dur1, dur2)
## df AIC
## dur1 17 279.1905
## dur2 16 281.9139
Anova(dur1)
## Analysis of Deviance Table (Type II tests)
##
## Response: duration
## LR Chisq Df Pr(>Chisq)
## treatment 12.1256 4 0.016441 *
## whole.mean 3.2095 1 0.073214 .
## alive 14.0609 1 0.000177 ***
## replicate 19.4901 8 0.012447 *
## drones 0.8714 1 0.350578
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(dur1, dur3, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: duration ~ treatment + whole.mean + alive + replicate + drones
## Model 2: duration ~ treatment * whole.mean + alive + replicate
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 29 612.45
## 2 26 526.31 3 86.142 0.2352
plot(dur1)




plot(dur2)




durm <- emmeans(dur2, pairwise ~ treatment, type = "response")
durm
## $emmeans
## treatment emmean SE df lower.CL upper.CL
## 1 46.5 1.65 30 43.1 49.8
## 2 41.7 1.60 30 38.5 45.0
## 3 43.2 1.70 30 39.8 46.7
## 4 40.0 1.67 30 36.5 43.4
## 5 41.0 1.59 30 37.7 44.2
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## treatment1 - treatment2 4.746 2.32 30 2.043 0.2711
## treatment1 - treatment3 3.227 2.47 30 1.306 0.6895
## treatment1 - treatment4 6.507 2.27 30 2.865 0.0542
## treatment1 - treatment5 5.489 2.31 30 2.371 0.1512
## treatment2 - treatment3 -1.518 2.29 30 -0.664 0.9626
## treatment2 - treatment4 1.761 2.35 30 0.749 0.9429
## treatment2 - treatment5 0.743 2.25 30 0.330 0.9973
## treatment3 - treatment4 3.279 2.51 30 1.307 0.6891
## treatment3 - treatment5 2.262 2.31 30 0.981 0.8619
## treatment4 - treatment5 -1.018 2.32 30 -0.438 0.9919
##
## Results are averaged over the levels of: replicate
## P value adjustment: tukey method for comparing a family of 5 estimates
dur2
##
## Call: glm(formula = duration ~ treatment + alive + replicate + drones,
## data = drone.ce)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 alive
## 36.71945 -4.74596 -3.22749 -6.50678 -5.48903 2.19415
## replicate2 replicate3 replicate4 replicate5 replicate7 replicate9
## 6.11571 -4.05650 1.53857 -1.74754 -2.64805 3.88441
## replicate11 replicate12 drones
## -0.84312 8.46662 -0.05065
##
## Degrees of Freedom: 44 Total (i.e. Null); 30 Residual
## Null Deviance: 1883
## Residual Deviance: 680.2 AIC: 281.9
summary(dur2)
##
## Call:
## glm(formula = duration ~ treatment + alive + replicate + drones,
## data = drone.ce)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -8.1576 -1.8997 0.2387 1.9234 11.0078
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 36.71945 3.48627 10.533 1.35e-11 ***
## treatment2 -4.74596 2.32338 -2.043 0.04996 *
## treatment3 -3.22749 2.47079 -1.306 0.20139
## treatment4 -6.50678 2.27152 -2.865 0.00756 **
## treatment5 -5.48903 2.31482 -2.371 0.02435 *
## alive 2.19415 0.66850 3.282 0.00262 **
## replicate2 6.11571 3.15494 1.938 0.06203 .
## replicate3 -4.05650 3.06910 -1.322 0.19625
## replicate4 1.53857 3.45612 0.445 0.65939
## replicate5 -1.74754 3.31011 -0.528 0.60143
## replicate7 -2.64805 3.04868 -0.869 0.39197
## replicate9 3.88441 3.04431 1.276 0.21176
## replicate11 -0.84312 3.10565 -0.271 0.78788
## replicate12 8.46662 3.18991 2.654 0.01260 *
## drones -0.05065 0.15803 -0.321 0.75080
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 22.67426)
##
## Null deviance: 1883.20 on 44 degrees of freedom
## Residual deviance: 680.23 on 30 degrees of freedom
## AIC: 281.91
##
## Number of Fisher Scoring iterations: 2
durmedt <- setDT(as.data.frame(durm$emmeans))
durmcdt <- setDT(as.data.frame(durm$contrasts))
durmedt
## treatment emmean SE df lower.CL upper.CL
## 1: 1 46.46052 1.647546 30 43.09578 49.82526
## 2: 2 41.71456 1.597787 30 38.45144 44.97768
## 3: 3 43.23303 1.703063 30 39.75491 46.71115
## 4: 4 39.95374 1.668630 30 36.54594 43.36153
## 5: 5 40.97149 1.592379 30 37.71941 44.22356
durmcdt
## contrast estimate SE df t.ratio p.value
## 1: treatment1 - treatment2 4.7459577 2.323375 30 2.0426994 0.27105734
## 2: treatment1 - treatment3 3.2274860 2.470792 30 1.3062556 0.68947538
## 3: treatment1 - treatment4 6.5067815 2.271517 30 2.8645099 0.05421493
## 4: treatment1 - treatment5 5.4890312 2.314821 30 2.3712547 0.15118029
## 5: treatment2 - treatment3 -1.5184716 2.287064 30 -0.6639392 0.96258247
## 6: treatment2 - treatment4 1.7608239 2.350514 30 0.7491230 0.94288956
## 7: treatment2 - treatment5 0.7430735 2.249442 30 0.3303368 0.99728269
## 8: treatment3 - treatment4 3.2792955 2.509246 30 1.3068849 0.68909833
## 9: treatment3 - treatment5 2.2615452 2.306373 30 0.9805637 0.86185671
## 10: treatment4 - treatment5 -1.0177503 2.321561 30 -0.4383904 0.99192737
Adur <- setDT(as.data.frame(Anova(dur2)))
Adur
## LR Chisq Df Pr(>Chisq)
## 1: 9.9482850 4 0.0413078832
## 2: 10.7729539 1 0.0010299401
## 3: 29.2951002 8 0.0002814171
## 4: 0.1027289 1 0.7485791141
cldur <- cld(object = durm,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldur
## treatment emmean SE df lower.CL upper.CL .group
## 4 40.0 1.67 30 35.4 44.5 a
## 5 41.0 1.59 30 36.6 45.3 a
## 2 41.7 1.60 30 37.3 46.1 a
## 3 43.2 1.70 30 38.6 47.9 a
## 1 46.5 1.65 30 41.9 51.0 a
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 5 estimates
## P value adjustment: tukey method for comparing a family of 5 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.
durmdf <- as.data.frame(durm$emmeans)
durmdf$plot <- durmdf$emmean + durmdf$SE
ggplot(durmdf, aes(x = treatment, y = emmean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
geom_errorbar(aes(ymin = emmean - SE, ymax = emmean + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Days", title = "Average Colony Duration") +
scale_fill_viridis_d() +
coord_cartesian(ylim=c(35,50))+
theme(legend.position = "none") +
annotate(geom = "text",
x = 3, y = 50,
label = "P = 0.03",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(durmdf$plot+1),
label = c("b", "ab", "ab", "a", "ab"),
size = 6) +
theme(legend.position = "none")

LS0tDQp0aXRsZTogIldpZGVseS11c2VkIGZ1bmdpY2lkZSBQcmlzdGluZcKuIGNhdXNlcyBzdWItbGV0aGFsIGVmZmVjdHMgaW4gY29tbW9uIGVhc3Rlcm4gYnVtYmxlIGJlZSAoKkJvbWJ1cyBpbXBhdGllbnMqKSBtaWNyb2NvbG9uaWVzICINCmF1dGhvcjogIkVtaWx5IFJ1bm5pb24iDQpkYXRlOiAiRGF0YSBDb2xsZWN0ZWQgMjAyMiwgRGF0YSBBbmFseXplZCAyMDIzIg0Kb3V0cHV0Og0KICBodG1sX2RvY3VtZW50Og0KICAgIHRvYzogdHJ1ZQ0KICAgIHRvY19kZXB0aDogNA0KICAgIG51bWJlcl9zZWN0aW9uczog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YXRtZW50IiwgeSA9ICJNZWFuIENvdW50IG9mIEhvbmV5IFBvdHMiLCB0aXRsZSA9ICJDb3VudCBvZiBIb25leSBQb3RzIGJ5IFRyZWF0bWVudCIpICsNCiAgdGhlbWVfbWluaW1hbCgpICsNCiAgdGhlbWUobGVnZW5kLnBvc2l0aW9uID0gInJpZ2h0IikNCg0KaHBfc3VtIDwtIGJyb29kICU+JQ0KICBncm91cF9ieSh0cmVhdG1lbnQpICU+JQ0KICBzdW1tYXJpc2UobWhwID0gbWVhbihob25leV9wb3QpLCANCiAgICAgICAgICAgIHNkaHAgPSBzZChob25leV9wb3QpLA0KICAgICAgICAgICAgbmhwID0gbGVuZ3RoKGhvbmV5X3BvdCkpICU+JQ0KICBtdXRhdGUoc2VocCA9IHNkaHAvc3FydChuaHApKQ0KDQoNCmhwLm1lYW5zIDwtIGVtbWVhbnMob2JqZWN0ID0gaHA0LA0KICAgICAgICAgICAgICAgICAgICAgICAgc3BlY3MgPSAidHJlYXRtZW50IiwNCiAgICAgICAgICAgICAgICAgICAgICAgIGFkanVzdCA9ICJUdWtleSIsDQogICAgICAgICAgICAgICAgICAgICAgICB0eXBlID0gInJlc3BvbnNlIikNCg0KaHBlbSA8LSBzZXREVChhcy5kYXRhLmZyYW1lKGhwLm1lYW5zKSkNCmhwZW0NCg0KaHBhIDwtIHNldERUKGFzLmRhdGEuZnJhbWUocGFpcnMoaHAubWVhbnMpKSkNCmhwYQ0KDQpocC5jbGQubW9kZWwgPC0gY2xkKG9iamVjdCA9IGhwLm1lYW5zLA0KICAgICAgICAgICAgICAgICAgICAgYWRqdXN0ID0gIlR1a2V5IiwNCiAgICAgICAgICAgICAgICAgICAgIExldHRlcnMgPSBsZXR0ZXJzLA0KICAgICAgICAgICAgICAgICAgICAgYWxwaGEgPSAwLjA1KQ0KaHAuY2xkLm1vZGVsDQoNCmdncGxvdChocF9zdW0sIGFlcyh4ID0gdHJlYXRtZW50LCB5ID0gbWhwKSkgKw0KICBnZW9tX2Jh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