Compute the statistical bias of observed and predicted data.
Usage
bias(obs, pred, use = "everything")
Arguments
- obs
A numeric vector, data.frame or data.table with observed data.
- pred
A numeric vector, data.frame or data.table with predicted (model) data.
- use
An optional character string giving a method for computing RMSE
in the presence of missing values. This must be one of the strings
"everything" or "complete.obs".
Value
The statistical bias of input data as a numeric.
Details
The function computes the bias of two series with observed and predicted data,
according to the following definition:
$$
\mathrm{bias} = \frac{1}{N}\sum_{i=1}^{N} (P_{i} - O_{i})
$$
Examples
x <- runif(1:10) * 10
y <- runif(1:10) * 10
bias(x, y)
#> [1] -1.350351
if (FALSE) {
# validationData is a data.table with obs and mod columns with observed and model data:
validationData[, .(bias = bias(obs, mod, use = "complete.obs"))]
}