Code
library(sjPlot)
library(ggplot2)
library(lme4)
library(lmerTest)
library(dplyr)
library(here)
library(emmeans)
library(randomizr)
library(tidyverse)
options(digits = 3, scipen = 5)library(sjPlot)
library(ggplot2)
library(lme4)
library(lmerTest)
library(dplyr)
library(here)
library(emmeans)
library(randomizr)
library(tidyverse)
options(digits = 3, scipen = 5)Underground mining is known to disrupt surface and groundwater flows which may affect nearby swamp communities. The researchers wanted to examine how differing water availability affected swamp plant communities, both alone and in combination with a fire disturbance. For this study, researchers planned to collect mesocosms from multiple swamps, then randomise them to water and fire treatments in a glasshouse to infer if water availability causes changes in biomass. Mesocosms, for the purpose of this study, are a column of soil and plants, collected by hammering PVC pipe (diameter of 150 mm and a depth of 250 mm) to ground level and extracted with trenching shovels. They would then placed in tubs in a glasshouse, and tub water levels were manipulated to simulate different levels of groundwater availability. A fire event was to be simulated by sequentially applying biomass removal (clipping), heat and smoke to half of the mesocosms in each water treatment after 20 months (see Figure 1 main manuscript).
The example below is a simplified portion of the full experiment and analysis in (Mason et al., 2022)
Feasible - There is enough funding and expertise to conduct a 3.5 year glasshouse experiment with about 250 mesocosms.
Interesting - Swamp communities are likely to be sensitive to changes in the hydrological gradient and fire regime (Keith et al., 2009; Keith et al., 2022) and recent longwall underground coal extraction has caused subsidence, diminishing water resources (Mason et al., 2021).
Novel - Current evidence is from observational studies, no controlled empirical manipulations have been undertaken, and this would add substantially to the evidence base.
Ethical - Extraction of small mesocosms is unlikely to have a negative effect on the health of the ecosystem.
Relevant - Underground coal mining is active in the Southern Coalfield of the Sydney Basin. Understanding the compounding effects of hydrological and fire disturbance will assist conservation of endangered upland swamp communities.
Note - We will assume burnt vegetation will have greater reduction in biomass than unburnt vegetation, and this is not of interest.
The sampling is summarised in Fig. 1
Mesocosms were randomised to high, medium or low water availability treatment levels, and burnt or unburnt fire treatment levels.
To do this we need the randomizr package, and a list of mesocosms.
mesocosms <- read.csv(here("data","mesocosms.csv"))
head(mesocosms) Mesocosm swamp veg
1 CAT_CH_01 CA ch
2 CAT_CH_02 CA ch
3 CAT_CH_03 CA ch
4 CAT_CH_04 CA ch
5 CAT_CH_05 CA ch
6 CAT_CH_06 CA ch
prob_each = rep(1/6,6))mesocosms$treatment = complete_ra(N = nrow(mesocosms), prob_each = rep(1/6,6),
conditions = c("H_u", "M_u", "L_u", "H_b", "M_b", "L_b"))
head(mesocosms) Mesocosm swamp veg treatment
1 CAT_CH_01 CA ch M_u
2 CAT_CH_02 CA ch M_u
3 CAT_CH_03 CA ch L_u
4 CAT_CH_04 CA ch L_u
5 CAT_CH_05 CA ch M_b
6 CAT_CH_06 CA ch M_b
We can check how many mesocosms are in each treatment.
table(mesocosms$treatment)
H_u M_u L_u H_b M_b L_b
41 41 42 41 41 42
method = "mvt" in emmeans)We have three sources of dependence
bio_data <- read.csv(here("data","wetland_biomass.csv")) %>%
mutate(water = factor(water, levels = c("H","M","L")))bio_live <- lmer(log(biomass + 1) ~ swamp + veg + factor(days) * water + factor(days) * fire +
water*fire +
(1 | Mesocosm),
data = bio_data)The warning about rank deficiency means is expected. It is because we don’t have measurements of burnt swamps prior to the burning treatment at 2 years.
Note - re.form = NA gives marginal residuals.
plot(bio_live, resid(. ) ~ predict(., re.form = NA))plot(bio_live, sqrt(abs(resid(. ))) ~ predict(., re.form = NA))Assumptions of linearity and constant variance are approximately satisfied, though there is some hint of variance reducing with the mean.
Start by plotting model estimates. The easiest way is to use emmip from emmeans.
emmeans_plot = emmip(bio_live, ~ water ~ days | fire ,
CIs = TRUE, type = "response") # always include confidence intervals
emmeans_plotWe can take the data from the previous plot and use them to make a prettier plot.
pos = position_dodge(width=70) # dodge water
#colour blind friendly palette
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
plot_df <- emmeans_plot$data %>%
mutate(fire = relevel(fire,"ub"))
ggplot(plot_df, aes(days, yvar, color = water, shape = fire, linetype = fire),
position = position_dodge2(width = 0.1)) +
geom_point( position = pos, size = 2) +
geom_path(position = pos, size = 1) +
geom_errorbar(aes(ymin = LCL, ymax = UCL), position = pos, alpha = 0.5, width = 0, size = 2) +
theme_classic() +
xlim(0,1500) +
xlab("Time since experiment commenced (days)") +
ylab("Mean biomass (+/- 95% CI) per mesocosm (g)") +
scale_colour_manual(values=cbPalette) +
theme(legend.position = "none",
axis.text = element_text( size = 12),
axis.title = element_text( size = 14)) Next we calculate the desired effects and their confidence intervals, again using emmeans.
Estimate the marginal means for all water treatments, at just the times of interest (592 days and 1270 days), for unburnt mesocosms using the emmeans function.
# water by time changes
em_water <- emmeans(bio_live, ~ water + days , type = "response",
at = list(days = c( 1270, 592), fire = "ub"))Note - You may get a warning, but it can be ignored.
Calculate all pairwise interactions between the two.
water_changes <- contrast(em_water, interaction = "pairwise")
water_changes water_pairwise days_pairwise estimate SE df t.ratio p.value
H - M 1270 - 592 0.081 0.254 341 0.320 0.7490
H - L 1270 - 592 0.781 0.253 341 3.093 0.0020
M - L 1270 - 592 0.700 0.253 341 2.771 0.0060
Results are averaged over the levels of: swamp, veg
Degrees-of-freedom method: kenward-roger
Also estimate the means for all water and fire treatment combinations at the last time point (1270 days).
# fire by water changes
em_fire <- emmeans(bio_live, ~ water + fire , type = "response",
at = list(days = c(1270)))Again calculate all pairwise interactions.
fire_changes <- contrast(em_fire, interaction = "pairwise")
fire_changes water_pairwise fire_pairwise estimate SE df t.ratio p.value
H - M b - ub 0.276 0.254 341 1.087 0.2780
H - L b - ub 0.168 0.253 342 0.663 0.5080
M - L b - ub -0.108 0.253 342 -0.428 0.6690
Results are averaged over the levels of: swamp, veg
Degrees-of-freedom method: kenward-roger
Each of the above analyses will answer our primary questions, however we would like to control for multiple testing: for this we can use the rbind function.
# combine these for multiple testing adjustment
combined_effects <- rbind(water_changes, fire_changes, adjust = "mvt")
#confint(combined_effects) #confidence intervals
#summary(combined_effects) # for p-values
#combined table
cbind(summary(combined_effects)[,c(1:4,8)], confint(combined_effects)[, 7:8]) %>%
mutate_at(c(4, 6, 7), round, 1) %>%
mutate_at(5, round,3) water_pairwise days_pairwise fire_pairwise estimate p.value lower.CL upper.CL
1 H - M 1270 - 592 . 0.1 0.995 -0.6 0.7
2 H - L 1270 - 592 . 0.8 0.011 0.1 1.4
3 M - L 1270 - 592 . 0.7 0.029 0.0 1.4
4 H - M . b - ub 0.3 0.716 -0.4 0.9
5 H - L . b - ub 0.2 0.933 -0.5 0.8
6 M - L . b - ub -0.1 0.986 -0.8 0.5
Note: these are slightly different from the analysis in the manuscript, as multiple testing adjustments were applied to all 6 contrasts simultaneously.
Differences in biomass between high and low water unburnt mesocosms more than doubled (relative change = 2.2 (95% CI: 1.1 – 4.2)) between two and four years. Similarly, differences in biomass between unburnt low and medium water mesocosms doubled (relative change = 2.0; 95% CI: 1.1 – 3.9), but there was no evidence of differences in biomass changes between high and medium water mesocosms (relative change = 1.1; 95% CI: 0.6 – 2.1). We did not find any evidence of an interaction between fire and water treatments.
In this experimental glasshouse simulation, reduced water availability leads to large reductions in biomass in wetland communities relative to communities simulating undisturbed swamps (high water availability), however we did not find any evidence of a synergistic effect of fire disturbance on biomass.
The intent of the experiment was to demonstrate a causal relationship between water availability and richness, biomass and composition of wetland species, and every effort was made to meet the causal assumptions for experiments (Kimmel et al., 2021). Some interference may have happen as above ground biomass increased over the course of the experiment, potentially shading neighbouring mesocosms. The amount of shading depends on height (and so biomass), which we know differed between treatments, and could have led to bias over time. To combat this mesocosms were infrequently re-randomised across tubs within water treatment levels. Some mesocosms subsided in the PVC casing after collection. This was problematic as the treatment effect relied on water depth in the tubs. To limit any effect (multiple treatment), the lower section of the subsided mesocosms was packed with a 50:50 mix of nursery-sourced river sand and peat moss to facilitate capillary action up the casing. In total, 101 mesocosms required packing, and these were randomised to all treatments. Soil moisture was measured throughout the experiment, and clear differences between water treatment levels were found, as intended by the experimental design. However, this glasshouse setup does not directly mimic field moisture or nutrient transport profiles and may affect soil moisture, species richness and composition outcomes.