Sovereign 8s.is mirror of standardgalactic/WQ_SWMP_Synthesis
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-05-11 10:34:33 -04:00
Data Clearing out unused dtaa and analyses to prepare repo for publication 2025-05-19 12:09:18 -05:00
helper_files Clearing out unused dtaa and analyses to prepare repo for publication 2025-05-19 12:09:18 -05:00
Outputs Updates to figures, re-run models with different sites and salinity to check for model influence and other sanity checks. 2026-05-11 10:34:33 -04:00
R Updates to figures, re-run models with different sites and salinity to check for model influence and other sanity checks. 2026-05-11 10:34:33 -04:00
.gitignore Clearing out unused dtaa and analyses to prepare repo for publication 2025-05-19 12:09:18 -05:00
Draft 4.docx Update figure 1 with correct median data 2025-05-26 20:53:11 -05:00
README.md cleaned up README headers 2025-05-21 11:12:25 -05:00
remove_stns.docx Intermediate update for paper revisions. 2026-04-24 11:13:25 -04:00
Trend_quickcalcs.xlsx Upload all files 2025-05-19 11:25:18 -05:00
WQ_SWMP_Synthesis.Rproj rename 2025-05-19 15:40:17 -05:00

SWMP Water Quality Synthesis

The final dataset used in this project was downloaded from the CDMO through the Advanced Query System, Zip download option on 8/29/2023. 'All Reserves and Stations' was selected. The date range selected was 2002 - 2022. The downloaded zip file was 1.6 GB.

Repository Organization

Sub-folders of this repository were created to provide some organization of the different coding needs for the project. Most sub-folders have a README with more detail. Current sub-folders are:

  • Data - meant to contain data, as processed by scripts in R/Data_processing. The full dataset is not committed to github due to its size but is available on Box - see below for links. Described well by the Data Processing readme.
  • helper_files - scripts of functions and definitions (e.g. which parameters and flags/codes to use) that are needed across sub-folders. Also contains csv files with helpful information on sampling stations (from the CDMO download) and QAQC flags and codes.
  • Outputs - files generated from analyses and visualization code. This includes calculated trends, predictive model outputs, and visualizations. Outputs readme
  • R - code; divided into three subfolders.
    • Analyses_for_paper - main folder for calculations and modeling. Linked closely to the Outputs folder. Analyses_for_paper README
    • Data_processing - scripts that were used to process downloaded data by combining files from a station, removing data points that did not pass various QA/QC criteria, and aggregating to daily and monthly levels. Data Processing readme
    • Figures - scripts that were used to produce figures such as maps and graphs.

Compilation of details and additional READMEs

General Methods Summary

For a much more detailed write-up of the stats, see the Statistical Methods - Detailed portion of the R/Analyses_for_paper readme. For more detail on Data Processing, see the Data Processing readme.

At HUD NERR stations, NO3 was used as a proxy for NO23 because NO23 was not reported for the vast majority of the reporting period. Comparisons between the two once both were reported showed that they were very similar, and R^2 in a regression model between the two was almost 1.

Data Processing

General data processing was performed using the SWMPr package (v. 2.5.0, Beck 2016) and tidyverse meta-package for R (Wickham et al. 2019).

Data files from all Reserves and stations, with a date range of 2002-2022, were downloaded from the NERRS Centralized Data Management Office's Advanced Query System, Zip Download option, on 8/29/2023. Only SWMP stations that started collecting data before 2013, were active as of the end of 2022, and collected both water quality (WQ) and nutrient (NUT) data types were included in analyses. Water quality stations that were abnormally deep (long-term median depth > 6m: pdbgd, kachd, and kacsd) were removed after trend calculation. Generally, data points flagged as either suspect or rejected were excluded from these analyses. For nutrients, only grab samples were included. Typically each NUT station has two replicate grab samples per month, though some stations collect more.

