DOI: 10.5061/dryad.xwdbrv1p8
title: Risk of predation increases susceptibility to parasitism via trait-mediated indirect effects

description: The presence of natural enemies can cause organisms to change habitat use,
 foraging behaviour and/or resource allocation in response to a perceived
 risk; responses that may come at the cost of other fitness-related traits.
 Since most species encounter multiple natural enemies, defensive
 behaviours against one attacker may make the focal organism more
 vulnerable to attack by a different natural enemy. Anti-predator
 behaviours can lead to trait-mediated indirect effects such as an
 increased risk of attack by parasites, and vice versa. Few empirical
 studies have examined the response of a single focal species to the risk
 of attack by multiple species. Our experiments provided Drosophila
 nigrospiracula with opportunities to prioritise either anti-predator or
 anti-parasite behaviour at the cost of increased infection or predation,
 respectively. When exposed to parasites in the presence of predator cues,
 D. nigrospiracula experienced increased infection compared to flies
 without predator cues, but the presence/absence of parasite cues had no
 analogous effect on predation rates. We suggest that flies perceived
 parasitic infection to be a lesser threat and responded more strongly to
 predation risk at the cost of increased infection. In an ecological
 context, we shows how trait-mediated indirect effects could regulate
 community structure by increasing susceptibility to infection.
