Skip to contents

Mirrors the continuous metrics of the C# GoodnessOfFit class of the Numerics library.

Usage

goodness_of_fit(observed, modeled, metrics = "all", k = 0)

Arguments

observed, modeled

numeric vectors of equal length.

metrics

"all" (the default) for every metric as a named vector, or a character vector of metric names drawn from rmse, mse, mae, mape, smape, nse, log_nse, kge, kge_mod, pbias, rsr, pearson, r_squared, d, d_mod, d_ref, ve. "all" evaluates every metric eagerly, including mape, which errors if observed contains a zero; ask for just the metrics you want to avoid that.

k

degrees-of-freedom correction subtracted from the sample size in the RMSE denominator. Default 0.

Value

a named numeric vector.

Examples

obs <- c(2, 4, 6, 8, 10)
mod <- c(2.2, 3.9, 6.4, 7.5, 10.1)
goodness_of_fit(obs, mod)
#>      rmse       mse       mae      mape     smape       nse   log_nse       kge 
#> 0.3065942 0.0940000 0.2600000 5.2833333 5.1907412 0.9882500 0.9888468 0.9746773 
#>   kge_mod     pbias       rsr   pearson r_squared         d     d_mod     d_ref 
#> 0.9715356 0.3333333 0.1083974 0.9943098 0.9886519 0.9969808 0.9456067 0.9458333 
#>        ve 
#> 0.9566667 
goodness_of_fit(obs, mod, metrics = c("nse", "kge"))
#>       nse       kge 
#> 0.9882500 0.9746773