Bias: Compute the Mean Bias

View source: R/Bias.R

BiasR Documentation

Compute the Mean Bias

Description

The Mean Bias or Mean Error (Wilks, 2011) is defined as the mean difference between the ensemble mean forecast and the observations. It is a deterministic metric. Positive values indicate that the forecasts are on average too high and negative values indicate that the forecasts are on average too low. It also allows to compute the Absolute Mean Bias or bias without temporal mean. If there is more than one dataset, the result will be computed for each pair of exp and obs data.

Usage

Bias(
  exp,
  obs,
  time_dim = "sdate",
  memb_dim = NULL,
  dat_dim = NULL,
  na.rm = FALSE,
  absolute = FALSE,
  time_mean = TRUE,
  alpha = 0.05,
  ncores = NULL
)

Arguments

exp

A named numerical array of the forecast with at least time dimension.

obs

A named numerical array of the observation with at least time dimension. The dimensions must be the same as 'exp' except 'memb_dim' and 'dat_dim'.

time_dim

A character string indicating the name of the time dimension. The default value is 'sdate'.

memb_dim

A character string indicating the name of the member dimension to compute the ensemble mean; it should be set to NULL if the parameter 'exp' is already the ensemble mean. The default value is NULL.

dat_dim

A character string indicating the name of dataset dimension. The length of this dimension can be different between 'exp' and 'obs'. The default value is NULL.

na.rm

A logical value indicating if NAs should be removed (TRUE) or kept (FALSE) for computation. The default value is FALSE.

absolute

A logical value indicating whether to compute the absolute bias. The default value is FALSE.

time_mean

A logical value indicating whether to compute the temporal mean of the bias. The default value is TRUE.

alpha

A numeric or NULL (default) to indicate the significance level using Welch's t-test. Only available when absolute is FALSE.

ncores

An integer indicating the number of cores to use for parallel computation. The default value is NULL.

Value

A numerical array of bias with dimensions c(nexp, nobs, the rest dimensions of 'exp' except 'time_dim' (if time_mean = T) and 'memb_dim'). nexp is the number of experiment (i.e., 'dat_dim' in exp), and nobs is the number of observation (i.e., 'dat_dim' in obs). If dat_dim is NULL, nexp and nobs are omitted. If alpha is specified, and absolute is FALSE, the result is a list with two elements: the bias as described above and the significance as a logical array with the same dimensions.

References

Wilks, 2011; https://doi.org/10.1016/B978-0-12-385022-5.00008-7

Examples

exp <- array(rnorm(1000), dim = c(dat = 1, lat = 3, lon = 5, member = 10, sdate = 50))
obs <- array(rnorm(1000), dim = c(dat = 1, lat = 3, lon = 5, sdate = 50))
bias <- Bias(exp = exp, obs = obs, memb_dim = 'member')
bias2 <- Bias(exp = exp, obs = obs, memb_dim = 'member', alpha = 0.01)
abs_bias <- Bias(exp = exp, obs = obs, memb_dim = 'member', absolute = TRUE, alpha = NULL)


s2dv documentation built on Oct. 13, 2024, 9:07 a.m.