description: <strong>Flies, mites, and spiders</strong>:
 <em>Drosophila nigrospiracula</em> flies were cultured on
 <em>Drosophila</em> media (Formula 4–24 Instant Drosophila
 Medium; Carolina Biological Supply Company, Burlington, NC), instant
 mashed potato, and autoclaved necrotic tissue of Saguaro cacti
 (<em>Carnegiea gigantea</em>). <em>Macrocheles
 subbadius</em> mites were maintained in a mix of 2:1 mix of wheat
 bran to wood chips and co-cultured with free-living nematodes as a food
 source, hereafter referred to as ‘mite media’. <em>Drosophila
 nigrospiracula</em> and <em>M. subbadius</em> were both
 collected from the Sonoran Desert, Arizona, USA, in 2019 and maintained
 separately in continuous culture at the University of Alberta in climate
 controlled incubators (Percival Scientific, Perry, IA, USA) at 25 °C, 70 %
 relative humidity (RH) and a 12 h:12 h light:dark regime.
 <em>Salticus scenicus</em> spiders were collected by hand on
 the campus of the University of Alberta, Canada. Spiders were maintained
 in 100 mL specimen jars and provided with water and one <em>D.
 nigrospiracula</em> fly twice per week.
 <strong>Experimental arenas</strong>: we custom
 designed a two-level arena system that could expose flies to parasites
 (<em>M. subbadius</em>) on the lower level or predators
 (<em>S. scenicus</em>) on the upper level (see schematic -
 Figure 1). Our design allowed us to test the effects of indirect contact
 (odour and visual cues) of one threat type while the focal species was
 simultaneously and directly exposed to the other threat type. The arena
 system was composed of two clear plastic Petri dishes (diameter 6 cm,
 height 1.5 cm) stacked one on top of the other. Mesh-covered holes in the
 floor of the upper dish and the roof of the lower dish allowed odour cues
 to flow between arenas. We placed a hole in the roof of the upper dish so
 that spiders and/or flies could be aspirated into this arena; this hole
 was plugged with adhesive tac (UHU Tac Adhesive Putty, UHU GmbH &
 Co. KG, Germany) during trials. The inner surfaces of the upper dish were
 abraded with course sandpaper so that the spiders could access all areas
 of the arena when hunting flies. This system allowed us to test our two
 alternate hypotheses using four separate scenarios. Our first hypothesis -
 flies prioritise anti-predator behavioural defenses over risk of infection
 - used scenarios 1) direct contact between flies and mites with indirect
 contact (visual and odour cues only) from spider and 2) direct contact
 between flies and mites, no spider cues. Our second hypothesis - flies
 prioritise anti-parasite behaviour at an increased risk of predation -
 used scenarios 3) direct contact between flies and spider with indirect
 contact with mites and 4) direct contact between flies and spider but no
 mite cues. In Scenarios 1 and 2, approximately 15 g of
 mite media from our in-lab mite colonies was packed into the lower arena
 (Figure 1A-iv) and two intersecting trenches (0.5 mm wide, 0.5 mm deep)
 were made in the media with a short length of thin wood (Figure 1B-iv).
 These trenches replicated the small interstices or necrotic pockets of the
 cactus, where flies would normally encounter mites. The number of mites in
 the mite media varied among days, and therefore among trials, due to
 patchy aggregation of mites within colony containers. We assumed that any
 subsequent variability in infection would affect both treatments equally
 (see statistical analysis section). In both scenarios, five flies were
 aspirated into the trenches in the lower arena before attaching the upper
 arena. In Scenario 1, a spider was added to the upper arena, while in
 Scenario 2, no spider was added. In Scenarios 3 and 4, one fly and one
 spider were aspirated into the upper level; the fly was added first to
 avoid an immediate attack by the spider. In Scenario 3 mite media was
 packed into the lower level, but no trenches were made, while mite-free
 media was added to the lower level in Scenario 4, again with no trenches.
 Mite-free media contained wheat bran, wood chips and nematodes, but no
 mites, allowing us to control for any fly behavioural responses to the
 odour cues generated by the media and nematodes.
 <strong>Experiment One</strong>: predator present and
 predator absent trials were conducted over 7 days in November and December
 2023. Flies were directly exposed to mites with (n = 34) and without (n =
 33) indirect exposure to spiders; arenas were then placed into a dark box
 inside the incubator for 1.5 hours. After the trial was complete, the
 flies were anaesthetised with CO<sub>2</sub> and inspected
 under a dissecting microscope for mites. We calculated three response
 variables to quantify infection success (Rózsa et al. 2000):
 <em>infection prevalence</em> - the mean proportion of flies
 that were infected; <em>infection intensity</em> - the average
 number of mites among all infected flies, and <em>infection
 abundance</em> – the average number of mites per fly, including
 uninfected and infected flies. <strong>Experiment
 Two</strong>: parasite present/absent trials were completed over
 four days in December 2023. Flies were directly exposed to spiders with (n
 = 32) and without (n = 32) indirect exposure to mites; trials lasted 30
 minutes and were run in replicates of four: two with parasites present and
 two with parasites absent. Trials were limited to 30 minutes because after
 that time spiders began to spin webs that inhibited fly movement and
 confounded the behavioural responses of interest. After the spider and fly
 were loaded, an opaque plastic container (interior light intensity: 136
 lux) was placed over top of the arena unit to limit visual disturbances
 that might affect spider or fly behaviour. The plastic container had a
 hole in the top that was covered with a lid, which was removed briefly at
 five-minute intervals to assess fly mortality. Spider and fly were
 observed until either the fly was killed or the trial ended, at which time
 we recorded mortality (yes/no) and time until death. Trials were conducted
 in-lab, where temperature and relative humidity were relatively consistent
 (18-19 °C and 22-24% RH). <em>Statistical
 Analysis</em> <strong>Experiment
 One:</strong> A generalised linear mixed effect model (glmm -
 <em>glmer</em> function in the package
 <em>lme4</em> (Bates et al. 2014)) was used to analyse
 infection prevalence data. This model used infection prevalence as the
 response variable, treatment as the fixed effect, and trial number as a
 random effect to compensate for unknown variables in a given day. A
 general linear model (glm – <em>glm</em> function in the
 package <em>stats</em>) was used to test for differences of
 infection prevalence caused by variability in mite density among trials.
 This model used infection prevalence as the response variable and trial as
 fixed effect. Both models used a binomial error family and logit link
 function, and a dispersion parameter for our glmm was calculated using the
 <em>dispersion_glmer</em> function in the package
 <em>blmeco</em> (Korner-Nievergelt et al. 2019).
 We used a Wilcoxon signed-rank non-parametric tests
 (<em>wilcox.test</em> function in the
 <em>stats</em> package) to analyse infection intensity and
 infection abundance data as neither met the assumptions of normality.
 Infection intensity or infection abundance were the response variables and
 treatment, predator present or predator absent, was the fixed effect. Due
 to variable mite density among trials, we used a Kruskal Wallace
 non-parametric test (<em>kruskal.test</em> function in the
 <em>stats</em> package) to look for any significant degree of
 variability in infection caused by trial number, and a pairwise Nemenyi
 test with a Tukey distribution (<em>NemenyiTest</em> function
 in the <em>DescTools</em> package (Signorell et al. 2024)) to
 find significant pairwise differences between trials.
 <strong>Experiment Two</strong>: Fly survival was
 analysed using both a glmm (as described above) and a cox proportionate
 hazard model with random effects (<em>coxme</em> function in
 the package <em>coxme</em> (Therneau 2012)). The glmm analyzed
 end point survival only, with fixed effects of treatment (parasite present
 and parasite absent), media mass, spider mass, and trial date as a random
 effect. The proportional hazards model incorporated time of death of each
 treatment (parasite present and parasite absent), spider mass and media
 mass and again with the random effect of trial date. In this experiment,
 variable mite density was not considered to be an issue, as mite media
 provide only a parasite present signal. However, in the interest of
 completeness, we tested for any effect of trial date as a proxy for mite
 density using a glm with fly mortality as response variable and trial date
 as fixed effect, and a cox proportionate hazard model with time of death
 as response variable and trial date as fixed effect. 
