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(box ~ treatment + count + bees_alive + replicate + (1|colony), data = pollen)
plot(p3)

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

drop1(p3, test = "Chisq")
## Single term deletions
##
## Model:
## box ~ treatment + count + bees_alive + replicate + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -2858.7
## treatment 4 -2860.0 6.655 0.1553
## count 1 -2632.7 227.945 < 2.2e-16 ***
## bees_alive 1 -2837.5 23.187 1.470e-06 ***
## replicate 8 -2842.5 32.139 8.797e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(p3)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: box
## Chisq Df Pr(>Chisq)
## treatment 4.9947 4 0.2878
## count 255.4752 1 < 2.2e-16 ***
## bees_alive 20.6874 1 5.407e-06 ***
## replicate 33.2642 8 5.519e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(pollen$treatment, pollen$difference)

p7 <- lmer(box ~ treatment + (1|colony), data = pollen)
Anova(p7)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: box
## Chisq Df Pr(>Chisq)
## treatment 2.8907 4 0.5763
p2 <- lmer(box ~ treatment*count + bees_alive + replicate + (1|colony), data = pollen )
plot(p2)

p2
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ treatment * count + bees_alive + replicate + (1 | colony)
## Data: pollen
## REML criterion at convergence: -2725.368
## Random effects:
## Groups Name Std.Dev.
## colony (Intercept) 0.02528
## Residual 0.04852
## Number of obs: 920, groups: colony, 45
## Fixed Effects:
## (Intercept) treatment2 treatment3 treatment4
## 0.0709000 0.0189633 0.0111327 0.0198332
## treatment5 count bees_alive replicate2
## -0.0074442 0.0041487 0.0163141 -0.0230583
## replicate3 replicate4 replicate5 replicate7
## -0.0006633 0.0101403 0.0286123 0.0225163
## replicate9 replicate11 replicate12 treatment2:count
## -0.0146471 -0.0230244 -0.0511175 -0.0001311
## treatment3:count treatment4:count treatment5:count
## 0.0005067 -0.0001179 0.0004880
summary(p2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: box ~ treatment * count + bees_alive + replicate + (1 | colony)
## Data: pollen
##
## REML criterion at convergence: -2725.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6427 -0.6259 -0.0070 0.6782 2.9400
##
## Random effects:
## Groups Name Variance Std.Dev.
## colony (Intercept) 0.0006393 0.02528
## Residual 0.0023545 0.04852
## Number of obs: 920, groups: colony, 45
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 0.0709000 0.0256618 2.763
## treatment2 0.0189633 0.0161823 1.172
## treatment3 0.0111327 0.0160488 0.694
## treatment4 0.0198332 0.0162549 1.220
## treatment5 -0.0074442 0.0160875 -0.463
## count 0.0041487 0.0005508 7.532
## bees_alive 0.0163141 0.0037234 4.381
## replicate2 -0.0230583 0.0173366 -1.330
## replicate3 -0.0006633 0.0175706 -0.038
## replicate4 0.0101403 0.0175161 0.579
## replicate5 0.0286123 0.0176042 1.625
## replicate7 0.0225163 0.0174170 1.293
## replicate9 -0.0146471 0.0173746 -0.843
## replicate11 -0.0230244 0.0173881 -1.324
## replicate12 -0.0511175 0.0174035 -2.937
## treatment2:count -0.0001311 0.0008165 -0.161
## treatment3:count 0.0005067 0.0007758 0.653
## treatment4:count -0.0001179 0.0008084 -0.146
## treatment5:count 0.0004880 0.0007950 0.614
Anova(p2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: box
## Chisq Df Pr(>Chisq)
## treatment 4.9811 4 0.2892
## count 254.6887 1 < 2.2e-16 ***
## bees_alive 19.1971 1 1.179e-05 ***
## replicate 33.3245 8 5.382e-05 ***
## treatment:count 1.2155 4 0.8755
## ---
## 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: 4.981133 4 2.892388e-01
## 2: 254.688660 1 2.467781e-57
## 3: 19.197089 1 1.178931e-05
## 4: 33.324512 8 5.382376e-05
## 5: 1.215454 4 8.755477e-01
qqnorm(resid(p2));qqline(resid(p2))

anova(p3, p2, test = "Chisq")
## Data: pollen
## Models:
## p3: box ~ treatment + count + bees_alive + replicate + (1 | colony)
## p2: box ~ treatment * count + bees_alive + replicate + (1 | colony)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## p3 17 -2858.7 -2776.6 1446.3 -2892.7
## p2 21 -2851.9 -2750.6 1446.9 -2893.9 1.2035 4 0.8775
drop1(p2, test = "Chisq")
## Single term deletions
##
## Model:
## box ~ treatment * count + bees_alive + replicate + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> -2851.9
## bees_alive 1 -2832.1 21.731 3.137e-06 ***
## replicate 8 -2835.7 32.199 8.578e-05 ***
## treatment:count 4 -2858.7 1.203 0.8775
## ---
## 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.00913 31.1 0.175 0.212
## 2 0.211 0.00919 31.9 0.192 0.230
## 3 0.211 0.00915 31.4 0.192 0.229
## 4 0.212 0.00923 32.4 0.193 0.231
## 5 0.192 0.00925 32.6 0.173 0.211
##
## Results are averaged over the levels of: replicate
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## treatment1 - treatment2 -1.74e-02 0.0130 31.5 -1.340 0.6687
## treatment1 - treatment3 -1.73e-02 0.0129 31.3 -1.336 0.6712
## treatment1 - treatment4 -1.84e-02 0.0130 31.6 -1.419 0.6203
## treatment1 - treatment5 1.51e-03 0.0130 31.9 0.116 1.0000
## treatment2 - treatment3 7.94e-05 0.0130 31.5 0.006 1.0000
## treatment2 - treatment4 -1.03e-03 0.0130 32.3 -0.079 1.0000
## treatment2 - treatment5 1.89e-02 0.0130 32.1 1.450 0.6014
## treatment3 - treatment4 -1.11e-03 0.0130 32.1 -0.085 1.0000
## treatment3 - treatment5 1.88e-02 0.0130 31.8 1.447 0.6030
## treatment4 - treatment5 1.99e-02 0.0131 32.8 1.520 0.5574
##
## Results are averaged over the levels of: replicate
## 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.00925 32.6 0.167 0.217 a
## 1 0.193 0.00913 31.1 0.168 0.218 a
## 3 0.211 0.00915 31.4 0.186 0.236 a
## 2 0.211 0.00919 31.9 0.186 0.236 a
## 4 0.212 0.00923 32.4 0.187 0.237 a
##
## Results are averaged over the levels of: replicate
## 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.1934550 0.009131203 31.06814 0.1748335 0.2120766
## 2: 2 0.2108254 0.009187479 31.84905 0.1921076 0.2295431
## 3: 3 0.2107460 0.009153395 31.35906 0.1920862 0.2294058
## 4: 4 0.2118556 0.009228642 32.39435 0.1930665 0.2306448
## 5: 5 0.1919411 0.009253391 32.57773 0.1731057 0.2107765
ecpdt
## contrast estimate SE df t.ratio
## 1: treatment1 - treatment2 -1.737034e-02 0.01295867 31.49955 -1.340442253
## 2: treatment1 - treatment3 -1.729097e-02 0.01293829 31.28873 -1.336418143
## 3: treatment1 - treatment4 -1.840061e-02 0.01296601 31.58590 -1.419141766
## 4: treatment1 - treatment5 1.513915e-03 0.01301091 31.91392 0.116357339
## 5: treatment2 - treatment3 7.937556e-05 0.01295936 31.52138 0.006124958
## 6: treatment2 - treatment4 -1.030268e-03 0.01303983 32.28228 -0.079009275
## 7: treatment2 - treatment5 1.888426e-02 0.01302797 32.09990 1.449516812
## 8: treatment3 - treatment4 -1.109643e-03 0.01302704 32.13109 -0.085180001
## 9: treatment3 - treatment5 1.880488e-02 0.01299631 31.78360 1.446939923
## 10: treatment4 - treatment5 1.991453e-02 0.01310310 32.81566 1.519833091
## p.value
## 1: 0.6687112
## 2: 0.6711758
## 3: 0.6203075
## 4: 0.9999562
## 5: 1.0000000
## 6: 0.9999907
## 7: 0.6013554
## 8: 0.9999874
## 9: 0.6030143
## 10: 0.5574382
ggplot(data = sum, aes(x=treatment, y = mean, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0.3, 0.58)) +
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 = "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)

Pollen over time
pollen$dose <- paste0(pollen$dose, " ppb Pristine")
pollen$days <- 2 * pollen$count
pollen.plot <- ggplot(pollen, aes(x = days, y = difference, color = dose)) +
geom_point(size =5)+
ylab("Mean Polen Consumption(g)") +
xlab("Time (days)") +
scale_fill_viridis_d() +
theme(text = element_text(size = 30)) +
geom_smooth(method = "lm", color = "black") +
theme_cowplot() +
theme(legend.position = "none")
pollen.plot

library(crosstalk)
Whole Mean
wmint <- glm(whole.mean ~ treatment*brood_cells + alive + replicate + drones, data = brood)
wm1 <- glm(whole.mean ~ treatment + brood_cells + alive + replicate + drones, data = brood)
anova(wmint, wm1, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: whole.mean ~ treatment * brood_cells + alive + replicate + drones
## Model 2: whole.mean ~ treatment + brood_cells + alive + replicate + drones
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 25 0.10411
## 2 29 0.12961 -4 -0.025508 0.19
AIC(wmint, wm1)
## df AIC
## wmint 21 -103.4013
## wm1 17 -101.5394
summary(wm1)
##
## Call:
## glm(formula = whole.mean ~ treatment + brood_cells + alive +
## replicate + 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
## brood_cells 0.0058210 0.0009147 6.364 5.91e-07 ***
## 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
## 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 + brood_cells + alive + replicate + drones
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 0.12961 -101.539
## treatment 4 0.13580 -107.441 2.099 0.7176158
## brood_cells 1 0.31060 -64.212 39.328 3.583e-10 ***
## alive 1 0.13156 -102.870 0.669 0.4132482
## replicate 8 0.18642 -101.184 16.355 0.0375664 *
## drones 1 0.16734 -92.043 11.497 0.0006972 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
wm2 <- update(wm1, .~. -alive)
drop1(wm2, .~. -replicate, test = "Chisq")
## Single term deletions
##
## Model:
## whole.mean ~ treatment + brood_cells + replicate + drones
## Df Deviance AIC scaled dev. Pr(>Chi)
## <none> 0.13156 -102.870
## treatment 4 0.13877 -108.466 2.403 0.6619958
## brood_cells 1 0.33312 -63.061 41.809 1.006e-10 ***
## drones 1 0.18183 -90.307 14.563 0.0001355 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
sum <- brood %>%
group_by(treatment) %>%
summarise(mean = mean(whole.mean),
sd = sd(whole.mean),
n = length(whole.mean)) %>%
mutate(se = sd/sqrt(n))
sum$plot <- sum$mean + sum$se
ggplot(data = sum, aes(x=treatment, y = mean, fill = treatment)) +
geom_col(col = "black") +
coord_cartesian(ylim = c(0.3, 0.6)) +
scale_fill_viridis_d() +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9))

sum <- pollen %>%
group_by(colony) %>%
summarise(mean = mean(difference),
sd = sd(difference),
n = length(difference)) %>%
mutate(se = sd/sqrt(n))
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
Survival
workers$survived <- as.logical(workers$survived)
wrksurvive1 <- glmer.nb(survived ~ treatment + whole.mean + (1|colony), data = workers)
## Warning in theta.ml(Y, mu, weights = object@resp$weights, limit = limit, :
## iteration limit reached
drop1(wrksurvive1, test = "Chisq")
## Single term deletions
##
## Model:
## survived ~ treatment + whole.mean + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 452.24
## treatment 4 445.71 1.4634 0.8331
## whole.mean 1 453.36 3.1188 0.0774 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
surv <- workers %>%
group_by(colony) %>%
summarise(died = sum(died))
surv
## # A tibble: 45 × 2
## colony died
## <fct> <dbl>
## 1 1.11R2 0
## 2 1.12R2 5
## 3 1.1R2 0
## 4 1.2R2 1
## 5 1.3R2 0
## 6 1.4R2 4
## 7 1.5R2 1
## 8 1.7R2 0
## 9 1.9R2 3
## 10 2.11R2 0
## # ℹ 35 more rows
dead.sum <- brood %>%
group_by(treatment) %>%
summarise(mean = mean(dead),
sd = sd(dead),
n = length(dead)) %>%
mutate(se = sd/sqrt(n))
dead.sum
## # A tibble: 5 × 5
## treatment mean sd n se
## <fct> <dbl> <dbl> <int> <dbl>
## 1 1 1.56 1.94 9 0.648
## 2 2 0.778 1.64 9 0.547
## 3 3 0.333 0.707 9 0.236
## 4 4 1.11 1.69 9 0.564
## 5 5 0.667 1.66 9 0.553
dead.sum$plot <- dead.sum$mean + dead.sum$se
deadmod <- glm.nb(dead ~ treatment + whole.mean + 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
drop1(deadmod, test = "Chisq")
## Single term deletions
##
## Model:
## dead ~ treatment + whole.mean + duration + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 24.262 96.285
## treatment 4 37.321 101.344 13.059 0.01099 *
## whole.mean 1 49.533 119.556 25.271 4.981e-07 ***
## duration 1 31.867 101.890 7.605 0.00582 **
## replicate 8 66.987 123.010 42.725 9.897e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(deadmod)
##
## Call:
## glm.nb(formula = dead ~ treatment + whole.mean + duration + replicate,
## data = brood, init.theta = 18061.38408, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.08665 -0.59716 -0.00004 0.11394 1.34751
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.179e+01 9.984e+03 -0.002 0.99826
## treatment2 -1.106e+00 5.366e-01 -2.061 0.03930 *
## treatment3 -1.730e+00 6.889e-01 -2.511 0.01205 *
## treatment4 -6.657e-01 5.363e-01 -1.241 0.21448
## treatment5 -1.974e+00 6.859e-01 -2.879 0.00399 **
## whole.mean -5.409e+00 1.225e+00 -4.416 1e-05 ***
## duration 9.929e-02 3.727e-02 2.664 0.00772 **
## replicate2 2.072e+01 9.984e+03 0.002 0.99834
## replicate3 2.021e+01 9.984e+03 0.002 0.99838
## replicate4 2.195e+01 9.984e+03 0.002 0.99825
## replicate5 2.161e+01 9.984e+03 0.002 0.99827
## replicate7 1.136e+00 1.394e+04 0.000 0.99994
## replicate9 1.987e+01 9.984e+03 0.002 0.99841
## replicate11 -8.220e-01 1.428e+04 0.000 0.99995
## replicate12 1.980e+01 9.984e+03 0.002 0.99842
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(18061.38) family taken to be 1)
##
## Null deviance: 99.794 on 44 degrees of freedom
## Residual deviance: 24.262 on 30 degrees of freedom
## AIC: 98.285
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 18061
## Std. Err.: 312078
## Warning while fitting theta: iteration limit reached
##
## 2 x log-likelihood: -66.285
Anova(deadmod)
## Analysis of Deviance Table (Type II tests)
##
## Response: dead
## LR Chisq Df Pr(>Chisq)
## treatment 13.059 4 0.01099 *
## whole.mean 25.271 1 4.981e-07 ***
## duration 7.605 1 0.00582 **
## replicate 42.725 8 9.897e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dm <- emmeans(deadmod, pairwise ~ treatment, type = "response")
pairs(dm)
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 3.022 1.622 Inf 1 2.061 0.2372
## treatment1 / treatment3 5.639 3.885 Inf 1 2.511 0.0882
## treatment1 / treatment4 1.946 1.044 Inf 1 1.241 0.7271
## treatment1 / treatment5 7.203 4.940 Inf 1 2.879 0.0326
## treatment2 / treatment3 1.866 1.311 Inf 1 0.887 0.9017
## treatment2 / treatment4 0.644 0.402 Inf 1 -0.705 0.9555
## treatment2 / treatment5 2.383 1.530 Inf 1 1.353 0.6578
## treatment3 / treatment4 0.345 0.257 Inf 1 -1.430 0.6085
## treatment3 / treatment5 1.277 1.036 Inf 1 0.302 0.9982
## treatment4 / treatment5 3.701 2.818 Inf 1 1.719 0.4221
##
## 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
cld <- cld(object = dm,
alpha = 0.5,
Letters = letters,
adjust = "Tukey")
cld
## treatment response SE df asymp.LCL asymp.UCL .group
## 5 0.000257 0.493 Inf 2.22e-16 Inf a
## 3 0.000328 0.629 Inf 2.22e-16 Inf ab
## 2 0.000611 1.174 Inf 2.22e-16 Inf ab
## 4 0.000950 1.823 Inf 2.22e-16 Inf bc
## 1 0.001848 3.548 Inf 2.22e-16 Inf 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 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.5
## 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 = dead.sum, aes(x=treatment, y=mean, fill=treatment)) +
geom_col(position = "dodge", color = "black") +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
coord_cartesian(ylim = c(0,3)) +
labs(x = "Treatment", y = "Count", title ="Average Count of Dead Workers per Treatment") +
theme(text = element_text(size = 20)) +
annotate(geom = "text",
x = 1, y = 3,
label = "P = 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(dead.sum$plot + 0.3),
label = c("c", "ab", "ab", "bc", "a"),
size = 8) +
theme(legend.position = "none")

Days Alive
wrkdays1 <- glmer.nb(days_alive ~ treatment + whole.mean + (1|colony), data = workers)
## Warning in theta.ml(Y, mu, weights = object@resp$weights, limit = limit, :
## iteration limit reached
drop1(wrkdays1, test = "Chisq")
## Single term deletions
##
## Model:
## days_alive ~ treatment + whole.mean + (1 | colony)
## npar AIC LRT Pr(Chi)
## <none> 1556.2
## treatment 4 1552.6 4.3423 0.3617
## whole.mean 1 1554.4 0.1711 0.6791
Anova(wrkdays1)
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: days_alive
## Chisq Df Pr(>Chisq)
## treatment 4.5552 4 0.3361
## whole.mean 0.4086 1 0.5227
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
summary(cbw1)
##
## Call:
## glm(formula = cbind(alive, dead) ~ treatment + whole.mean + qro +
## duration, family = binomial("logit"), data = cbindworkers)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.7044 -0.3201 0.2136 0.8125 2.3644
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 4.92270 1.86309 2.642 0.008236 **
## treatment2 1.78014 0.74437 2.391 0.016781 *
## treatment3 3.17661 0.97071 3.272 0.001066 **
## treatment4 0.68242 0.69123 0.987 0.323519
## treatment5 3.04557 0.91055 3.345 0.000824 ***
## whole.mean 11.39681 2.35481 4.840 1.30e-06 ***
## qroB3 -1.13377 0.85242 -1.330 0.183496
## qroB4 -5.80915 1.39582 -4.162 3.16e-05 ***
## qroB5 -3.31437 0.72563 -4.568 4.93e-06 ***
## duration -0.17584 0.04614 -3.811 0.000138 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 143.651 on 44 degrees of freedom
## Residual deviance: 55.296 on 35 degrees of freedom
## AIC: 98.077
##
## Number of Fisher Scoring iterations: 6
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")

work_surv_bw <- 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 = "Worker Probability of Survival") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
theme(text = element_text(size = 20)) +
theme_cowplot() +
scale_fill_grey() +
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",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) # Set axis title font size
work_surv_col <- 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 = "Worker Probability of Survival") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
theme_cowplot() +
scale_fill_viridis_d() +
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",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
coxph workers
workers <- workers %>% mutate(worker_id = row_number())
workers$worker_id <- as.factor(workers$worker_id)
library(survminer)
## Warning: package 'survminer' was built under R version 4.2.3
res.cox <- coxph(Surv(days_alive, alive_at_end) ~ treatment + whole.mean + qro + cluster(worker_id), data = workers)
res.cox
## Call:
## coxph(formula = Surv(days_alive, alive_at_end) ~ treatment +
## whole.mean + qro, data = workers, cluster = worker_id)
##
## coef exp(coef) se(coef) robust se z p
## treatment2 0.2657 1.3043 0.2822 0.2875 0.924 0.35550
## treatment3 -0.1399 0.8694 0.2901 0.3238 -0.432 0.66560
## treatment4 1.0007 2.7202 0.3150 0.3706 2.700 0.00693
## treatment5 0.4436 1.5584 0.2691 0.2731 1.624 0.10428
## whole.mean 5.0470 155.5494 0.6431 0.6889 7.326 2.38e-13
## qroB3 0.7967 2.2182 0.2791 0.2500 3.186 0.00144
## qroB4 0.3302 1.3912 0.3410 0.3450 0.957 0.33848
## qroB5 -0.3682 0.6920 0.2143 0.2167 -1.699 0.08936
##
## Likelihood ratio test=134 on 8 df, p=< 2.2e-16
## n= 224, number of events= 186
summary(res.cox)
## Call:
## coxph(formula = Surv(days_alive, alive_at_end) ~ treatment +
## whole.mean + qro, data = workers, cluster = worker_id)
##
## n= 224, number of events= 186
##
## coef exp(coef) se(coef) robust se z Pr(>|z|)
## treatment2 0.2657 1.3043 0.2822 0.2875 0.924 0.35550
## treatment3 -0.1399 0.8694 0.2901 0.3238 -0.432 0.66560
## treatment4 1.0007 2.7202 0.3150 0.3706 2.700 0.00693 **
## treatment5 0.4436 1.5584 0.2691 0.2731 1.624 0.10428
## whole.mean 5.0470 155.5494 0.6431 0.6889 7.326 2.38e-13 ***
## qroB3 0.7967 2.2182 0.2791 0.2500 3.186 0.00144 **
## qroB4 0.3302 1.3912 0.3410 0.3450 0.957 0.33848
## qroB5 -0.3682 0.6920 0.2143 0.2167 -1.699 0.08936 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## treatment2 1.3043 0.766682 0.7424 2.292
## treatment3 0.8694 1.150206 0.4609 1.640
## treatment4 2.7202 0.367624 1.3157 5.624
## treatment5 1.5584 0.641692 0.9124 2.662
## whole.mean 155.5494 0.006429 40.3131 600.193
## qroB3 2.2182 0.450812 1.3589 3.621
## qroB4 1.3912 0.718797 0.7076 2.735
## qroB5 0.6920 1.445100 0.4525 1.058
##
## Concordance= 0.78 (se = 0.016 )
## Likelihood ratio test= 134 on 8 df, p=<2e-16
## Wald test = 247.7 on 8 df, p=<2e-16
## Score (logrank) test = 156.4 on 8 df, p=<2e-16, Robust = 118.4 p=<2e-16
##
## (Note: the likelihood ratio and score tests assume independence of
## observations within a cluster, the Wald and robust score tests do not).
Anova(res.cox)
## Warning in Anova.coxph(res.cox): LR tests unavailable with robust variances
## Wald tests substituted
## Analysis of Deviance Table (Type II tests)
##
## Response: Surv(days_alive, alive_at_end)
## Df Chisq Pr(>Chisq)
## treatment 4 22.854 0.0001354 ***
## whole.mean 1 53.667 2.376e-13 ***
## qro 3 25.140 1.444e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emm.cox <- emmeans(res.cox, pairwise ~ treatment, type = "response")
pairs(emm.cox)
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 0.767 0.2205 Inf 1 -0.924 0.8877
## treatment1 / treatment3 1.150 0.3724 Inf 1 0.432 0.9928
## treatment1 / treatment4 0.368 0.1362 Inf 1 -2.700 0.0539
## treatment1 / treatment5 0.642 0.1752 Inf 1 -1.624 0.4816
## treatment2 / treatment3 1.500 0.3122 Inf 1 1.949 0.2914
## treatment2 / treatment4 0.480 0.1098 Inf 1 -3.209 0.0116
## treatment2 / treatment5 0.837 0.1669 Inf 1 -0.892 0.8999
## treatment3 / treatment4 0.320 0.0903 Inf 1 -4.035 0.0005
## treatment3 / treatment5 0.558 0.1371 Inf 1 -2.376 0.1220
## treatment4 / treatment5 1.746 0.5584 Inf 1 1.741 0.4086
##
## 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 scale
surv_model <- survfit(res.cox, data = workers)
# Plot the survival curves using ggsurvplot
ggsurvplot(surv_model, color = "#2E9FDF", ggtheme = theme_minimal())
## Warning: Now, to change color palette, use the argument palette= '#2E9FDF'
## instead of color = '#2E9FDF'

