dr: Index of agreement (dr)

Description Usage Arguments Details Value Source References See Also Examples

Description

This function computes the "index of agreement (dr)".

Usage

1
dr(predicted, observed, na.rm = FALSE)

Arguments

predicted

numeric vector that contains the 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

dr is expressed as

d_{r} = 1 - \frac{∑ \limits_{i=1}^n{≤ft|P_i - O_i\right|}}{c ∑ \limits_{i=1}^n{≤ft|O_i - \bar{O}\right|}}, \: when \: ∑ \limits_{i=1}^n{≤ft|P_i - O_i\right|} ≤q c \: ∑ \limits_{i=1}^n{≤ft|O_i - \bar{O}\right|}

d_{r} = \frac{{c ∑ \limits_{i=1}^n{≤ft|O_i - \bar{O}\right|}}}{∑ \limits_{i=1}^n{≤ft|P_i - O_i\right|}} - 1, \: when \: ∑ \limits_{i=1}^n{≤ft|P_i - O_i\right|} > c \: ∑ \limits_{i=1}^n{≤ft|O_i - \bar{O}\right|}

d_r

the "index of agreement (dr)"

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.

The "index of agreement (dr)" is fully discussed in the Willmott reference.

Value

"index of agreement (dr)" 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 dr(pre, obs, na.rm = TRUE).

Source

r - Better error message for stopifnot? - Stack Overflow answered by Andrie on Dec 1 2011. See http://stackoverflow.com/questions/8343509/better-error-message-for-stopifnot.

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, http://onlinelibrary.wiley.com/doi/10.1002/joc.2419/pdf.

See Also

mape for mean absolute percent error (MAPE), mae for mean-absolute error (MAE), madstat for mean-absolute deviation (MAD), vnse for Nash-Sutcliffe model efficiency (NSE), and rmse for root mean square error (RMSE).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(ie2misc)
obs <- 1:10 # observed
pre <- 2:11 # predicted
dr(pre, obs)


require(stats)
set.seed(100) # makes the example reproducible
obs1 <- rnorm(100) # observed
pre1 <- rnorm(100) # predicted


# using the vectors pre1 and obs1
dr(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")))
dr(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)
dr(df1[, 2], df1[, 1])

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


# using a data.table of the numeric vectors pre1 and obs1
df2 <- data.table(obs1, pre1)
dr(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

iembry-USGS/ie2misc documentation built on May 18, 2019, 3:40 a.m.