Git Product home page Git Product logo

wqtrends's Introduction

wqtrends

R-CMD-check pkgdown Codecov test coverage CRAN status DOI

R package to assess water quality trends for long-term monitoring data in estuaries using Generalized Additive Models with error propagation from mixed-effect meta-analysis. Uses concepts in the mgcv and mixmeta packages. Detailed information on the methods used in this package are described in the following open access article:

Beck, M.W., de Valpine, P., Murphy, R., Wren, I., Chelsky, A., Foley, M., Senn, D.B. 2022. Multi-scale trend analysis of water quality using error propagation of Generalized Additive Models. Science of the Total Environment. 802:149927. https://doi.org/10.1016/j.scitotenv.2021.149927

Installation

Install the package from CRAN as follows. The development version of the package can be installed from r-universe. The source code is available on GitHub.

# Install wqtrends in R:
install.packages('wqtrends')

# load wqtrends
library(wqtrends)

Issues and suggestions

Please report any issues and suggestions on the issues link for the repository.

wqtrends's People

Contributors

fawda123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wqtrends's Issues

back-transformation giving very small se for GPP

Estimates of seasonal averages for GPP give very small standard error estimates on the back-transformed results. Works fine for chl:

library(wqtrends)
library(dplyr)
library(ggplot2)

tomod <- rawdat %>%
  filter(station %in% 32) %>%
  filter(param %in% 'chl')

gam2 <- anlz_gam(tomod, mod = 'gam2', trans = 'log10')
  
avgs <- anlz_avgseason(mods = list(gam2), doystr = 90, doyend = 180)

ggplot(avgs, aes(x = yr, y = predicted)) +
  geom_point() + 
  geom_errorbar(aes(ymin = predicted - se, ymax = predicted + se))

image

GPP gives very small standard error:

tomod <- rawdat %>%
  filter(station %in% 32) %>%
  filter(param %in% 'gpp')

gam2 <- anlz_gam(tomod, mod = 'gam2', trans = 'log10')
  
avgs <- anlz_avgseason(mods = list(gam2), doystr = 90, doyend = 180)

ggplot(avgs, aes(x = yr, y = predicted)) +
  geom_point() + 
  geom_errorbar(aes(ymin = predicted - se, ymax = predicted + se))

image

GPP using identity transformation looks better.

tomod <- rawdat %>%
  filter(station %in% 32) %>%
  filter(param %in% 'gpp')

gam2 <- anlz_gam(tomod, mod = 'gam2', trans = 'ident')
  
avgs <- anlz_avgseason(mods = list(gam2), doystr = 90, doyend = 180)

ggplot(avgs, aes(x = yr, y = predicted)) +
  geom_point() + 
  geom_errorbar(aes(ymin = predicted - se, ymax = predicted + se))

image

The small CI values occur for both BoxCox and log transformations of GPP. It is likely an error with the back-transformation bias correction factor starting here:

sdval <- sd(resid(mod), na.rm = TRUE)

Fix centering to deal with odd years in anlz_trndeason

If justify = "center" and win is odd, the current lines don't fix the center of the window correctly:

if(justify == 'center'){
yrstr <- round(yr - win / 2)
yrend <- round(yr + win / 2)
if(win %% 2 != 0){
yrstr <- yrstr + 1
yrend <- yrend - 1
}

This was an attempt at fixing the window to be exactly centered for an odd number of years, at the expense of not including the exact number of years specified in win.

Use floor instead and get rid of the exception for odd years. This will create an off-centered window (only by one year), but it will always calculate the window width exactly as specified by the user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.