surv_model <- survfit(res.cox, data = workers)
require("survival")
fit <- survfit(Surv(days_alive, alive_at_end) ~ treatment, data = workers)
ggsurvplot(fit, data = workers)

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
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
Anova(e5)
## Analysis of Deviance Table (Type II tests)
##
## Response: eggs
## LR Chisq Df Pr(>Chisq)
## treatment 4.2268 4 0.376181
## whole.mean 4.7488 1 0.029319 *
## replicate 24.3217 8 0.002024 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
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
egm.rep <- emmeans(e5, pairwise ~ replicate, type = "response")
summary(egm.rep)
## $emmeans
## replicate response SE df asymp.LCL asymp.UCL
## 1 6.04 2.75 Inf 2.475 15
## 2 5.75 2.69 Inf 2.300 14
## 3 7.39 3.31 Inf 3.073 18
## 4 13.88 6.05 Inf 5.908 33
## 5 10.33 4.93 Inf 4.047 26
## 7 2.54 1.28 Inf 0.945 7
## 9 3.96 1.90 Inf 1.545 10
## 11 4.24 2.12 Inf 1.598 11
## 12 0.00 0.00 Inf 0.000 Inf
##
## Results are averaged over the levels of: treatment
## Confidence level used: 0.95
## Intervals are back-transformed from the log scale
##
## $contrasts
## contrast ratio SE df null z.ratio p.value
## replicate1 / replicate2 1.00e+00 1.00e+00 Inf 1 0.074 1.0000
## replicate1 / replicate3 1.00e+00 1.00e+00 Inf 1 -0.316 1.0000
## replicate1 / replicate4 0.00e+00 0.00e+00 Inf 1 -1.333 0.9215
## replicate1 / replicate5 1.00e+00 0.00e+00 Inf 1 -0.834 0.9959
## replicate1 / replicate7 2.00e+00 2.00e+00 Inf 1 1.304 0.9306
## replicate1 / replicate9 2.00e+00 1.00e+00 Inf 1 0.636 0.9994
## replicate1 / replicate11 1.00e+00 1.00e+00 Inf 1 0.516 0.9999
## replicate1 / replicate12 4.01e+12 1.14e+18 Inf 1 0.000 1.0000
## replicate2 / replicate3 1.00e+00 1.00e+00 Inf 1 -0.386 1.0000
## replicate2 / replicate4 0.00e+00 0.00e+00 Inf 1 -1.361 0.9123
## replicate2 / replicate5 1.00e+00 0.00e+00 Inf 1 -0.848 0.9953
## replicate2 / replicate7 2.00e+00 2.00e+00 Inf 1 1.162 0.9643
## replicate2 / replicate9 1.00e+00 1.00e+00 Inf 1 0.561 0.9998
## replicate2 / replicate11 1.00e+00 1.00e+00 Inf 1 0.453 1.0000
## replicate2 / replicate12 3.82e+12 1.08e+18 Inf 1 0.000 1.0000
## replicate3 / replicate4 1.00e+00 0.00e+00 Inf 1 -1.012 0.9849
## replicate3 / replicate5 1.00e+00 0.00e+00 Inf 1 -0.515 0.9999
## replicate3 / replicate7 3.00e+00 2.00e+00 Inf 1 1.596 0.8075
## replicate3 / replicate9 2.00e+00 1.00e+00 Inf 1 0.949 0.9900
## replicate3 / replicate11 2.00e+00 1.00e+00 Inf 1 0.824 0.9962
## replicate3 / replicate12 4.90e+12 1.39e+18 Inf 1 0.000 1.0000
## replicate4 / replicate5 1.00e+00 1.00e+00 Inf 1 0.475 0.9999
## replicate4 / replicate7 5.00e+00 4.00e+00 Inf 1 2.624 0.1765
## replicate4 / replicate9 4.00e+00 2.00e+00 Inf 1 1.922 0.5983
## replicate4 / replicate11 3.00e+00 2.00e+00 Inf 1 1.756 0.7115
## replicate4 / replicate12 9.20e+12 2.62e+18 Inf 1 0.000 1.0000
## replicate5 / replicate7 4.00e+00 3.00e+00 Inf 1 2.186 0.4148
## replicate5 / replicate9 3.00e+00 2.00e+00 Inf 1 1.391 0.9016
## replicate5 / replicate11 2.00e+00 2.00e+00 Inf 1 1.226 0.9509
## replicate5 / replicate12 6.85e+12 1.95e+18 Inf 1 0.000 1.0000
## replicate7 / replicate9 1.00e+00 0.00e+00 Inf 1 -0.630 0.9994
## replicate7 / replicate11 1.00e+00 0.00e+00 Inf 1 -0.698 0.9988
## replicate7 / replicate12 1.68e+12 4.79e+17 Inf 1 0.000 1.0000
## replicate9 / replicate11 1.00e+00 1.00e+00 Inf 1 -0.101 1.0000
## replicate9 / replicate12 2.63e+12 7.47e+17 Inf 1 0.000 1.0000
## replicate11 / replicate12 2.81e+12 8.00e+17 Inf 1 0.000 1.0000
##
## Results are averaged over the levels of: treatment
## P value adjustment: tukey method for comparing a family of 9 estimates
## Tests are performed on the log scale
anova(e5)
## Warning in anova.negbin(e5): tests made without re-estimating 'theta'
## Analysis of Deviance Table
##
## Model: Negative Binomial(1.1765), link: log
##
## Response: eggs
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 44 101.645
## treatment 4 8.7491 40 92.896 0.067685 .
## whole.mean 1 20.3387 39 72.558 6.488e-06 ***
## replicate 8 24.3217 31 48.236 0.002024 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairs(egm.rep)
## contrast ratio SE df null z.ratio p.value
## replicate1 / replicate2 1.00e+00 1.00e+00 Inf 1 0.074 1.0000
## replicate1 / replicate3 1.00e+00 1.00e+00 Inf 1 -0.316 1.0000
## replicate1 / replicate4 0.00e+00 0.00e+00 Inf 1 -1.333 0.9215
## replicate1 / replicate5 1.00e+00 0.00e+00 Inf 1 -0.834 0.9959
## replicate1 / replicate7 2.00e+00 2.00e+00 Inf 1 1.304 0.9306
## replicate1 / replicate9 2.00e+00 1.00e+00 Inf 1 0.636 0.9994
## replicate1 / replicate11 1.00e+00 1.00e+00 Inf 1 0.516 0.9999
## replicate1 / replicate12 4.01e+12 1.14e+18 Inf 1 0.000 1.0000
## replicate2 / replicate3 1.00e+00 1.00e+00 Inf 1 -0.386 1.0000
## replicate2 / replicate4 0.00e+00 0.00e+00 Inf 1 -1.361 0.9123
## replicate2 / replicate5 1.00e+00 0.00e+00 Inf 1 -0.848 0.9953
## replicate2 / replicate7 2.00e+00 2.00e+00 Inf 1 1.162 0.9643
## replicate2 / replicate9 1.00e+00 1.00e+00 Inf 1 0.561 0.9998
## replicate2 / replicate11 1.00e+00 1.00e+00 Inf 1 0.453 1.0000
## replicate2 / replicate12 3.82e+12 1.08e+18 Inf 1 0.000 1.0000
## replicate3 / replicate4 1.00e+00 0.00e+00 Inf 1 -1.012 0.9849
## replicate3 / replicate5 1.00e+00 0.00e+00 Inf 1 -0.515 0.9999
## replicate3 / replicate7 3.00e+00 2.00e+00 Inf 1 1.596 0.8075
## replicate3 / replicate9 2.00e+00 1.00e+00 Inf 1 0.949 0.9900
## replicate3 / replicate11 2.00e+00 1.00e+00 Inf 1 0.824 0.9962
## replicate3 / replicate12 4.90e+12 1.39e+18 Inf 1 0.000 1.0000
## replicate4 / replicate5 1.00e+00 1.00e+00 Inf 1 0.475 0.9999
## replicate4 / replicate7 5.00e+00 4.00e+00 Inf 1 2.624 0.1765
## replicate4 / replicate9 4.00e+00 2.00e+00 Inf 1 1.922 0.5983
## replicate4 / replicate11 3.00e+00 2.00e+00 Inf 1 1.756 0.7115
## replicate4 / replicate12 9.20e+12 2.62e+18 Inf 1 0.000 1.0000
## replicate5 / replicate7 4.00e+00 3.00e+00 Inf 1 2.186 0.4148
## replicate5 / replicate9 3.00e+00 2.00e+00 Inf 1 1.391 0.9016
## replicate5 / replicate11 2.00e+00 2.00e+00 Inf 1 1.226 0.9509
## replicate5 / replicate12 6.85e+12 1.95e+18 Inf 1 0.000 1.0000
## replicate7 / replicate9 1.00e+00 0.00e+00 Inf 1 -0.630 0.9994
## replicate7 / replicate11 1.00e+00 0.00e+00 Inf 1 -0.698 0.9988
## replicate7 / replicate12 1.68e+12 4.79e+17 Inf 1 0.000 1.0000
## replicate9 / replicate11 1.00e+00 1.00e+00 Inf 1 -0.101 1.0000
## replicate9 / replicate12 2.63e+12 7.47e+17 Inf 1 0.000 1.0000
## replicate11 / replicate12 2.81e+12 8.00e+17 Inf 1 0.000 1.0000
##
## Results are averaged over the levels of: treatment
## P value adjustment: tukey method for comparing a family of 9 estimates
## Tests are performed on the log scale
eggs.letters <- cld(object = egm.rep,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
eggs.letters
## replicate response SE df asymp.LCL asymp.UCL .group
## 12 0.00 0.00 Inf 0.00 Inf a
## 7 2.54 1.28 Inf 0.63 10 a
## 9 3.96 1.90 Inf 1.05 15 a
## 11 4.24 2.12 Inf 1.07 17 a
## 2 5.75 2.69 Inf 1.58 21 a
## 1 6.04 2.75 Inf 1.71 21 a
## 3 7.39 3.31 Inf 2.14 25 a
## 5 10.33 4.93 Inf 2.75 39 a
## 4 13.88 6.05 Inf 4.16 46 a
##
## Results are averaged over the levels of: treatment
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 9 estimates
## Intervals are back-transformed from the log scale
## P value adjustment: tukey method for comparing a family of 9 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.
egg_sum.rep <- brood %>%
group_by(replicate) %>%
summarise(me = mean(eggs),
sde = sd(eggs),
ne = length(eggs)) %>%
mutate(see = sde/sqrt(ne))
egg_sum.rep$plot <- egg_sum.rep$me + egg_sum.rep$see
egg_sum.rep
## # A tibble: 9 × 6
## replicate me sde ne see plot
## <fct> <dbl> <dbl> <int> <dbl> <dbl>
## 1 1 5.8 6.18 5 2.76 8.56
## 2 2 5.8 7.29 5 3.26 9.06
## 3 3 9.6 6.77 5 3.03 12.6
## 4 4 15 12.0 5 5.38 20.4
## 5 5 25.2 35.0 5 15.6 40.8
## 6 7 3.6 3.29 5 1.47 5.07
## 7 9 3.8 3.19 5 1.43 5.23
## 8 11 3.8 5.85 5 2.62 6.42
## 9 12 0 0 5 0 0
ggplot(egg_sum.rep, aes(x = replicate, y = me, fill = replicate)) +
geom_bar(stat = "identity", color = "black") +
geom_errorbar(aes(ymin = me - see, ymax = me + see), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Location in Rearing Room", y = "Eggs") +
theme_classic(base_size = 30)+
theme_cowplot() +
coord_cartesian(ylim = c(0,48)) +
scale_fill_viridis_d() +
annotate(geom = "text",
label = "P < 0.01",
x = 1, y = 41) +
annotate(geom = "text",
label = c("a", "a", "a", "a", "a", "a", "a", "a", "a"),
x = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
y = c(egg_sum.rep$plot + 2)) +
theme(legend.position = "none") +
scale_x_discrete(labels = c("1", "2", "3", "4", "5", "6", "7", "8", "9"))

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(hp1, .~. -duration)
drop1(hp5, test = "Chisq")
## Single term deletions
##
## Model:
## honey_pot ~ treatment + whole.mean + alive + replicate
## Df Deviance AIC LRT Pr(>Chi)
## <none> 51.695 242.18
## treatment 4 58.630 241.11 6.9346 0.1393870
## whole.mean 1 64.585 253.07 12.8895 0.0003304 ***
## alive 1 54.818 243.30 3.1231 0.0771906 .
## replicate 8 61.101 235.58 9.4056 0.3092455
## ---
## 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> 55.751 235.35
## treatment 4 62.691 234.29 6.9398 0.139103
## whole.mean 1 65.522 243.12 9.7702 0.001774 **
## alive 1 61.327 238.92 5.5759 0.018209 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(hp4) #this is what we are keeping
## Analysis of Deviance Table (Type II tests)
##
## Response: honey_pot
## LR Chisq Df Pr(>Chisq)
## treatment 6.9398 4 0.139103
## whole.mean 9.7702 1 0.001774 **
## alive 5.5759 1 0.018209 *
## ---
## 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 6.9346 4 0.1393870
## whole.mean 12.8895 1 0.0003304 ***
## alive 3.1231 1 0.0771906 .
## replicate 9.4056 8 0.3092455
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(brood$alive, brood$honey_pot)

ha <- setDT(as.data.frame(Anova(hp4)))
ha
## LR Chisq Df Pr(>Chisq)
## 1: 6.939816 4 0.13910307
## 2: 9.770212 1 0.00177362
## 3: 5.575943 1 0.01820885
hp4
##
## Call: glm.nb(formula = honey_pot ~ treatment + whole.mean + alive,
## data = brood, init.theta = 17.17564907, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 whole.mean
## 0.25431 0.48891 0.04221 0.37416 0.28792 1.34428
## alive
## 0.14517
##
## Degrees of Freedom: 44 Total (i.e. Null); 38 Residual
## Null Deviance: 87.31
## Residual Deviance: 55.75 AIC: 237.3
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 response SE df asymp.LCL asymp.UCL
## 1: 1 4.468531 0.8206283 Inf 2.787977 7.162099
## 2: 2 7.286075 1.0642306 Inf 5.006625 10.603327
## 3: 3 4.661181 0.7898286 Inf 3.016197 7.203313
## 4: 4 6.496204 1.0038280 Inf 4.367885 9.661578
## 5: 5 5.959440 0.9666969 Inf 3.928629 9.040030
hpa <- setDT(as.data.frame(pairs(hp.means)))
hpa
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 0.6132975 0.1442285 Inf 1 -2.0789539 0.2291565
## 2: treatment1 / treatment3 0.9586693 0.2398129 Inf 1 -0.1687340 0.9998188
## 3: treatment1 / treatment4 0.6878681 0.1643724 Inf 1 -1.5657826 0.5194963
## 4: treatment1 / treatment5 0.7498240 0.1854626 Inf 1 -1.1640455 0.7719242
## 5: treatment2 / treatment3 1.5631391 0.3430888 Inf 1 2.0351819 0.2490958
## 6: treatment2 / treatment4 1.1215896 0.2358815 Inf 1 0.5456086 0.9825001
## 7: treatment2 / treatment5 1.2226106 0.2639382 Inf 1 0.9310152 0.8849405
## 8: treatment3 / treatment4 0.7175238 0.1609740 Inf 1 -1.4796265 0.5757829
## 9: treatment3 / treatment5 0.7821508 0.1810531 Inf 1 -1.0614592 0.8262678
## 10: treatment4 / treatment5 1.0900695 0.2445949 Inf 1 0.3843464 0.9953836
hp.cld.model <- cld(object = hp.means,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
hp.cld.model
## treatment response SE df asymp.LCL asymp.UCL .group
## 1 4.47 0.821 Inf 2.79 7.16 a
## 3 4.66 0.790 Inf 3.02 7.20 a
## 5 5.96 0.967 Inf 3.93 9.04 a
## 4 6.50 1.004 Inf 4.37 9.66 a
## 2 7.29 1.064 Inf 5.01 10.60 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()

count_pup_col <- 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 Count") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
theme_cowplot() +
theme_cowplot() +
coord_cartesian(ylim=c(0,7.6)) +
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",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
count_pup_bw <- ggplot(dpem1, aes(x = treatment, y = response, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_grey() +
geom_errorbar(aes(ymin = response - SE, ymax = response + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Dead Pupae Count") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
theme_cowplot() +
theme_cowplot() +
coord_cartesian(ylim=c(0,7.6)) +
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",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
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")

me <- emmeans(mod3, pairwise~replicate, type = "response")
me
## $emmeans
## replicate prob SE df asymp.LCL asymp.UCL
## 1 0.922 0.0184 Inf 0.877 0.951
## 2 0.801 0.0369 Inf 0.719 0.864
## 3 0.792 0.0405 Inf 0.701 0.860
## 4 0.746 0.0362 Inf 0.668 0.810
## 5 0.839 0.0329 Inf 0.764 0.894
## 7 0.775 0.0302 Inf 0.710 0.829
## 9 0.926 0.0208 Inf 0.873 0.958
## 11 0.818 0.0370 Inf 0.734 0.879
## 12 0.229 0.0685 Inf 0.122 0.388
##
## Results are averaged over the levels of: treatment
## Confidence level used: 0.95
## Intervals are back-transformed from the logit scale
##
## $contrasts
## contrast odds.ratio SE df null z.ratio p.value
## replicate1 / replicate2 2.915 1.0162 Inf 1 3.070 0.0550
## replicate1 / replicate3 3.098 0.9934 Inf 1 3.526 0.0126
## replicate1 / replicate4 4.012 1.2461 Inf 1 4.472 0.0003
## replicate1 / replicate5 2.252 0.7378 Inf 1 2.479 0.2421
## replicate1 / replicate7 3.418 0.9367 Inf 1 4.484 0.0003
## replicate1 / replicate9 0.937 0.3526 Inf 1 -0.173 1.0000
## replicate1 / replicate11 2.625 0.9202 Inf 1 2.754 0.1294
## replicate1 / replicate12 39.615 18.5862 Inf 1 7.842 <.0001
## replicate2 / replicate3 1.063 0.3652 Inf 1 0.176 1.0000
## replicate2 / replicate4 1.376 0.4323 Inf 1 1.016 0.9845
## replicate2 / replicate5 0.773 0.2706 Inf 1 -0.737 0.9983
## replicate2 / replicate7 1.172 0.3428 Inf 1 0.544 0.9998
## replicate2 / replicate9 0.321 0.1219 Inf 1 -2.993 0.0686
## replicate2 / replicate11 0.900 0.2953 Inf 1 -0.320 1.0000
## replicate2 / replicate12 13.588 5.9778 Inf 1 5.931 <.0001
## replicate3 / replicate4 1.295 0.3671 Inf 1 0.912 0.9924
## replicate3 / replicate5 0.727 0.1899 Inf 1 -1.220 0.9524
## replicate3 / replicate7 1.103 0.2701 Inf 1 0.402 1.0000
## replicate3 / replicate9 0.302 0.1113 Inf 1 -3.251 0.0316
## replicate3 / replicate11 0.848 0.3030 Inf 1 -0.463 0.9999
## replicate3 / replicate12 12.789 6.1043 Inf 1 5.339 <.0001
## replicate4 / replicate5 0.561 0.1404 Inf 1 -2.308 0.3368
## replicate4 / replicate7 0.852 0.2129 Inf 1 -0.641 0.9994
## replicate4 / replicate9 0.234 0.0861 Inf 1 -3.946 0.0026
## replicate4 / replicate11 0.654 0.2235 Inf 1 -1.241 0.9473
## replicate4 / replicate12 9.875 4.5684 Inf 1 4.950 <.0001
## replicate5 / replicate7 1.517 0.3883 Inf 1 1.629 0.7887
## replicate5 / replicate9 0.416 0.1563 Inf 1 -2.334 0.3214
## replicate5 / replicate11 1.166 0.4518 Inf 1 0.395 1.0000
## replicate5 / replicate12 17.588 8.8739 Inf 1 5.683 <.0001
## replicate7 / replicate9 0.274 0.0890 Inf 1 -3.988 0.0022
## replicate7 / replicate11 0.768 0.2287 Inf 1 -0.886 0.9937
## replicate7 / replicate12 11.591 4.9902 Inf 1 5.691 <.0001
## replicate9 / replicate11 2.802 1.0656 Inf 1 2.709 0.1443
## replicate9 / replicate12 42.282 20.5404 Inf 1 7.708 <.0001
## replicate11 / replicate12 15.090 6.4587 Inf 1 6.341 <.0001
##
## Results are averaged over the levels of: treatment
## P value adjustment: tukey method for comparing a family of 9 estimates
## Tests are performed on the log odds ratio scale
mem <- setDT(as.data.frame(me$emmeans))
mem$plot <- mem$prob + mem$SE
mem
## replicate prob SE df asymp.LCL asymp.UCL plot
## 1: 1 0.9216710 0.01837372 Inf 0.8772289 0.9509254 0.9400447
## 2: 2 0.8014307 0.03691037 Inf 0.7192354 0.8641094 0.8383411
## 3: 3 0.7916015 0.04046630 Inf 0.7013705 0.8600108 0.8320678
## 4: 4 0.7457450 0.03624468 Inf 0.6684959 0.8101065 0.7819897
## 5: 5 0.8393341 0.03294383 Inf 0.7639523 0.8939835 0.8722780
## 6: 7 0.7749194 0.03021159 Inf 0.7102936 0.8286075 0.8051310
## 7: 9 0.9262459 0.02084973 Inf 0.8734946 0.9580567 0.9470956
## 8: 11 0.8175835 0.03695373 Inf 0.7338853 0.8792871 0.8545373
## 9: 12 0.2290030 0.06849024 Inf 0.1219336 0.3884926 0.2974932
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(replicate) %>%
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: 9 × 4
## replicate mean.l mean.d prob.alive
## <fct> <dbl> <dbl> <dbl>
## 1 1 29.8 4.4 0.871
## 2 2 21.4 5 0.811
## 3 3 18.4 9.4 0.662
## 4 4 44.6 13.4 0.769
## 5 5 42.6 14.2 0.75
## 6 7 31.2 17 0.647
## 7 9 18.2 3 0.858
## 8 11 18.6 5.4 0.775
## 9 12 2 8.4 0.192
cldb <- cld(object = me,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldb
## replicate prob SE df asymp.LCL asymp.UCL .group
## 12 0.229 0.0685 Inf 0.0922 0.465 a
## 4 0.746 0.0362 Inf 0.6335 0.833 b
## 7 0.775 0.0302 Inf 0.6808 0.848 b
## 3 0.792 0.0405 Inf 0.6584 0.882 b
## 2 0.801 0.0369 Inf 0.6800 0.885 bc
## 11 0.818 0.0370 Inf 0.6931 0.899 bc
## 5 0.839 0.0329 Inf 0.7266 0.911 bc
## 1 0.922 0.0184 Inf 0.8534 0.960 c
## 9 0.926 0.0208 Inf 0.8437 0.967 c
##
## Results are averaged over the levels of: treatment
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 9 estimates
## Intervals are back-transformed from the logit scale
## P value adjustment: tukey method for comparing a family of 9 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 = replicate, y = prob, fill = replicate)) +
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 = "Location in Rearing Room", y = "Probability") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0,1.05)) +
theme(legend.position = "none") +
annotate(geom = "text",
label = "P < 0.05",
x = 1, y = 1.05,
size = 10) +
annotate(geom = "text",
label = c("c", "bc", "b", "b", "bc", "b", "c", "bc", "a"),
x = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
y = c(mem$plot + 0.04),
size = 10) +
theme(legend.position = "none") +
scale_x_discrete(labels = c("1", "2", "3", "4", "5", "6", "7", "8", "9"))

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 <- as.data.frame(me$emmeans)
mem$plot <- mem$prob + mem$SE
mem
## treatment prob SE df asymp.LCL asymp.UCL plot
## 1 0.3311029 40.09654 Inf 2.220446e-16 1 40.42764
## 2 0.1032328 16.76030 Inf 2.220446e-16 1 16.86353
## 3 0.0797172 13.28181 Inf 2.220446e-16 1 13.36153
## 4 0.1335927 20.95509 Inf 2.220446e-16 1 21.08868
## 5 0.0723353 12.14858 Inf 2.220446e-16 1 12.22092
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Intervals are back-transformed from the logit scale
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.pupae <- 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.pupae$prob.alive <- (sum.pupae$mean.l)/(sum.pupae$mean.d + sum.pupae$mean.l)
sum.pupae
## # 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") + 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, 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.
prob_brood_col <- ggplot(mem, aes(x = treatment, y = prob, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_viridis_d() +
labs(x = "Treatment", y = "Larvae and Pupae Probability of Survival") +
geom_errorbar(aes(ymin = prob - SE, ymax = prob + SE), width = 0.2, position = position_dodge(0.9)) +
theme_cowplot() +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
theme_cowplot() +
coord_cartesian(ylim=c(0.8,1.013)) +
annotate(geom = "text",
x = 1, y = 1.01 ,
label = "P < 0.001",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(mem$plot + 0.01),
label = c("c", "a", "ab", "ab", "bc"),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
prob_brood_bw <- ggplot(mem, aes(x = treatment, y = prob, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_grey() +
labs(x = "Treatment", y = "Larvae and Pupae Probability of Survival") +
geom_errorbar(aes(ymin = prob - SE, ymax = prob + SE), width = 0.2, position = position_dodge(0.9)) +
theme_cowplot() +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
theme_cowplot() +
coord_cartesian(ylim=c(0.8,1.013)) +
annotate(geom = "text",
x = 1, y = 1.01 ,
label = "P < 0.001",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(mem$plot + 0.01),
label = c("c", "a", "ab", "ab", "bc"),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
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.
em_color <- 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") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) + # Set x-axis labels
theme_cowplot() +
coord_cartesian(ylim = c(30,41)) +
annotate(geom = "text",
label = "P < 0.05",
x = 1, y = 41,
size = 8) +
annotate(geom = "text",
label = c("b", "ab", "b", "a", "ab"),
x = c(1, 2, 3, 4, 5),
y = c(em_sum$plot + 0.4),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
em_color

em_bw <- ggplot(em_sum, aes(x = treatment, y = mean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_grey() +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Days") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) + # Set x-axis labels
theme_cowplot() +
coord_cartesian(ylim = c(30,41)) +
annotate(geom = "text",
label = "P < 0.05",
x = 1, y = 41,
size = 8) +
annotate(geom = "text",
label = c("b", "ab", "b", "a", "ab"),
x = c(1, 2, 3, 4, 5),
y = c(em_sum$plot + 0.4),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
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)

ggplot(drone.ce.na, aes(x = drones, y = emerge, color = treatment)) +
geom_point(size = 5)+
theme_cowplot() +
scale_color_viridis_d() +
geom_smooth(method = "lm", color = "black", size = 1) +
labs(y = "Days", x = "Count of Males")+
labs(color = "Treatment") +
theme_classic(base_size = 30) +
theme_cowplot() +
theme(
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))

ggplot(drone.ce.na, aes(x = drones, y = emerge, color = treatment)) +
geom_point(size = 5) +
theme_cowplot() +
scale_color_viridis_d() +
geom_smooth(method = "lm", color = "black", size = 1) +
labs(y = "Days", x = "Count of Males") +
labs(color = "Treatment") +
scale_color_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) + # Set legend labels
theme_cowplot() +
theme(
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20), # Set axis title font size
text = element_text(size = 20)
)

em_sum.rep <- drone.ce.na %>%
group_by(replicate) %>%
summarise(mean = mean(emerge),
sd = sd(emerge),
n = length(emerge)) %>%
mutate(se = sd/sqrt(n))
em_sum.rep$plot <- (em_sum.rep$mean + em_sum.rep$se)
egm.rep <- emmeans(de2, pairwise ~ replicate, type = "response")
cldemer.rep <- cld(object = egm.rep,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldemer.rep
## replicate response SE df asymp.LCL asymp.UCL .group
## 4 1146 88.3 Inf 926 1418 a
## 7 1191 83.0 Inf 982 1444 a
## 3 1196 87.9 Inf 976 1466 a
## 5 1221 113.8 Inf 944 1580 ab
## 11 1223 88.8 Inf 1001 1495 a
## 9 1282 94.1 Inf 1046 1570 ab
## 1 1333 86.3 Inf 1114 1594 ab
## 2 1441 105.1 Inf 1178 1763 ab
## 12 1820 162.6 Inf 1421 2330 b
##
## Results are averaged over the levels of: treatment
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 9 estimates
## Intervals are back-transformed from the log scale
## P value adjustment: tukey method for comparing a family of 9 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.rep, aes(x = replicate, y = mean, fill = replicate)) +
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 = "Location in Rearing Room", y = "Days") +
theme_cowplot ()+
coord_cartesian(ylim = c(30,48)) +
annotate(geom = "text",
label = "P < 0.05",
x = 1, y = 45) +
annotate(geom = "text",
label = c("ab", "ab", "a", "a", "ab", "a", "ab", "a", "b"),
x = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
y = c(em_sum.rep$plot + 0.8)) +
theme(legend.position = "none") +
scale_x_discrete(labels = c("1", "2", "3", "4", "5", "6", "7", "8", "9"))

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
dry_color <- 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)") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) + # Set x-axis labels
theme_cowplot() +
coord_cartesian(ylim=c(0.02, 0.043)) +
annotate(geom = "text",
x = 1, y = 0.0427 ,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = rep(de$plot[1] + 0.001, 5), # Adjusted y parameter to match the length
label = c("b", "ab", "a", "ab", "ab"),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
dry_color

dry_bw <- ggplot(de, aes(x = treatment, y = emmean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_grey() +
geom_errorbar(aes(ymin = emmean - SE, ymax = emmean + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Treatment", y = "Dry Weight(g)") +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) + # Set x-axis labels
theme_cowplot() +
coord_cartesian(ylim=c(0.02, 0.043)) +
annotate(geom = "text",
x = 1, y = 0.0427 ,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = rep(de$plot[1] + 0.001, 5), # Adjusted y parameter to match the length
label = c("b", "ab", "a", "ab", "ab"),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
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
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.00125, 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)

sum.rad <- drone.rad %>%
group_by(treatment) %>%
summarise(mean = mean(relative_fat),
sd = sd(relative_fat),
n=(length(relative_fat))) %>%
mutate(se = sd/sqrt(n))
sum.rad$plot <- (sum.rad$mean + sum.rad$se)
fat_col <- ggplot(sum.rad, 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)) +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
labs(x = "Treatment", y = "Relative Fat (g)") +
theme_cowplot() +
coord_cartesian(ylim=c(0.00125, 0.0024)) +
annotate(geom = "text",
x = 1.1, y = 0.0024 ,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(sum.rad$plot + 0.0001),
label = c("bc", "abc", "a", "ab", "c"),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
fat_bw <- ggplot(sum.rad, aes(x = treatment, y = mean, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
scale_fill_grey() +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, position = position_dodge(0.9)) +
scale_x_discrete(labels = c("0 ppb", "150 ppb", "1,500 ppb", "15,000 ppb", "150,000 ppb")) +
labs(x = "Treatment", y = "Relative Fat (g)") +
theme_cowplot() +
coord_cartesian(ylim=c(0.00125, 0.0024)) +
annotate(geom = "text",
x = 1.1, y = 0.0024 ,
label = "P < 0.01",
size = 8) +
annotate(geom = "text",
x = c(1, 2, 3, 4, 5),
y = c(sum.rad$plot + 0.0001),
label = c("bc", "abc", "a", "ab", "c"),
size = 8) +
theme(legend.position = "none",
axis.text = element_text(size = 20), # Set axis label font size
axis.title = element_text(size = 20)) + # Set axis title font size
theme(text = element_text(size = 20))
sum.rad <- drone.rad %>%
group_by(replicate) %>%
summarise(mean = mean(relative_fat),
sd = sd(relative_fat),
n=(length(relative_fat))) %>%
mutate(se = sd/sqrt(n))
dem_rep <- emmeans(rf1, pairwise ~ replicate, type = "response")
dd.cld_rep <- cld(object =dem_rep,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
dd.cld_rep
## replicate emmean SE df lower.CL upper.CL .group
## 4 -6.95 0.173 168 -7.44 -6.47 a
## 3 -6.94 0.170 190 -7.42 -6.47 a
## 7 -6.91 0.176 169 -7.41 -6.42 a
## 9 -6.90 0.179 153 -7.40 -6.40 a
## 1 -6.84 0.173 186 -7.32 -6.35 a
## 11 -6.83 0.195 162 -7.38 -6.29 a
## 5 -6.79 0.176 138 -7.28 -6.30 a
## 2 -6.69 0.178 168 -7.19 -6.19 a
## 12 -6.53 0.213 170 -7.13 -5.94 a
##
## Results are averaged over the levels of: treatment, alive
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: sidak method for 9 estimates
## P value adjustment: tukey method for comparing a family of 9 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.rad$plot <- (sum.rad$mean + sum.rad$se)
ggplot(sum.rad, aes(x = replicate, y = mean, fill = replicate)) +
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 = "Location in Rearing Room", y = "Relative Fat (g)") +
theme_classic(base_size = 30) +
coord_cartesian(ylim=c(0.00125, 0.0026)) +
theme(legend.position = "none") +
annotate(geom = "text",
label = "P < 0.05",
x = 1, y = 0.00243,
size = 10) +
annotate(geom = "text",
label = c("a", "a", "a", "a", "a", "a", "a", "a", "a"),
x = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
y = c(sum.rad$plot + 0.0001),
size = 10) +
theme(legend.position = "none") +
scale_x_discrete(labels = c("1", "2", "3", "4", "5", "6", "7", "8", "9"))

Colony Duration
descdist(drone.ce$duration, discrete = TRUE)

## summary statistics
## ------
## min: 20 max: 58
## median: 42
## mean: 42.46667
## estimated sd: 6.542171
## estimated skewness: -0.2500756
## estimated kurtosis: 6.629389
hist(drone.ce$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
dur.glmnb <- glm.nb(duration ~ treatment + replicate + alive, data =drone.ce)
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
Anova(dur.glmnb)
## Analysis of Deviance Table (Type II tests)
##
## Response: duration
## LR Chisq Df Pr(>Chisq)
## treatment 5.9880 4 0.200046
## replicate 17.3105 8 0.027034 *
## alive 8.5927 1 0.003375 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(dur1)




plot(dur2)




durm <- emmeans(dur.glmnb, pairwise ~ treatment, type = "response")
durm
## $emmeans
## treatment response SE df asymp.LCL asymp.UCL
## 1 46.5 2.38 Inf 42.1 51.5
## 2 41.4 2.14 Inf 37.4 45.8
## 3 43.0 2.20 Inf 38.9 47.5
## 4 39.6 2.11 Inf 35.6 43.9
## 5 40.5 2.12 Inf 36.5 44.9
##
## Results are averaged over the levels of: replicate
## Confidence level used: 0.95
## Intervals are back-transformed from the log scale
##
## $contrasts
## contrast ratio SE df null z.ratio p.value
## treatment1 / treatment2 1.124 0.0824 Inf 1 1.589 0.5042
## treatment1 / treatment3 1.083 0.0804 Inf 1 1.076 0.8192
## treatment1 / treatment4 1.177 0.0864 Inf 1 2.216 0.1737
## treatment1 / treatment5 1.149 0.0857 Inf 1 1.867 0.3351
## treatment2 / treatment3 0.964 0.0695 Inf 1 -0.509 0.9865
## treatment2 / treatment4 1.047 0.0778 Inf 1 0.622 0.9716
## treatment2 / treatment5 1.023 0.0748 Inf 1 0.310 0.9980
## treatment3 / treatment4 1.086 0.0806 Inf 1 1.117 0.7977
## treatment3 / treatment5 1.061 0.0765 Inf 1 0.824 0.9233
## treatment4 / treatment5 0.977 0.0732 Inf 1 -0.314 0.9979
##
## 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
dur.glmnb
##
## Call: glm.nb(formula = duration ~ treatment + replicate + alive, data = drone.ce,
## init.theta = 2039053.521, link = log)
##
## Coefficients:
## (Intercept) treatment2 treatment3 treatment4 treatment5 replicate2
## 3.59067 -0.11655 -0.07984 -0.16275 -0.13922 0.13748
## replicate3 replicate4 replicate5 replicate7 replicate9 replicate11
## -0.10795 0.03605 -0.05252 -0.06701 0.09396 -0.01399
## replicate12 alive
## 0.20086 0.05464
##
## Degrees of Freedom: 44 Total (i.e. Null); 31 Residual
## Null Deviance: 46.18
## Residual Deviance: 17.05 AIC: 298
durmedt <- setDT(as.data.frame(durm$emmeans))
durmcdt <- setDT(as.data.frame(durm$contrasts))
durmedt
## treatment response SE df asymp.LCL asymp.UCL
## 1: 1 46.54947 2.381938 Inf 42.10743 51.46012
## 2: 2 41.42816 2.140290 Inf 37.43866 45.84279
## 3: 3 42.97724 2.202199 Inf 38.87067 47.51766
## 4: 4 39.55787 2.107104 Inf 35.63629 43.91100
## 5: 5 40.49988 2.124967 Inf 36.54201 44.88642
durmcdt
## contrast ratio SE df null z.ratio p.value
## 1: treatment1 / treatment2 1.1236191 0.08239917 Inf 1 1.5893756 0.5041905
## 2: treatment1 / treatment3 1.0831192 0.08040887 Inf 1 1.0755235 0.8192140
## 3: treatment1 / treatment4 1.1767435 0.08642740 Inf 1 2.2159187 0.1736880
## 4: treatment1 / treatment5 1.1493732 0.08568802 Inf 1 1.8673784 0.3350661
## 5: treatment2 / treatment3 0.9639558 0.06946699 Inf 1 -0.5094026 0.9864687
## 6: treatment2 / treatment4 1.0472797 0.07779941 Inf 1 0.6218585 0.9716411
## 7: treatment2 / treatment5 1.0229206 0.07481065 Inf 1 0.3098666 0.9980025
## 8: treatment3 / treatment4 1.0864396 0.08063965 Inf 1 1.1169727 0.7976708
## 9: treatment3 / treatment5 1.0611696 0.07645129 Inf 1 0.8240997 0.9232832
## 10: treatment4 / treatment5 0.9767406 0.07321556 Inf 1 -0.3139606 0.9978973
Adur <- setDT(as.data.frame(Anova(dur.glmnb)))
Adur
## LR Chisq Df Pr(>Chisq)
## 1: 5.988000 4 0.200046241
## 2: 17.310479 8 0.027033654
## 3: 8.592746 1 0.003375046
cldur <- cld(object = durm,
adjust = "Tukey",
Letters = letters,
alpha = 0.05)
cldur
## treatment response SE df asymp.LCL asymp.UCL .group
## 4 39.6 2.11 Inf 34.5 45.4 a
## 5 40.5 2.12 Inf 35.4 46.3 a
## 2 41.4 2.14 Inf 36.3 47.3 a
## 3 43.0 2.20 Inf 37.7 49.0 a
## 1 46.5 2.38 Inf 40.8 53.1 a
##
## 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.
durmdf <- as.data.frame(durm$emmeans)
durmdf$plot <- durmdf$response + durmdf$SE
ggplot(durmdf, aes(x = treatment, y = response, fill = treatment)) +
geom_bar(stat = "identity", color = "black") +
geom_errorbar(aes(ymin = response - SE, ymax = response + 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")

Figures
broodfig <- brood %>%
select(treatment, brood_cells, eggs, drones, honey_pot, larvae, pupae, dead_larvae, dead_pupae, alive)
brood_long <- broodfig %>%
pivot_longer(cols = c(brood_cells, eggs, drones, honey_pot, larvae, pupae, dead_larvae, dead_pupae, alive),
names_to = "dependent_variable",
values_to = "count")
ggplot(brood_long, aes(x = as.factor(treatment), y = count, fill = dependent_variable)) +
geom_bar(stat = "identity", position = position_dodge()) +
labs(x = "Treatment", y = "Count", fill = "Brood Stage") +
scale_fill_manual(values = c("brood_cells" = "blue",
"honey_pot" = "green",
"eggs" = "orange",
"dead_larvae" = "red",
"dead_pupae" = "pink",
"drones" = "magenta",
"alive" = "black",
"larvae" = "gold",
"pupae" = "sienna")) +
theme_cowplot()

sum <- brood %>%
group_by(treatment) %>%
summarise(meane = mean(eggs),
meanhp = mean(honey_pot),
meanl = mean(larvae),
meanp = mean(pupae))
sum
## # A tibble: 5 × 5
## treatment meane meanhp meanl meanp
## <fct> <dbl> <dbl> <dbl> <dbl>
## 1 1 14.8 4.22 28.4 8.56
## 2 2 9.11 7.89 17 16.7
## 3 3 5.56 5.56 37 18.8
## 4 4 6.56 7 24.2 12.6
## 5 5 4.33 6.22 18 8.33
# Create a data frame with the provided data
data <- data.frame(
treatment = factor(c(1, 2, 3, 4, 5)),
meane = c(14.777778, 9.111111, 5.555556, 6.555556, 4.333333),
meanhp = c(4.222222, 7.888889, 5.555556, 7.000000, 6.222222),
meanl = c(28.44444, 17.00000, 37.00000, 24.22222, 18.00000),
meanp = c(8.555556, 16.666667, 18.777778, 12.555556, 8.333333)
)
# Melt the data into long format
library(reshape2)
data_melted <- melt(data, id.vars = "treatment")
# Create the bar graph
ggplot(data_melted, aes(x = treatment, y = value, fill = variable)) +
geom_bar(stat = "identity", position = position_dodge()) +
labs(x = "Treatment", y = "Mean", fill = "Variable") +
scale_fill_manual(values = c("meane" = "blue",
"meanhp" = "green",
"meanl" = "orange",
"meanp" = "red")) +
theme_minimal()

# Create a data frame with the provided data and standard errors
data <- data.frame(
treatment = factor(c(1, 2, 3, 4, 5)),
meane = c(14.777778, 9.111111, 5.555556, 6.555556, 4.333333),
meanhp = c(4.222222, 7.888889, 5.555556, 7.000000, 6.222222),
meanl = c(28.44444, 17.00000, 37.00000, 24.22222, 18.00000),
meanp = c(8.555556, 16.666667, 18.777778, 12.555556, 8.333333),
se_meane = c(0.1, 0.2, 0.15, 0.2, 0.1), # Replace with your actual standard errors
se_meanhp = c(0.1, 0.15, 0.12, 0.18, 0.1), # Replace with your actual standard errors
se_meanl = c(0.2, 0.25, 0.18, 0.3, 0.15), # Replace with your actual standard errors
se_meanp = c(0.12, 0.18, 0.2, 0.15, 0.1) # Replace with your actual standard errors
)
# Melt the data into long format
data_long <- data %>%
pivot_longer(cols = starts_with("meane"),
names_to = "variable",
values_to = "mean") %>%
pivot_longer(cols = starts_with("se_"),
names_to = "variable_se",
values_to = "se") %>%
mutate(variable_se = gsub("se_", "", variable_se)) %>%
select(treatment, variable, mean, variable_se, se)
# Create the bar graph with standard error bars
ggplot(data_long, aes(x = treatment, y = mean, fill = variable_se)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se),
position = position_dodge(width = 0.9), width = 0.2) +
labs(x = "Treatment", y = "Mean", fill = "Variable") +
scale_fill_manual(values = c("meane" = "blue",
"meanhp" = "green",
"meanl" = "orange",
"meanp" = "red")) +
theme_minimal()

sum <- brood %>%
group_by(treatment) %>%
summarise(meane = mean(eggs),
meanhp = mean(honey_pot),
meanl = mean(larvae),
meanp = mean(pupae),
sd_e= sd(eggs),
sd_hp = sd(honey_pot),
sd_l = sd(larvae),
sd_p = sd(pupae),
n_e = length(eggs),
n_hp = length(honey_pot),
n_l = length(larvae),
n_p = length(pupae)) %>%
mutate(se_e = sd_e / sqrt(n_e),
se_hp = sd_hp / sqrt(n_hp),
se_l = sd_l / sqrt(n_l),
se_p = sd_p / sqrt(n_p))
# Now 'sum' contains the means, standard deviations, and standard errors for each variable
sum_data <- read_csv("sum_data.csv", col_types = cols(treatment = col_factor(levels = c("1",
"2", "3", "4", "5"))))
unique(sum_data$treatment)
## [1] 1 2 3 4 5
## Levels: 1 2 3 4 5
ggplot(sum_data, aes(x = treatment, y = mean, fill = variable)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se),
position = position_dodge(width = 0.9), width = 0.2) +
labs(x = "Treatment", y = "Count", fill = "Variable") +
scale_fill_viridis_d(labels = c("Average Eggs", "Average Honey Pots", "Average Larvae", "Average Pupae")) +
theme_cowplot()

sum <- brood %>%
group_by(treatment) %>%
summarise(meane = mean(eggs),
meanhp = mean(honey_pot),
meanl = mean(larvae),
meanp = mean(pupae),
meana = mean(alive),
meandp = mean(dead_pupae),
meandl = mean(dead_larvae),
sd_e= sd(eggs),
sd_hp = sd(honey_pot),
sd_l = sd(larvae),
sd_p = sd(pupae),
sd_a = sd(alive),
sd_dp = sd(dead_pupae),
sd_dl = sd(dead_larvae),
n_e = length(eggs),
n_hp = length(honey_pot),
n_l = length(larvae),
n_p = length(pupae),
n_a = length(alive),
n_dp = length(dead_pupae),
n_dl = length(dead_larvae)) %>%
mutate(se_e = sd_e / sqrt(n_e),
se_hp = sd_hp / sqrt(n_hp),
se_l = sd_l / sqrt(n_l),
se_p = sd_p / sqrt(n_p),
se_a = sd_a / sqrt(n_a),
se_dp = sd_dp / sqrt(n_dp),
se_dl = sd_dl / sqrt(n_dl))
sum
## # A tibble: 5 × 29
## treatment meane meanhp meanl meanp meana meandp meandl sd_e sd_hp sd_l sd_p
## <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 14.8 4.22 28.4 8.56 3.44 2 1.78 27.7 3.27 27.0 6.71
## 2 2 9.11 7.89 17 16.7 4.22 7.89 3.22 11.7 3.59 12.5 15.3
## 3 3 5.56 5.56 37 18.8 4.67 8.89 5.78 6.56 2.96 26.3 14.9
## 4 4 6.56 7 24.2 12.6 3.89 2.89 6.67 5.90 3.61 23.8 15.6
## 5 5 4.33 6.22 18 8.33 4.33 3.89 1.56 4.39 4.35 13.6 7.19
## # ℹ 17 more variables: sd_a <dbl>, sd_dp <dbl>, sd_dl <dbl>, n_e <int>,
## # n_hp <int>, n_l <int>, n_p <int>, n_a <int>, n_dp <int>, n_dl <int>,
## # se_e <dbl>, se_hp <dbl>, se_l <dbl>, se_p <dbl>, se_a <dbl>, se_dp <dbl>,
## # se_dl <dbl>
e <- ggplot(sum, aes(x = treatment, y = meane, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meane - se_e, ymax = meane + se_e),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average eggs", x = "")
hp <- ggplot(sum, aes(x = treatment, y = meanhp, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meanhp - se_hp, ymax = meanhp + se_hp),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average honey pots", x = "")
l <- ggplot(sum, aes(x = treatment, y = meanl, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meanl - se_l, ymax = meanl + se_l),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average larvae", x = "treatment")
p <- ggplot(sum, aes(x = treatment, y = meanp, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meanhp - se_p, ymax = meanp + se_p),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average pupae", x = "treatment")
a <- ggplot(sum, aes(x = treatment, y = meana, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meana - se_a, ymax = meana + se_a),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average surviving workers", x = "treatment")
dl <- ggplot(sum, aes(x = treatment, y = meandl, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meandl - se_dl, ymax = meandl + se_dl),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average dead larvae", x = "treatment")
dp <- ggplot(sum, aes(x = treatment, y = meandp, fill = treatment)) +
geom_bar(stat = "identity", position = position_dodge()) +
geom_errorbar(aes(ymin = meandp - se_dp, ymax = meandp + se_dp),
position = position_dodge(width = 0.9), width = 0.2) +
scale_fill_viridis_d() +
theme_cowplot() +
theme(legend.position = "none") +
labs(y = "average dead pupae", x = "treatment")
plot_grid(e, hp, l, p, dl, dp, ncol=2, nrow =3)

sum_dt = setDT(as.data.frame(sum))
sum_dt
## treatment meane meanhp meanl meanp meana meandp meandl
## 1: 1 14.777778 4.222222 28.44444 8.555556 3.444444 2.000000 1.777778
## 2: 2 9.111111 7.888889 17.00000 16.666667 4.222222 7.888889 3.222222
## 3: 3 5.555556 5.555556 37.00000 18.777778 4.666667 8.888889 5.777778
## 4: 4 6.555556 7.000000 24.22222 12.555556 3.888889 2.888889 6.666667
## 5: 5 4.333333 6.222222 18.00000 8.333333 4.333333 3.888889 1.555556
## sd_e sd_hp sd_l sd_p sd_a sd_dp sd_dl n_e n_hp
## 1: 27.666667 3.270236 27.02828 6.710274 1.9436506 2.061553 1.986063 9 9
## 2: 11.720116 3.586239 12.51998 15.280707 1.6414763 12.128937 5.262551 9 9
## 3: 6.559556 2.962731 26.33439 14.914572 0.7071068 7.270565 6.220486 9 9
## 4: 5.897269 3.605551 23.84207 15.573303 1.6914819 3.018462 14.815532 9 9
## 5: 4.387482 4.352522 13.62901 7.193747 1.6583124 4.284987 1.878238 9 9
## n_l n_p n_a n_dp n_dl se_e se_hp se_l se_p se_a
## 1: 9 9 9 9 9 9.222222 1.0900787 9.009426 2.236758 0.6478835
## 2: 9 9 9 9 9 3.906705 1.1954130 4.173328 5.093569 0.5471588
## 3: 9 9 9 9 9 2.186519 0.9875772 8.778129 4.971524 0.2357023
## 4: 9 9 9 9 9 1.965756 1.2018504 7.947358 5.191101 0.5638273
## 5: 9 9 9 9 9 1.462494 1.4508405 4.543004 2.397916 0.5527708
## se_dp se_dl
## 1: 0.6871843 0.6620208
## 2: 4.0429790 1.7541837
## 3: 2.4235216 2.0734953
## 4: 1.0061539 4.9385108
## 5: 1.4283289 0.6260793
plot_grid(em_color, dry_color, fat_col, count_pup_col, ncol=2, nrow =2)

plot_grid(em_bw, dry_bw, fat_bw, count_pup_bw, ncol=2, nrow =2)

plot_grid(work_surv_col, prob_brood_col, ncol=2, nrow =1)

plot_grid(work_surv_bw, prob_brood_bw, ncol=2, nrow =1)

plot(workers$replicate, workers$start_wet_weight)

plot(workers$replicate, workers$`dry weight`)

LS0tDQp0aXRsZTogIldpZGVseS11c2VkIGZ1bmdpY2lkZSBQcmlzdGluZcKuIGNhdXNlcyBzdWItbGV0aGFsIGVmZmVjdHMgaW4gY29tbW9uIGVhc3Rlcm4gYnVtYmxlIGJlZSAoKkJ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tID0gInRleHQiLA0KICAgICAgICAgICBsYWJlbCA9ICJQIDwgMC4wNSIsDQogICAgICAgICAgIHggPSAxLCB5ID0gNDEsDQogICAgICAgICAgIHNpemUgPSA4KSArIA0KICBhbm5vdGF0ZShnZW9tID0gInRleHQiLA0KICAgICAgICAgICBsYWJlbCA9IGMoImIiLCAiYWIiLCAiYiIsICJhIiwgImFiIiksDQogICAgICAgICAgIHggPSBjKDEsIDIsIDMsIDQsIDUpLA0KICAgICAgICAgICB5ID0gYyhlbV9zdW0kcGxvdCArIDAuNCksIA0KICAgICAgICAgICBzaXplID0gOCkgKw0KICB0aGVtZShsZWdlbmQucG9zaXRpb24gPSAibm9uZSIsDQogICAgICAgIGF4aXMudGV4dCA9IGVsZW1lbnRfdGV4dChzaXplID0gMjApLCAgIyBTZXQgYXhpcyBsYWJlbCBmb250IHNpemUNCiAgICAgICAgYXhpcy50aXRsZSA9IGVsZW1lbnRfdGV4dChzaXplID0gMjApKSArICAjIFNldCBheGlzIHRpdGxlIGZvbnQgc2l6ZQ0KICB0aGVtZSh0ZXh0ID0gZWxlbWVudF90ZXh0KHNpemUgPSAyMCkpDQoNCmVtX2NvbG9yDQoNCg0KZW1fYncgPC0gZ2dwbG90KGVtX3N1bSwgYWVzKHggPSB0cmVhdG1lbnQsIHkgPSBtZWFuLCBmaWxsID0gdHJlYXRtZW50KSkgKw0KICBnZW9tX2JhcihzdGF0ID0gImlkZW50aXR5IiwgY29sb3IgPSAiYmxhY2siKSArDQogICBzY2FsZV9maWxsX2dyZXkoKSArIA0KIGdlb21fZXJyb3JiYXIoYWVzKHltaW4gPSBtZWFuIC0gc2UsIHltYXggPSBtZWFuICsgc2UpLCB3aWR0aCA9IDAuMiwgcG9zaXRpb24gPSBwb3NpdGlvbl9kb2RnZSgwLjkpKSArDQogIGxhYnMoeCA9ICJUcmVhdG1lbnQiLCB5ID0gIkRheXMiKSArDQogIHNjYWxlX3hfZGlzY3JldGUobGFiZWxzID0gYygiMCBwcGIiLCA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Agc2NhbGVfZmlsbF9tYW51YWwodmFsdWVzID0gYygiZ3JheTkwIiwgImdyYXk3MCIsICJncmF5NTAiICwgImdyYXkzMCIsImdyYXkxMCIpLA0KICAgICAgICAgICAgICAgICAgICBuYW1lID0gIlByaXN0aW5lIExldmVsIiwNCiAgICAgICAgICAgICAgICAgICAgbGFiZWxzID0gYygiVHJlYXRtZW50IDEgKGNvbnRyb2wpIiwgIlRyZWF0bWVudCAyIiwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlRyZWF0bWVudCAzIiwgIlRyZWF0bWVudCA0IiwgIlRyZWF0bWVudCA1IikpICsNCiAgZ2d0aXRsZSgiRHJvbmUgUmFkaWFsIENlbGwgTGVuZ3RoKG1tKSIpICsNCiAgbGFicyh5ID0gIkNvdW50IiwgeCA9ICJMZW5ndGgiKQ0Kc2hhcGlyby50ZXN0KGRyb25lLnJhZCRyYWRpYWwpDQoNCmRyb25lLnJhZCRzcXIgPC0gKGRyb25lLnJhZCRyYWRpYWwpXjINCg0Kc2hhcGlyby50ZXN0KGRyb25lLnJhZCRzcXIpDQoNCmdncGxvdChkcm9uZS5yYWQsIGFlcyh4PXNxciwgZmlsbCA9IHRyZWF0bWVudCkpICsNCiAgZ2VvbV9oaXN0b2dyYW0ocG9zaXRpb24gPSAiaWRlbnRpdHkiLCBiaW53aWR0aCA9IDAuNSAsY29sPUkoImJsYWNrIikpICsNCiAgc2NhbGVfZmlsbF9tYW51YWwodmFsdWVzID0gYygiZ3JheTkwIiwgImdyYXk3MCIsICJncmF5NTAiICwgImdyYXkzMCIsImdyYXkxMCIpLA0KICAgICAgICAgICAgICAgICAgICBuYW1lID0gIlByaXN0aW5lIExldmVsIiwNCiAgICAgICAgICAgICAgICAgICAgbGFiZWxzID0gYygiVHJlYXRtZW50IDEgKGNvbnRyb2wpIiwgIlRyZWF0bWVudCAyIiwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlRyZWF0bWVudCAzIiwgIlRyZWF0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vdCIgPSAiZ3JlZW4iLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImVnZ3MiID0gIm9yYW5nZSIsIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZGVhZF9sYXJ2YWUiID0gInJlZCIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJkZWFkX3B1cGFlIiA9ICJwaW5rIiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImRyb25lcyIgPSAibWFnZW50YSIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJhbGl2ZSIgPSAiYmxhY2siLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibGFydmFlIiA9ICJnb2xkIiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInB1cGFlIiA9ICJzaWVubmEiKSkgKw0KICB0aGVtZV9jb3dwbG90KCkNCmBgYA0KDQoNCmBgYHtyfQ0Kc3VtIDwtIGJyb29kICU+JQ0KICBncm91cF9ieSh0cmVhdG1lbnQpICU+JQ0KICBzdW1tYXJpc2UobWVhbmUgPSBtZWFuKGVnZ3MpLA0KICAgICAgICAgICAgbWVhbmhwID0gbWVhbihob25leV9wb3QpLA0KICAgICAgICAgICAgbWVhbmwgPSBtZWFuKGxhcnZhZSksDQogICAgICAgICAgICBtZWFucCA9IG1lYW4ocHVwYWUpKQ0KDQpzdW0NCg0KDQojIENyZWF0ZSBhIGRhdGEgZnJhbWUgd2l0aCB0aGUgcHJvdmlkZWQgZGF0YQ0KZGF0YSA8LSBkYXRhLmZyYW1lKA0KICB0cmVhdG1lbnQgPSBmYWN0b3IoYygxLCAyLCAzLCA0LCA1KSksDQogIG1lYW5lID0gYygxNC43Nzc3NzgsIDkuMTExMTExLCA1LjU1NTU1NiwgNi41NTU1NTYsIDQuMzMzMzMzKSwNCiAgbWVhbmhwID0gYyg0LjIyMjIyMiwgNy44ODg4ODksIDUuNTU1NTU2LCA3LjAwMDAwMCwgNi4yM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