vnse: Nash-Sutcliffe model efficiency (NSE)

View source: R/vnse.R

vnseR Documentation

Nash-Sutcliffe model efficiency (NSE)

Description

This function computes the Nash-Sutcliffe model efficiency (NSE) or "Nash and Sutcliffe’s coefficient of efficiency (E)".

Usage

vnse(predicted, observed, na.rm = FALSE)

Arguments

predicted

numeric vector that contains the model predicted data points (1st parameter)

observed

numeric vector that contains the observed data points (2nd parameter)

na.rm

logical vector that determines whether the missing values should be removed or not.

Details

NSE or E is expressed as

E = 1 - \frac{\sum \limits_{i=1}^n{\left(P_i - O_i\right)^2}}{\sum \limits_{i=1}^n{\left(O_i - \bar{O}\right)^2}}

E

"Nash and Sutcliffe’s coefficient of efficiency (E)"

n

the number of observations

P

the "model estimates or predictions"

O

the "pairwise-matched observations that are judged to be reliable"

\bar{O}

the "true" mean of the observations

Note: Both P and O should have the same units.

"Nash and Sutcliffe’s coefficient of efficiency (E)" and other "dimensionless measures of average error" are fully discussed in the Willmott reference.

Value

Nash-Sutcliffe model efficiency (NSE) as a numeric vector. The default choice is that any NA values will be kept (na.rm = FALSE). This can be changed by specifying na.rm = TRUE, such as vnse(pre, obs, na.rm = TRUE).

References

Cort J. Willmott, Scott M. Robeson, and Kenji Matsuura, "A refined index of model performance", International Journal of Climatology, Volume 32, Issue 13, pages 2088-2094, 15 November 2012, article from ResearchGate: https://www.researchgate.net/publication/235961403_A_refined_index_of_model_performance.

See Also

mape for mean absolute percent error (MAPE), mae for mean-absolute error (MAE), madstat for mean-absolute deviation (MAD), dr for "index of agreement (dr)", and rmse for root mean square error (RMSE).

Examples


library("ie2misc")

obs <- 1:10 # observed
pre <- 2:11 # predicted
vnse(pre, obs)


library("rando")

set_n(100) # makes the example reproducible
obs1 <- r_norm(.seed = 609) # observed
pre1 <- r_norm(.seed = 624) # predicted


# using the vectors pre1 and obs1
vnse(pre1, obs1)


# using a matrix of the numeric vectors pre1 and obs1
mat1 <- matrix(data = c(obs1, pre1), nrow = length(pre1), ncol = 2,
   byrow = FALSE, dimnames = list(c(rep("", length(pre1))),
   c("Predicted", "Observed")))
vnse(mat1[, 2], mat1[, 1])

# mat1[, 1] # observed values from column 1 of mat1
# mat1[, 2] # predicted values from column 2 of mat1


# using a data.frame of the numeric vectors pre1 and obs1
df1 <- data.frame(obs1, pre1)
vnse(df1[, 2], df1[, 1])

# df1[, 1] # observed values from column 1 of df1
# df1[, 2] # predicted values from column 2 of df1


library("data.table")

# using a data.table of the numeric vectors pre1 and obs1
df2 <- data.table(obs1, pre1)
vnse(df2[, 2, with = FALSE][[1]], df2[, 1, with = FALSE][[1]])

# df2[, 1, with = FALSE][[1]] # observed values from column 1 of df2
# df2[, 2, with = FALSE][[1]] # predicted values from column 2 of df2






ie2misc documentation built on Sept. 20, 2023, 9:08 a.m.