Skip to content

Commit 51307fd

Browse files
committed
docs: add keywords to references
1 parent f0d648e commit 51307fd

19 files changed

Lines changed: 81 additions & 62 deletions

R/RcppExports.R

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
2-
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3-
4-
kge_cpp <- function(obs, sim, na_rm = TRUE, version = "2012") {
5-
.Call(`_tidyhydro_kge_cpp`, obs, sim, na_rm, version)
6-
}
7-
8-
mse_cpp <- function(truth, estimate, na_rm = TRUE) {
9-
.Call(`_tidyhydro_mse_cpp`, truth, estimate, na_rm)
10-
}
11-
12-
nse_cpp <- function(truth, estimate, performance = FALSE, na_rm = TRUE) {
13-
.Call(`_tidyhydro_nse_cpp`, truth, estimate, performance, na_rm)
14-
}
15-
16-
pbias_cpp <- function(truth, estimate, performance = FALSE, na_rm = TRUE) {
17-
.Call(`_tidyhydro_pbias_cpp`, truth, estimate, performance, na_rm)
18-
}
19-
20-
press_cpp <- function(truth, estimate, na_rm = TRUE) {
21-
.Call(`_tidyhydro_press_cpp`, truth, estimate, na_rm)
22-
}
23-
24-
sfe_cpp <- function(truth, estimate, na_rm = TRUE) {
25-
.Call(`_tidyhydro_sfe_cpp`, truth, estimate, na_rm)
26-
}
27-
1+
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
2+
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3+
4+
kge_cpp <- function(obs, sim, na_rm = TRUE, version = "2012") {
5+
.Call(`_tidyhydro_kge_cpp`, obs, sim, na_rm, version)
6+
}
7+
8+
mse_cpp <- function(truth, estimate, na_rm = TRUE) {
9+
.Call(`_tidyhydro_mse_cpp`, truth, estimate, na_rm)
10+
}
11+
12+
nse_cpp <- function(truth, estimate, performance = FALSE, na_rm = TRUE) {
13+
.Call(`_tidyhydro_nse_cpp`, truth, estimate, performance, na_rm)
14+
}
15+
16+
pbias_cpp <- function(truth, estimate, performance = FALSE, na_rm = TRUE) {
17+
.Call(`_tidyhydro_pbias_cpp`, truth, estimate, performance, na_rm)
18+
}
19+
20+
press_cpp <- function(truth, estimate, na_rm = TRUE) {
21+
.Call(`_tidyhydro_press_cpp`, truth, estimate, na_rm)
22+
}
23+
24+
sfe_cpp <- function(truth, estimate, na_rm = TRUE) {
25+
.Call(`_tidyhydro_sfe_cpp`, truth, estimate, na_rm)
26+
}
27+

R/data.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#' Mean Daily Water Discharge At Avacha River (Elizovo City)
2-
#'
2+
#' @keywords data
3+
#'
34
#' @details These data contain the measured (`obs`) mean daily water discharge
45
#' values (in \eqn{m^3/s}) at the Avacha River -- Elizovo City state gauging
56
#' station for the 2022 calendar year. They are accompanied by the GloFAS v4.0

R/kge.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#' Kling-Gupta Efficiency (KGE)
2+
#' @keywords gof
23
#'
34
#' @description
45
#' Calculate the Kling-Gupta Efficiency (*Gupta et al., 2009*).
@@ -122,6 +123,7 @@ kge_vec <- function(
122123
}
123124

124125
#' Modified Kling-Gupta Efficiency (KGE')
126+
#' @keywords gof
125127
#'
126128
#' @description
127129
#' Calculate the modified Kling-Gupta Efficiency (*Kling et al., 2012*),

R/mse.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#' Mean Squared Error (MSE)
2+
#' @keywords gof
23
#'
34
#' @description
45
#' The MSE is a metric that evaluates the goodness of fit between model

R/nse.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#' Nash-Sutcliffe Efficiency (NSE)
2+
#' @keywords gof
23
#'
34
#' @description
45
#' Calculate the Nash-Sutcliffe efficiency (*Nash & Sutcliffe, 1970*).

R/pbias.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#' Percent BIAS (pBIAS)
2+
#' @keywords gof
23
#'
34
#' @description
4-
#' \eqn{pBIAS} is the deviation of data being evaluated, expressed as a
5-
#' percentage. It measures the average tendency of the simulated data to be
6-
#' larger or smaller than their observed counterparts (*Moriasi et al., 2015*).
7-
#' The optimal value of \eqn{pBIAS} is 0.0, with low-magnitude values
8-
#' indicating accurate mode simulation. Positive values indicate model
9-
#' underestimation bias, and negative values indicate model overestimation
5+
#' \eqn{pBIAS} is the deviation of data being evaluated, expressed as a
6+
#' percentage. It measures the average tendency of the simulated data to be
7+
#' larger or smaller than their observed counterparts (*Moriasi et al., 2015*).
8+
#' The optimal value of \eqn{pBIAS} is 0.0, with low-magnitude values
9+
#' indicating accurate mode simulation. Positive values indicate model
10+
#' underestimation bias, and negative values indicate model overestimation
1011
#' bias (*Gupta et al., 1999*).
1112
#'
1213
#' @details
@@ -16,13 +17,13 @@
1617
#' pBIAS = 100 \times \frac{\sum_{i=1}^{n}{(sim_i - obs_i)}}
1718
#' {\sum_{i=1}^{n}{obs_i}}
1819
#' }
19-
#'
20+
#'
2021
#' where:
2122
#' \itemize{
2223
#' \item \eqn{sim} defines model simulations at time step \eqn{i}
2324
#' \item \eqn{obs} defines model observations at time step \eqn{i}
2425
#' }
25-
#'
26+
#'
2627
#' According to Moriasi et al. (2015) the metric interpretation can be as
2728
#' follows:
2829
#'

