{"id":20850632,"url":"https://github.com/atsyplenkov/tidyhydro","last_synced_at":"2025-04-10T19:51:22.023Z","repository":{"id":240318077,"uuid":"788258121","full_name":"atsyplenkov/tidyhydro","owner":"atsyplenkov","description":"Commonly Used Metrics In Hydrological Modelling","archived":false,"fork":false,"pushed_at":"2025-02-21T02:17:29.000Z","size":5934,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T12:59:08.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atsyplenkov.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-18T04:25:25.000Z","updated_at":"2025-02-21T02:14:37.000Z","dependencies_parsed_at":"2024-05-18T01:32:03.179Z","dependency_job_id":"ed51ff17-934b-44c7-962e-ec9c93223a45","html_url":"https://github.com/atsyplenkov/tidyhydro","commit_stats":null,"previous_names":["atsyplenkov/tidyhydro"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ftidyhydro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ftidyhydro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ftidyhydro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ftidyhydro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atsyplenkov","download_url":"https://codeload.github.com/atsyplenkov/tidyhydro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248283528,"owners_count":21077865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T03:10:42.002Z","updated_at":"2025-04-10T19:51:22.009Z","avatar_url":"https://github.com/atsyplenkov.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\r\noutput:\r\n  github_document:\r\n    html_preview: false\r\n---\r\n\r\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\r\n\r\n```{r, include = FALSE}\r\nknitr::opts_chunk$set(\r\n  collapse = TRUE,\r\n  comment = \"#\u003e\",\r\n  fig.path = \"man/figures/README-\",\r\n  out.width = \"100%\"\r\n)\r\n\r\nrequireNamespace(\"hydroGOF\", quietly = TRUE)\r\nrequireNamespace(\"bench\", quietly = TRUE)\r\n```\r\n\r\n# tidyhydro\r\n\r\n\u003c!-- badges: start --\u003e\r\n[![R-CMD-check](https://github.com/atsyplenkov/tidyhydro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/atsyplenkov/tidyhydro/actions/workflows/R-CMD-check.yaml)\r\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\r\n[![CRAN status](https://www.r-pkg.org/badges/version/tidyhydro)](https://CRAN.R-project.org/package=tidyhydro)\r\n![GitHub last commit](https://img.shields.io/github/last-commit/atsyplenkov/tidyhydro)\r\n\u003c!-- badges: end --\u003e\r\n\r\nThe `tidyhydro` package provides a set of commonly used metrics in hydrology (such as _NSE_, _KGE_, _pBIAS_) for use within a [`tidymodels`](https://www.tidymodels.org/) infrastructure. Originally inspired by the [`yardstick`](https://github.com/tidymodels/yardstick/tree/main)and [`hydroGOF`](https://github.com/hzambran/hydroGOF) packages, this library is mainly written in C++ and provides a very quick estimation of desired goodness-of-fit criteria.\r\n\r\nAdditionally, you'll find here a C++ implementation of lesser-known yet powerful metrics used in reports from the United States Geological Survey (USGS) and the National Environmental Monitoring Standards (NEMS) guidelines. Examples include _PRESS_ (Prediction Error Sum of Squares), _SFE_ (Standard Factorial Error), and _MSPE_ (Model Standard Percentage Error) and others. Based on the equations from _Helsel et al._ ([2020](http://pubs.er.usgs.gov/publication/tm4A3)), _Rasmunsen et al._ ([2008](https://pubs.usgs.gov/tm/tm3c4/)), _Hicks et al._ ([2020](https://www.nems.org.nz/documents/suspended-sediment)) and etc. (see functions documentation for details).\r\n\r\n## Example\r\nThe `tidyhydro` package follows the philosophy of [`yardstick`](https://github.com/tidymodels/yardstick/tree/main) and provides S3 class methods for vectors and data frames. For example, one can estimate `NSE` and `pBIAS` for a data frame like this:\r\n\r\n```{r example}\r\nlibrary(yardstick)\r\nlibrary(tidyhydro)\r\ndata(solubility_test)\r\n\r\nnse(solubility_test, solubility, prediction)\r\n\r\npbias(solubility_test, solubility, prediction)\r\n```\r\n\r\nor create a [`metric_set`](https://yardstick.tidymodels.org/reference/metric_set.html) and estimate several parameters at once like this:\r\n\r\n```{r metricset}\r\nhydro_metrics \u003c- yardstick::metric_set(nse, pbias)\r\n\r\nhydro_metrics(solubility_test, solubility, prediction)\r\n```\r\n\r\nWe do understand that sometimes one needs a qualitative interpretation of the model; therefore, we populated every function with a `performance` argument. When `performance = TRUE`, the metric interpretation will be returned according to Moriasi et al. ([2015](https://elibrary.asabe.org/abstract.asp?aid=46548\u0026t=3\u0026dabs=Y\u0026redir=\u0026redirType=)).\r\n\r\n```{r interpretation}\r\nhydro_metrics(solubility_test, solubility, prediction, performance = TRUE)\r\n```\r\n\r\n## Installation\r\n\r\nYou can install the development version of `tidyhydro` from [GitHub](https://github.com/atsyplenkov/tidyhydro) with:\r\n\r\n``` r\r\n# install.packages(\"devtools\")\r\ndevtools::install_github(\"atsyplenkov/tidyhydro\")\r\n\r\n# OR\r\n\r\n# install.packages(\"pak\")\r\npak::pak(\"atsyplenkov/tidyhydro\")\r\n```\r\n\r\n## Benchmarking\r\nSince the package uses `Rcpp` in the background, it performs slightly faster than base R and other R packages:\r\n```{r benchmarking}\r\nx \u003c- runif(10^5)\r\ny \u003c- runif(10^5)\r\n\r\nnse \u003c- function(truth, estimate, na_rm = TRUE) {\r\n  1 -\r\n    (\r\n      sum((truth - estimate)^2, na.rm = na_rm) /\r\n        sum((truth - mean(truth, na.rm = na_rm))^2, na.rm = na_rm)\r\n    )\r\n}\r\n\r\nbench::mark(\r\n  tidyhydro = tidyhydro::nse_vec(truth = x, estimate = y),\r\n  hydroGOF = hydroGOF::NSE(sim = y, obs = x),\r\n  baseR = nse(truth = x, estimate = y),\r\n  check = TRUE,\r\n  relative = TRUE,\r\n  iterations = 100L\r\n)\r\n```\r\n\r\n## See also\r\n- [`hydroGOF`](https://github.com/hzambran/hydroGOF) - Goodness-of-fit functions for comparison of simulated and observed hydrological time series\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatsyplenkov%2Ftidyhydro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatsyplenkov%2Ftidyhydro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatsyplenkov%2Ftidyhydro/lists"}