Skip to contents

Available metrics

In tidyhydro v0.1.1.9000, 7 metrics are implemented.

Metrics currently implemented in tidyhydro v0.1.1.9000
Name Abbr. Function calls Reference
Kling-Gupta Efficiency \(KGE\) kge, kge_vec Gupta, H.V.; Kling, H.; Yilmaz, K.K.; Martinez, G.F. (2009). Journal of Hydrology, 377(1–2), 80–91.
Modified Kling-Gupta Efficiency \(KGE'\) kge2012, kge_vec Kling, H., Fuchs, M., & Paulin, M. (2012). Journal of Hydrology, 424–425, 264–277.
Nash-Sutcliffe Efficiency \(NSE\) nse, nse_vec Nash, J. E., & Sutcliffe, J. V. (1970). Journal of Hydrology, 10(3), 282–290.
Mean Squared Error \(MSE\) mse, mse_vec Clark, M. P., Vogel, R. M., Lamontagne, J. R., Mizukami, N., Knoben, W. J. M., Tang, G., Gharari, S., Freer, J. E., Whitfield, P. H., Shook, K. R., & Papalexiou, S. M. (2021). The Abuse of Popular Performance Metrics in Hydrologic Modeling. Water Resources Research, 57(9), e2020WR029001.
Percent BIAS \(pBIAS\) pbias, pbias_vec Gupta, H. V., S. Sorooshian, and P. O. Yapo. (1999). Status of automatic calibration for hydrologic models: Comparison with multilevel expert calibration. J. Hydrologic Eng. 4(2): 135-143
PRediction Error Sum of Squares \(PRESS\) press, press_vec Rasmussen, P. P., Gray, J. R., Glysson, G. D. & Ziegler, A. C. Guidelines and procedures for computing time-series suspended-sediment concentrations and loads from in-stream turbidity-sensor and streamflow data. in U.S. Geological Survey Techniques and Methods book 3, chap. C4 53 (2009)
Standard Factorial Error \(SFE\) sfe, sfe_vec Herschy, R.W. 1978: Accuracy. Chapter 10 In: Herschy, R.W. (ed.) Hydrometry - principles and practices. John Wiley and Sons, Chichester, 511 p.

avacha dataset

The package includes the mean daily water discharge values (obs in m³/s) measured at the state gauging station Avacha River — Elizovo City (site No. 2090). Alongside the measured water discharge, the mean water discharge in the last 24 hours derived from the GloFAS-ERA5 v4.0 reanalysis is provided (sim).

library(ggplot2)
library(tidyhydro)
data(avacha)

avacha |>
  ggplot(aes(x = date)) +
  geom_line(aes(y = obs, colour = "Measured")) +
  geom_line(aes(y = sim, colour = "Predicted")) +
  scale_colour_brewer(name = "", palette = "Set1") +
  labs(x = "", y = "Water Discharge, m³/s")

Avacha River - Elizovo City hydrograph

Example usage

One can estimate the desired metrics using the tidyverse syntax. For example, to get the Nash-Sutcliffe Efficiency (\(NSE\)) or Modified Kling-Gupta Efficiency (\(KGE'\)) for the avacha dataset, one can run:

nse(avacha, obs, sim)
#> # A tibble: 1 × 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 nse     standard       0.895
kge2012(avacha, obs, sim)
#> # A tibble: 1 × 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 kge2012 standard       0.947

Or using the yardstick helper functions, one can create a metric set, combining it with other yardstick metrics, such as \(R^2\):

library(yardstick)
hydro_metrics <- metric_set(kge, pbias, rsq)
hydro_metrics(avacha, obs, sim)
#> # A tibble: 3 × 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 kge     standard      0.947 
#> 2 pbias   standard      0.0540
#> 3 rsq     standard      0.898

Such syntax is particularly useful when running a group analysis, for example, estimating model performance for different months:

library(lubridate)
library(dplyr)

avacha |>
  mutate(month = month(date)) |>
  group_by(month) |>
  nse(obs, sim)
#> # A tibble: 12 × 4
#>    month .metric .estimator .estimate
#>    <dbl> <chr>   <chr>          <dbl>
#>  1     1 nse     standard    -2.78   
#>  2     2 nse     standard     0.180  
#>  3     3 nse     standard     0.0335 
#>  4     4 nse     standard    -0.00438
#>  5     5 nse     standard     0.815  
#>  6     6 nse     standard    -2.78   
#>  7     7 nse     standard    -0.244  
#>  8     8 nse     standard    -0.228  
#>  9     9 nse     standard     0.359  
#> 10    10 nse     standard     0.466  
#> 11    11 nse     standard     0.439  
#> 12    12 nse     standard     0.455

Alternatively, one can still use the vectorised versions of the metrics, ending with the *_vec suffix:

nse_vec(truth = avacha$obs, estimate = avacha$sim)
#> [1] 0.895008