R/press.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#' PRediction Error Sum of Squares (PRESS)
2+
#' @keywords regression
23
#'
34
#' @description
45
#' \eqn{PRESS} is a measure of the quality of a regression model using

R/sfe.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#' Standard Factorial Error (SFE)
2+
#' @keywords regression
23
#'
34
#' @description
45
#' Prediction standard factorial error estimated
@@ -7,8 +8,8 @@
78
#' @details
89
#' The metric is widely used for assessing Sediment Rating Curves
910
#' (e.g., Hicks et al. 2020). The model is usually considered 'unacceptable'
10-
#' if the \eqn{SFE > 2}, see Hicks et al. (2011).
11-
#'
11+
#' if the \eqn{SFE > 2}, see Hicks et al. (2011).
12+
#'
1213
#' It is estimated as follows:
1314
#' \deqn{SFE = \exp\left(\sqrt{\frac{1}{n} \sum_{i=1}^{n}
1415
#' \left( \log\left(\frac{obs_i}{sim_i} \right) \right)^2 }\right)}

README.Rmd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ The `tidyhydro` package provides a set of commonly used metrics in hydrology (su
3838
Additionally, 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](https://pubs.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 documentation for details).
3939

4040
## Example
41-
The `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:
41+
The `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 `KGE`, `NSE` or `pBIAS` for a data frame like this:
4242

4343
```{r example}
4444
library(tidyhydro)
4545
data(avacha)
46-
47-
avacha
46+
str(avacha)
4847
4948
kge(avacha, obs, sim)
5049
```

README.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,16 @@ Error) and others. Based on the equations from *Helsel et al.*
4141
The `tidyhydro` package follows the philosophy of
4242
[`yardstick`](https://github.com/tidymodels/yardstick/tree/main) and
4343
provides S3 class methods for vectors and data frames. For example, one
44-
can estimate `NSE` and `pBIAS` for a data frame like this:
44+
can estimate `KGE`, `NSE` or `pBIAS` for a data frame like this:
4545

4646
``` r
4747
library(tidyhydro)
4848
data(avacha)
49-
50-
avacha
51-
#> # A data frame: 365 × 3
52-
#> date obs sim
53-
#> <date> <dbl> <dbl>
54-
#> 1 2022-01-01 76.2 84.8
55-
#> 2 2022-01-02 76.2 84.3
56-
#> 3 2022-01-03 76.3 84.0
57-
#> 4 2022-01-04 76.3 83.7
58-
#> 5 2022-01-05 76.4 83.4
59-
#> 6 2022-01-06 76.4 83.1
60-
#> 7 2022-01-07 76.5 83.0
61-
#> 8 2022-01-08 76.5 82.9
62-
#> 9 2022-01-09 76.6 82.8
63-
#> 10 2022-01-10 76.6 82.7
64-
#> # ℹ 355 more rows
49+
str(avacha)
50+
#> Classes 'tbl_df', 'tbl' and 'data.frame': 365 obs. of 3 variables:
51+
#> $ date: Date, format: "2022-01-01" "2022-01-02" ...
52+
#> $ obs : num 76.2 76.2 76.3 76.3 76.4 76.4 76.5 76.5 76.6 76.6 ...
53+
#> $ sim : num 84.8 84.3 84 83.7 83.4 ...
6554

6655
kge(avacha, obs, sim)
6756
#> # A tibble: 1 × 3
@@ -140,9 +129,9 @@ bench::mark(
140129
#> # A tibble: 3 × 6
141130
#> expression min median `itr/sec` mem_alloc `gc/sec`
142131
#> <bch:expr> <dbl> <dbl> <dbl> <dbl> <dbl>
143-
#> 1 tidyhydro 1 1 52.8 NaN NaN
144-
#> 2 hydroGOF 30.5 41.1 1 Inf Inf
145-
#> 3 baseR 17.3 20.6 2.31 Inf Inf
132+
#> 1 tidyhydro 1 1 29.2 NaN NaN
133+
#> 2 hydroGOF 15.1 19.1 1 Inf Inf
134+
#> 3 baseR 8.47 10.4 2.42 Inf Inf
146135
```
147136

148137
## Code of Conduct

0 commit comments

Comments
 (0)