Data Point Inclusion. SWMP data points go through multiple rounds of QA/QC at the Reserve level and with the CDMO. A wide range of general quality and descriptors can be documented through combinations of numeric flags and alphabetic codes (see https://cdmo.baruch.sc.edu/data/qaqc.cfm for details). For this analysis, any data points flagged as 'suspect' or 'rejected' were excluded from analysis, with exceptions when 'suspect' was combined with an 'algae bloom' or 'instrument recording error; recovered telemetry data' descriptor.

Aggregation to monthly values. Monthly aggregated values (median, quartiles, sd, IQR) were calculated for WQ or meteorological (MET) data only if a month had at least one week's worth of valid values. For 15-minute data, the cutoff was 672 points. To calculate monthly values for NUT data, valid monthly replicates were averaged. If at least one valid replicate was identified as censored, the averaged value was also identified as censored. Monthly medians for each parameter from this aggregation process were used in trend calculations and further modeling.

Statistical Methods Summary

Prioritized parameters

We chose trends in chlorophyll a, dissolved oxygen (DO, mg/L), and proportion of readings where DO < 2 as indicators of eutrophication.

Primary predictor variables we chose were: water temperature (temp), specific conductance (spcond), turbidity (turb), chlorophyll a (chla), dissolved ammonium (NH4), dissolved nitrate+nitrite (NO23), dissolved inorganic phosphorus (PO4), daily total photosynthetically active radiation (dailyPAR), and monthly total precipitation (precp). Organic forms of Nitrogen and Phosphorus are known to be important but are not measured as part of SWMP, so could not be included here. Nutrient values flagged as below detection were changed to one-half of the measurement detection limit (MDL).

Long-term medians and trends of all parameters were calculated, from monthly median values, for potential inclusion as predictors in models of eutrophication. When studying PAR time series, differences when sensors were changed were apparent at several stations, leading us to exclude PAR from the pool of predictors.

Due to collinearity between median DO mg/L, median water temperature, and latitude, these variables were combined into a Principal Components Analysis, and a station's score on axis 1 was used as a predictor in modeling (named 'tld_PC1').

See 'data_dictionary_trend_parameters.csv' for details on each parameter, its units, any transformations, and the distribution used.

Long-term trend calculations

Long-term trends in the monthly median values of prioritized parameters were calculated as the linear effect of time after accounting for seasonality as a cyclical spline using Generalized Additive Models (GAMs), via the bam() function of the mgcv package (v. 1.8.41; Wood 2017). The bam() function was also used to adjust for autocorrelation in residuals, when present. For WQ, MET, and NUT parameters, we used the default family = gaussian(). The exception for WQ parameters was proportion of time DO was < 2 mg/L; because this was a proportion, family = betar() was used. For NUT parameters, values were first log-transformed.

See 'data_dictionary_trend_parameters.csv' for details on each parameter, its units, any transformations, and the distribution used.

Assessing predictors of eutrophication trends

To assess how well environmental conditions and changes in environmental conditions explain or predict changes in our three key response variables, chlorophyll a and dissolved oxygen as DO mg/L and as proportion of time DO < 2 mg/L ('doLT2'), we used an information theoretic model selection framework (Burnham and Anderson 2002). We carefully chose predictors for each of the three responses from the prioritized variables described above. No interactions were included.

All variables were mean-centered and scaled to 1 standard deviation before model-fitting to help with model convergence in mixed models, to enable comparison between standardized coefficients in final models, and to ensure appropriate model selection and averaging (Harrison et al. 2018, Grueber et al. 2011, Symonds and Moussalli 2011). When appropriate for interpreting results, coefficients were back-calculated to either their original units or to percent-per-year change (when log transformations had been performed).

Global models were constructed with the predictors and a random effect for Reserve and fit, using Restricted Maximum Likelihood (REML), with the lme() function of the R nlme package (v. 3.1.160; Pinherio et al. 2022). To determine whether the random effect was necessary, a simple linear model without random effect was constructed via nlme::gls(), also using REML. REML is required when using AIC to compare models with different random effect structures (Zuur et al. 2009, section 5.7). When comparing models with the same random effect structure but different fixed effects, Maximum Likelihood (ML) must be used (Zuur et al. 2009). When the random effect was required (chla models), the global model was re-fit in lme() using Maximum Likelihood (ML) for subsequent model selection. When the random effect was not required (DO models), global models were re-fit as simple linear models, using stats::lm() (R Core Team 2022).

All model selection, averaging, and variable importance calculations were performed using the R MuMIn package (v. 1.47.5; Barton 2023). All-subsets selection was conducted using the dredge() function. Due to varying recommendations on AIC thresholds for top model sets (e.g. Bolker et al. 2009, Burnham and Anderson 2002, Richards 2008) and based on the number of models that would be included using different thresholds (Grueber et al. 2011), we generated top model sets for each response based on delta AICc for thresholds of 2, 4, and 6. Results using delta < 4 are presented here; results for deltas 2 and 6 are provided in supplementary materials. Final standardized coefficients were generated by averaging the top model sets with model.avg(), using the full-model method, which is appropriate for comparing relative effect sizes when there is high model uncertainty (Symonds and Moussalli 2011). Variable importance was assessed partly by comparing standardized coefficients but also by using metrics calculated by the sw() function. The sum of Akaike weights of models in which a predictor appears can be interpreted as the probability that the predictor is in the “best” model (Grueber et al. 2011, Symonds and Moussalli 2011). The function also shows how many models from the top set a predictor appeared in. Predictors that are in many models and/or highly weighted models will have higher weights than those in few and/or low-weighted models.

Graphics were generated using the ggplot2 package in R, part of the tidyverse meta-package (Wickham et al. 2019).

References

Full citations referenced above can be found in the more detailed R/Analyses_for_paper readme's References section.