description: Title - Risk of predation increases susceptibility to parasitism via
 trait-mediated indirect effects Summary: The presence of natural enemies
 can cause organisms to change habitat use, foraging behaviour and/or
 resource allocation in response to a perceived risk; responses that may
 come at the cost of other fitness-related traits. Since most species
 encounter multiple natural enemies, defensive behaviours against one
 attacker may make the focal organism more vulnerable to attack by a
 different natural enemy. Anti-predator behaviours can lead to
 trait-mediated indirect effects such as an increased risk of attack by
 parasites, and vice-versa. Few empirical studies have examined the
 response of a single focal species to the risk of attack by multiple
 species. Our experiments provided Drosophila nigrospiracula with
 opportunities to prioritise either anti-predator or anti-parasite
 behaviour at the cost of increased infection or predation, respectively.
 When exposed to parasites in the presence of predator cues, D.
 nigrospiracula experienced increased infection compared to flies without
 predator cues, but the presence/absence of parasite cues had no analogous
 effect on predation rates. We suggest that flies perceived parasitic
 infection to be a lesser threat and responded more strongly to predation
 risk at the cost of increased infection. In an ecological context, we
 shows how trait-mediated indirect effects could regulate community
 structure by increasing susceptibility to infection. File overview: the
 file Experiment1_R.csv contains the data used in Experiment One described
 on the manuscript. Column headers are as follows: **Trial_Number** - Each
 trial was conducted on a different day. This variable allowed for Trial
 Day to be tested as a random and fixed effect. **Petri_position** - Petri
 dishes were allocated positions inside the darkened box, and positions
 were randomised each trial to ensure that there was no effect of distance
 between dish and door to the box. **Treatment** - exposed to spider cues
 (spider) or not (control) **SpiderID** - ID to track which spiders had
 been used from our spider collection **SpiderMass** - Spider mass in mg to
 be used as a covariate in analysis **Flies_Recovered** - total number of
 flies recovered from experimental arena. Some flies were lost in transfer
 to or from arena. **Flies_Inf** - number of flies infected with one or
 more mite. **Fly1 to Fly5** - data shows the number of mites attached to
 each fly. Some columns read NA if less than 5 flies were recovered.
 **Abundance** - Parasite abundance. Calculated as number of mites divided
 by total number of flies. **Prevalence** - Parasite prevalence. Calculated
 as the number of infected flies divided by the total number of flies.
 **Infected** - number of infected flies. Used in cbind() analysis
 **Uninfected** - Number of uninfected flies. Used in cbind() analysis
 **InfInt** - Parasite infection intensity. Calculated as the number of
 mites divided by the number of infected flies. The file Experiment2_R.csv
 contains the data used in Experiment Two described on the manuscript.
 Column headers are as follows: **Date** - Date that trials were completed
 **TrialDay** - Dates as simple numeric values **Trial_No** - on each date,
 multiple sets of 4 trials were completed. Each of these sets was given a
 numeric value **Treatment** - Mites present or mites absent treatments
 **Position** - position of each of the four petris per trial. Position was
 randomised for each trial set. **Order** - indication of the order in
 which each petri was loaded. Order was randomisd between trial sets top
 avod any unwanted effect of load order. **MediaMass** - weight (mg) of
 media (mite or mite-free) added to lower arena **SpiderID** - ID to track
 which spiders had been used from our spider collection **SpiderMass** -
 Spider mass in mg to be used as a covariate in analysis **t0** start time
 of each trial **Dead** - binary indicator of fly status: 1 indicated fly
 was dead, 0 indicated fly was alive (variable unused in analysis)
 **Time1** - time fly was observed dead in seconds after t0: 0s entered if
 fly survived until end of trial (variable unused in analysis) **Time2** -
 time fly was observed dead in seconds after t0: 30s entered if fly
 survived until end of trial **status** - indicator of fly status: 2
 indicated fly was dead, 1 indicated fly was alive **dead** - binary
 indicator of fly status: 1 indicated fly was dead, 0 indicated fly was
 alive (used in glmm cbind() function) **alive** - binary indicator of fly
 status: 0 indicated fly was dead, 1 indicated fly was alive (used in glmm
 cbind() function) ### Experiment 1 - Infection Prevalence tests - Text
 from MS *Statistical Analysis* Section “A generalised linear mixed effect
 model (glmm - glmer function in the package lme4 (Bates et al. 2014)) was
 used to analyse infection prevalence data. This model used infection
 prevalence as the response variable, treatment as the fixed effect, and
 trial number as a random effect to compensate for unknown variables in a
 given day. A general linear model (glm – glm function in the package
 stats) was used to test for differences of infection prevalence caused by
 variability in mite density among trials. This model used infection
 prevalence as the response variable and trial as fixed effect. Both models
 used a binomial error family and logit link function, and a dispersion
 parameter for our glmm was calculated using the dispersion_glmer function
 in the package blmeco (Korner-Nievergelt et al. 2019).” ```
 setwd("D:/Proceedings")
 Exper1&lt;-read.csv("Experiment1_R.csv") attach(Exper1)
 str(Exper1) ## 'data.frame': 67 obs. of 12 variables: ## $
 Trial_Number : int 1 1 1 1 2 2 2 2 2 3 ... ## $ Petri_position: int 2 7 8
 9 2 4 6 8 10 4 ... ## $ Treatment : chr "Spider"
 "Spider" "Spider" "Spider" ... ## $ SpiderID
 : chr "s10" "s3" "s57" "s17" ...
 ## $ SpiderMass : num 7.31 8.68 7.37 10.65 7.9 ... ## $ Flies_Rec : int 5
 4 5 4 5 5 3 4 5 5 ... ## $ Flies_Inf : int 2 2 4 1 4 1 3 2 1 0 ... ## $
 Abundance : num 0.6 0.5 2.4 2.25 8.2 0.2 2.33 2 0.2 0 ... ## $ Prevalence
 : num 0.4 0.5 0.8 0.25 0.8 0.2 1 0.5 0.2 0 ... ## $ Infected : int 2 2 4 1
 4 1 3 2 1 0 ... ## $ Uninfected : int 3 2 1 3 1 4 0 2 4 5 ... ## $ InfInt
 : num 1.5 1 3 9 10.3 1 2.3 4 1 0 ... library(lme4) ## Loading required
 package: Matrix library(blmeco) ## Loading required package: MASS
 library(car) ## Loading required package: carData library(emmeans)
 model1&lt;-glmer((cbind(Infected,Uninfected))~Treatment+(1|Trial_Number),
 family="binomial") summary(model1) ## Generalized linear mixed
 model fit by maximum likelihood (Laplace ## Approximation) [glmerMod] ##
 Family: binomial ( logit ) ## Formula: (cbind(Infected, Uninfected)) ~
 Treatment + (1 | Trial_Number) ## ## AIC BIC logLik deviance df.resid ##
 192.2 198.8 -93.1 186.2 64 ## ## Scaled residuals: ## Min 1Q Median 3Q Max
 ## -1.6832 -0.8748 -0.2399 0.4993 3.7074 ## ## Random effects: ## Groups
 Name Variance Std.Dev. ## Trial_Number (Intercept) 0.4638 0.681 ## Number
 of obs: 67, groups: Trial_Number, 7 ## ## Fixed effects: ## Estimate Std.
 Error z value Pr(&gt;|z|) ## (Intercept) -1.6569 0.3383 -4.897 9.72e-07
 *** ## TreatmentSpider 0.7581 0.2783 2.724 0.00645 ** ## --- ## Signif.
 codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
 '.' 0.1 ' ' 1 ## ## Correlation of Fixed Effects: ##
 (Intr) ## TretmntSpdr -0.496 Anova(model1) ## Analysis of Deviance Table
 (Type II Wald chisquare tests) ## ## Response: (cbind(Infected,
 Uninfected)) ## Chisq Df Pr(&gt;Chisq) ## Treatment 7.4198 1 0.006451 **
 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01
 '*' 0.05 '.' 0.1 ' ' 1
 dispersion_glmer(model1) ## [1] 1.213211
 TrialAF&lt;-as.factor(Trial_Number)
 model2&lt;-glm((cbind(Infected,Uninfected))~TrialAF,
 family="binomial") summary(model2) ## ## Call: ## glm(formula =
 (cbind(Infected, Uninfected)) ~ TrialAF, family = "binomial") ##
 ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -1.8886 -1.0336 -0.5073
 0.4723 3.0185 ## ## Coefficients: ## Estimate Std. Error z value
 Pr(&gt;|z|) ## (Intercept) -0.1823 0.3496 -0.522 0.602011 ## TrialAF2
 -0.1691 0.4603 -0.367 0.713392 ## TrialAF3 -0.6650 0.4663 -1.426 0.153872
 ## TrialAF4 -2.2600 0.6277 -3.601 0.000317 *** ## TrialAF5 -1.3340 0.5077
 -2.628 0.008595 ** ## TrialAF6 -1.7636 0.5592 -3.154 0.001612 ** ##
 TrialAF7 -1.3340 0.5077 -2.628 0.008595 ** ## --- ## Signif. codes: 0
 '***' 0.001 '**' 0.01 '*' 0.05 '.'
 0.1 ' ' 1 ## ## (Dispersion parameter for binomial family taken
 to be 1) ## ## Null deviance: 129.107 on 66 degrees of freedom ## Residual
 deviance: 99.408 on 60 degrees of freedom ## AIC: 190.49 ## ## Number of
 Fisher Scoring iterations: 5 Anova(model2) ## Analysis of Deviance Table
 (Type II tests) ## ## Response: (cbind(Infected, Uninfected)) ## LR Chisq
 Df Pr(&gt;Chisq) ## TrialAF 29.7 6 4.483e-05 *** ## --- ## Signif. codes:
 0 '***' 0.001 '**' 0.01 '*' 0.05
 '.' 0.1 ' ' 1 #manually estimate dispersion parameter
 - residual deviance/residual degrees of freedom 99/60 ## [1] 1.65 em &lt;-
 emmeans(model2, "TrialAF") ## Warning in (function (object, at,
 cov.reduce = mean, cov.keep = get_emm_option("cov.keep"), :
 There are unevaluated constants in the response formula ## Auto-detection
 of the response transformation may be incorrect contrast(em,
 "pairwise", adjust = "Tukey") ## contrast estimate SE
 df z.ratio p.value ## TrialAF1 - TrialAF2 0.169 0.460 Inf 0.367 0.9998 ##
 TrialAF1 - TrialAF3 0.665 0.466 Inf 1.426 0.7879 ## TrialAF1 - TrialAF4
 2.260 0.628 Inf 3.601 0.0059 ## TrialAF1 - TrialAF5 1.334 0.508 Inf 2.628
 0.1176 ## TrialAF1 - TrialAF6 1.764 0.559 Inf 3.154 0.0269 ## TrialAF1 -
 TrialAF7 1.334 0.508 Inf 2.628 0.1176 ## TrialAF2 - TrialAF3 0.496 0.430
 Inf 1.153 0.9113 ## TrialAF2 - TrialAF4 2.091 0.601 Inf 3.478 0.0091 ##
 TrialAF2 - TrialAF5 1.165 0.475 Inf 2.455 0.1760 ## TrialAF2 - TrialAF6
 1.595 0.529 Inf 3.013 0.0414 ## TrialAF2 - TrialAF7 1.165 0.475 Inf 2.455
 0.1760 ## TrialAF3 - TrialAF4 1.595 0.606 Inf 2.633 0.1161 ## TrialAF3 -
 TrialAF5 0.669 0.480 Inf 1.393 0.8060 ## TrialAF3 - TrialAF6 1.099 0.535
 Inf 2.055 0.3797 ## TrialAF3 - TrialAF7 0.669 0.480 Inf 1.393 0.8060 ##
 TrialAF4 - TrialAF5 -0.926 0.638 Inf -1.451 0.7737 ## TrialAF4 - TrialAF6
 -0.496 0.680 Inf -0.730 0.9908 ## TrialAF4 - TrialAF7 -0.926 0.638 Inf
 -1.451 0.7737 ## TrialAF5 - TrialAF6 0.430 0.571 Inf 0.752 0.9892 ##
 TrialAF5 - TrialAF7 0.000 0.521 Inf 0.000 1.0000 ## TrialAF6 - TrialAF7
 -0.430 0.571 Inf -0.752 0.9892 ## ## Results are given on the log odds
 ratio (not the response) scale. ## P value adjustment: tukey method for
 comparing a family of 7 estimates ``` ### Experiment 1 - Infection
 Intensity and Infection Abundance tests - Text from MS *Statistical
 Analysis* Section “We used a Wilcoxon signed-rank non-parametric tests
 (wilcox.test function in the stats package) to analyse infection intensity
 and infection abundance data as neither met the assumptions of normality.
 Infection intensity or infection abundance were the response variables and
 treatment, predator present or predator absent, was the fixed effect. Due
 to variable mite density among trials, we used a Kruskal Wallace
 non-parametric test (kruskal.test function in the stats package) to look
 for any significant degree of variability in infection caused by trial
 number, and a Nemenyi pairwise test with a Tukey distribution (NemenyiTest
 function in the DescTools package) to find significant pairwise
 differences between trials.” #### Infection Intensity - Wilcox Test
 followed by Kruskal Wallace and Nemenyi tests ``` library(DescTools) ## ##
 Attaching package: 'DescTools' ## The following object is masked
 from 'package:car': ## ## Recode wilcox.test(InfInt~Treatment)
 ## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...):
 cannot ## compute exact p-value with ties ## ## Wilcoxon rank sum test
 with continuity correction ## ## data: InfInt by Treatment ## W = 372.5,
 p-value = 0.01423 ## alternative hypothesis: true location shift is not
 equal to 0 kruskal.test(InfInt ~ TrialAF, data = Exper1) ## ##
 Kruskal-Wallis rank sum test ## ## data: InfInt by TrialAF ##
 Kruskal-Wallis chi-squared = 17.247, df = 6, p-value = 0.008418 II =
 NemenyiTest(x = InfInt, g = TrialAF, dist="tukey") II ## ##
 Nemenyi's test of multiple comparisons for independent samples
 (tukey) ## ## mean.rank.diff pval ## 2-1 -3.014286 0.9999 ## 3-1 -6.564286
 0.9935 ## 4-1 -27.464286 0.0641 . ## 5-1 -16.314286 0.6167 ## 6-1
 -24.314286 0.1478 ## 7-1 -14.214286 0.7568 ## 3-2 -3.550000 0.9996 ## 4-2
 -24.450000 0.0744 . ## 5-2 -13.300000 0.7290 ## 6-2 -21.300000 0.1802 ##
 7-2 -11.200000 0.8590 ## 4-3 -20.900000 0.1990 ## 5-3 -9.750000 0.9226 ##
 6-3 -17.750000 0.3911 ## 7-3 -7.650000 0.9759 ## 5-4 11.150000 0.8615 ##
 6-4 3.150000 0.9998 ## 7-4 13.250000 0.7325 ## 6-5 -8.000000 0.9698 ## 7-5
 2.100000 1.0000 ## 7-6 10.100000 0.9093 ## --- ## Signif. codes: 0
 '***' 0.001 '**' 0.01 '*' 0.05 '.'
 0.1 ' ' 1 ``` #### Infection Abundance - Wilcox Test followed by
 Kruskal Wallace and Nemenyi tests ``` wilcox.test(Abundance ~ Treatment)
 ## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...):
 cannot ## compute exact p-value with ties ## ## Wilcoxon rank sum test
 with continuity correction ## ## data: Abundance by Treatment ## W = 386,
 p-value = 0.02352 ## alternative hypothesis: true location shift is not
 equal to 0 kruskal.test(Abundance ~ TrialAF, data = Exper1) ## ##
 Kruskal-Wallis rank sum test ## ## data: Abundance by TrialAF ##
 Kruskal-Wallis chi-squared = 19.696, df = 6, p-value = 0.003137 AB =
 NemenyiTest(x = Abundance, g = TrialAF, dist="tukey") AB ## ##
 Nemenyi's test of multiple comparisons for independent samples
 (tukey) ## ## mean.rank.diff pval ## 2-1 -4.542857 0.9992 ## 3-1
 -10.242857 0.9378 ## 4-1 -30.042857 0.0291 * ## 5-1 -20.842857 0.3116 ##
 6-1 -27.442857 0.0645 . ## 7-1 -18.392857 0.4699 ## 3-2 -5.700000 0.9949
 ## 4-2 -25.500000 0.0533 . ## 5-2 -16.300000 0.5000 ## 6-2 -22.900000
 0.1176 ## 7-2 -13.850000 0.6892 ## 4-3 -19.800000 0.2575 ## 5-3 -10.600000
 0.8881 ## 6-3 -17.200000 0.4314 ## 7-3 -8.150000 0.9669 ## 5-4 9.200000
 0.9407 ## 6-4 2.600000 0.9999 ## 7-4 11.650000 0.8346 ## 6-5 -6.600000
 0.9888 ## 7-5 2.450000 1.0000 ## 7-6 9.050000 0.9451 ## --- ## Signif.
 codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
 '.' 0.1 ' ' 1 detach(Exper1) ``` ### Experiment 2 -
 Fly mortality tests - Text from MS *Statistical Analysis* Section “Fly
 survival was analysed using both a glmm (as described above) and a cox
 proportionate hazard model with random effects (coxme function in the
 package coxme (Therneau 2012)). The glmm analyzed end point survival only,
 with fixed effects of treatment (parasite present and parasite absent),
 media mass, spider mass, and trial date as a random effect. The
 proportional hazards model incorporated time of death of each treatment
 (parasite present and parasite absent), spider mass and media mass and
 again with the random effect of trial date. In this experiment, variable
 mite density was not considered to be an issue, as mite media provide only
 a parasite present signal. However, in the interest of completeness, we
 tested for any effect of trial date as a proxy for mite density using a
 glm with fly mortality as response variable and trial date as fixed
 effect, and a cox proportionate hazard model with time of death as
 response variable and trial date as fixed effect.” #### End-point
 mortality - Generalised Linear mixed effect model followed by a glm to
 test for any effect of Trial Date ``` setwd("D:/Proceedings")
 Exper2&lt;-read.csv("Experiment2_R.csv") attach(Exper2)
 str(Exper2) ## 'data.frame': 63 obs. of 18 variables: ## $ Date
 : chr "19Dec" "19Dec" "19Dec"
 "19Dec" ... ## $ TrialDay : int 1 1 1 1 1 1 1 1 1 1 ... ## $
 Trial_No : int 1 1 1 1 2 2 2 2 3 3 ... ## $ Trial_No_Ct: logi NA NA NA NA
 NA NA ... ## $ Petri : int 8 5 4 9 8 5 4 9 8 1 ... ## $ Treatment : chr
 "Mite" "Mite" "NoMite" "NoMite"
 ... ## $ Position : int 1 2 3 4 1 2 3 4 1 2 ... ## $ Order : int 1 2 3 4 4
 3 2 1 1 2 ... ## $ MediaMass : num 5.5 6.4 4.9 5.4 7 7.2 5.7 6 6.5 7 ...
 ## $ SpiderID : chr "2" "x25" "57"
 "36" ... ## $ SpiderMass : num 6.01 6.88 7.37 6.62 10.35 ... ##
 $ t0 : num 10.2 10.2 10.2 10.2 11.1 ... ## $ Dead : int 1 1 0 0 0 0 0 1 1
 1 ... ## $ Time1 : int 10 10 0 0 0 0 0 15 5 5 ... ## $ Time2 : int 10 10
 30 30 30 30 30 15 5 5 ... ## $ status : int 2 2 1 1 1 1 1 2 2 2 ... ## $
 dead : int 1 1 0 0 0 0 0 1 1 1 ... ## $ alive : int 0 0 1 1 1 1 1 0 0 0
 ... TrialDayAF&lt;-as.factor(TrialDay)
 model3&lt;-glmer(cbind(dead,alive)~Treatment+SpiderMass+MediaMass+(1|TrialDayAF), family="binomial") ## boundary (singular) fit: see help('isSingular') summary(model3) ## Generalized linear mixed model fit by maximum likelihood (Laplace ## Approximation) [glmerMod] ## Family: binomial ( logit ) ## Formula: cbind(dead, alive) ~ Treatment + SpiderMass + MediaMass + (1 | ## TrialDayAF) ## ## AIC BIC logLik deviance df.resid ## 93.9 104.6 -42.0 83.9 58 ## ## Scaled residuals: ## Min 1Q Median 3Q Max ## -0.9904 -0.8096 -0.7298 1.1571 1.4678 ## ## Random effects: ## Groups Name Variance Std.Dev. ## TrialDayAF (Intercept) 0 0 ## Number of obs: 63, groups: TrialDayAF, 4 ## ## Fixed effects: ## Estimate Std. Error z value Pr(&gt;|z|) ## (Intercept) 1.06158 3.55850 0.298 0.765 ## TreatmentNoMite -0.36847 0.52099 -0.707 0.479 ## SpiderMass -0.04379 0.09711 -0.451 0.652 ## MediaMass -0.15279 0.53771 -0.284 0.776 ## ## Correlation of Fixed Effects: ## (Intr) TrtmNM SpdrMs ## TreatmntNMt -0.156 ## SpiderMass -0.234 0.051 ## MediaMass -0.973 0.079 0.027 ## optimizer (Nelder_Mead) convergence code: 0 (OK) ## boundary (singular) fit: see help('isSingular') Anova(model3) ## Analysis of Deviance Table (Type II Wald chisquare tests) ## ## Response: cbind(dead, alive) ## Chisq Df Pr(&gt;Chisq) ## Treatment 0.5002 1 0.4794 ## SpiderMass 0.2033 1 0.6521 ## MediaMass 0.0807 1 0.7763 dispersion_glmer(model3) ## [1] 1.154044 model4&lt;-glm(cbind(dead,alive)~TrialDayAF, family="binomial") summary(model4) ## ## Call: ## glm(formula = cbind(dead, alive) ~ TrialDayAF, family = "binomial") ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -1.1010 -0.9794 -0.9282 1.2557 1.4490 ## ## Coefficients: ## Estimate Std. Error z value Pr(&gt;|z|) ## (Intercept) -0.6190 0.4688 -1.320 0.187 ## TrialDayAF2 0.1335 0.6494 0.206 0.837 ## TrialDayAF3 0.4367 0.7658 0.570 0.568 ## TrialDayAF4 0.4367 0.7658 0.570 0.568 ## ## (Dispersion parameter for binomial family taken to be 1) ## ## Null deviance: 84.635 on 62 degrees of freedom ## Residual deviance: 84.124 on 59 degrees of freedom ## AIC: 92.124 ## ## Number of Fisher Scoring iterations: 4 Anova(model4) ## Analysis of Deviance Table (Type II tests) ## ## Response: cbind(dead, alive) ## LR Chisq Df Pr(&gt;Chisq) ## TrialDayAF 0.51017 3 0.9167 #manually estimate dispersion parameter - residual deviance/residual degrees of freedom 84/59 ## [1] 1.423729 ``` #### Mortality as a function of time - Cox mixed effect (coxme) model followed by a coxph model to test for any effect of Trial date ``` library(coxme) ## Loading required package: survival ## Loading required package: bdsmatrix ## ## Attaching package: 'bdsmatrix' ## The following object is masked from 'package:base': ## ## backsolve model5&lt;-coxme(Surv(Time2,status)~Treatment+SpiderMass+MediaMass+(1|TrialDayAF)) model5 ## Cox mixed-effects model fit by maximum likelihood ## ## events, n = 25, 63 ## Iterations= 5 22 ## NULL Integrated Fitted ## Log-likelihood -98.04112 -97.74864 -97.74787 ## ## Chisq df p AIC BIC ## Integrated loglik 0.58 4 0.96472 -7.42 -12.29 ## Penalized loglik 0.59 3 0.89965 -5.42 -9.07 ## ## Model: Surv(Time2, status) ~ Treatment + SpiderMass + MediaMass + (1 | TrialDayAF) ## Fixed coefficients ## coef exp(coef) se(coef) z p ## TreatmentNoMite -0.28707478 0.7504556 0.40803486 -0.70 0.48 ## SpiderMass -0.01653467 0.9836013 0.07204492 -0.23 0.82 ## MediaMass -0.12971693 0.8783440 0.40672415 -0.32 0.75 ## ## Random effects ## Group Variable Std Dev Variance ## TrialDayAF Intercept 9.039815e-03 8.171825e-05 model6&lt;-coxph(Surv(Time2,status)~TrialDayAF) summary(model6) ## Call: ## coxph(formula = Surv(Time2, status) ~ TrialDayAF) ## ## n= 63, number of events= 25 ## ## coef exp(coef) se(coef) z Pr(&gt;|z|) ## TrialDayAF2 0.1678 1.1827 0.5176 0.324 0.746 ## TrialDayAF3 0.2399 1.2711 0.5856 0.410 0.682 ## TrialDayAF4 0.1739 1.1899 0.5862 0.297 0.767 ## ## exp(coef) exp(-coef) lower .95 upper .95 ## TrialDayAF2 1.183 0.8455 0.4289 3.262 ## TrialDayAF3 1.271 0.7867 0.4034 4.006 ## TrialDayAF4 1.190 0.8404 0.3772 3.754 ## ## Concordance= 0.511 (se = 0.057 ) ## Likelihood ratio test= 0.2 on 3 df, p=1 ## Wald test = 0.2 on 3 df, p=1 ## Score (logrank) test = 0.2 on 3 df, p=1 detach(Exper2) ``` See text file RawCode.txt for code with no accompanying text or outputs