Temporal Trend Analysis
This project uses synthetic data. The workflow reflects practices commonly used across many water quality monitoring programs of this type.
Long-running water quality monitoring programs accumulate years of results across multiple sampling areas. This vignette demonstrates a reproducible pipeline for assessing whether an analyte is trending over time, and whether that trend differs by monitoring area.
What it does
- Multi-year time-series overview figures across analytes and monitoring areas
- Two-way ANOVA (
result ~ year * area) with iterative studentized-residual outlier removal - Assumption checks: Breusch-Pagan heteroscedasticity test, Shapiro-Wilk normality test
- Interaction significance testing that decides between the additive model and
emmeanspost-hoc pairwise comparisons - Slope extraction and back-transformation to a %/year rate of change, since a significant year effect only says a trend exists, not how big it is
- Mann-Kendall trend test and Sen’s slope estimator, run per monitoring area, as an assumption-light cross-check on both the direction and magnitude of the ANOVA trend
- Significance annotation on post-hoc comparison figures, driven by the actual model p-values
Design
The pipeline is organized into modular R functions (trend_model.R, mann_kendall.R, plot_trend.R, utils.R) and documented via an R Markdown vignette, including a flowchart figure of the model’s decision path (outlier removal → assumptions → interaction test → additive/interaction branch). Four case-study analytes exercise different branches of the pipeline: a shared real trend, a flat null case, a trend confined to one area, and a flat case with injected high-leverage outliers.