HFB | R Documentation |
High flow bias between sim
and obs
, with treatment of missing values.
This function is designed to identify differences in high values. See Details.
HFB(sim, obs, ...)
## Default S3 method:
HFB(sim, obs, na.rm=TRUE,
hQ.thr=0.1, start.month=1, out.PerYear=FALSE,
fun=NULL, ...,
epsilon.type=c("none", "Pushpalatha2012", "otherFactor", "otherValue"),
epsilon.value=NA)
## S3 method for class 'data.frame'
HFB(sim, obs, na.rm=TRUE,
hQ.thr=0.1, start.month=1, out.PerYear=FALSE,
fun=NULL, ...,
epsilon.type=c("none", "Pushpalatha2012", "otherFactor", "otherValue"),
epsilon.value=NA)
## S3 method for class 'matrix'
HFB(sim, obs, na.rm=TRUE,
hQ.thr=0.1, start.month=1, out.PerYear=FALSE,
fun=NULL, ...,
epsilon.type=c("none", "Pushpalatha2012", "otherFactor", "otherValue"),
epsilon.value=NA)
## S3 method for class 'zoo'
HFB(sim, obs, na.rm=TRUE,
hQ.thr=0.1, start.month=1, out.PerYear=FALSE,
fun=NULL, ...,
epsilon.type=c("none", "Pushpalatha2012", "otherFactor", "otherValue"),
epsilon.value=NA)
sim |
numeric, zoo, matrix or data.frame with simulated values |
obs |
numeric, zoo, matrix or data.frame with observed values |
na.rm |
a logical value indicating whether 'NA' should be stripped before the computation proceeds. |
hQ.thr |
numeric, representing the exceedence probabiliy used to identify high flows in |
start.month |
[OPTIONAL]. Only used when the (hydrological) year of interest is different from the calendar year. numeric in [1:12] indicating the starting month of the (hydrological) year. Numeric values in [1, 12] represent months in [January, December]. By default |
out.PerYear |
logical, indicating whether the output of this function has to include the median annual high-flows bias obtained for the individual years in |
fun |
function to be applied to The first argument MUST BE a numeric vector with any name (e.g., |
... |
arguments passed to |
epsilon.type |
argument used to define a numeric value to be added to both It is was designed to allow the use of logarithm and other similar functions that do not work with zero values. Valid values of 1) "none": 2) "Pushpalatha2012": one hundredth (1/100) of the mean observed values is added to both 3) "otherFactor": the numeric value defined in the 4) "otherValue": the numeric value defined in the |
epsilon.value |
-) when |
The median annual high flow bias (HFB) is designed to drive the calibration of hydrological models focused in the reproduction of high-flow events.
The high flow bias (HFB) ranges from 0 to Inf, with an optimal value of 0. Higher values of HFB indicate stronger differences between the high values of sim
and obs
. Essentially, the closer to 0, the more similar the high values of sim
and obs
are.
The HFB function is inspired in the annual peak-flow bias (APFB) objective function proposed by Mizukami et al. (2019). However, it has four important diferences:
1) instead of considering only the observed annual peak flow in each year, it considers all the high flows in each year, where "high flows" are all the values above a user-defined quantile of the observed values, by default 0.9 (hQ.thr=0.1
).
2) insted of considering only the simulated high flows for each year, which might occur in a date/time different from the date in which occurs the observed annual peak flow, it considers as many high simulated flows as the number of high observed flows for each year, each one in the exact same date/time in which the corresponding observed high flow occurred.
3) for each year, instead of using a single bias value (i.e., the bias in the single annual peak flow), it uses the median of all the bias in the user-defined high flows
4) when computing the final value of this metric, instead o using the mean of the annual values, it uses the median, in order to take a stronger representation of the bias when its distribution is not symetric.
If out.PerYear=FALSE
: numeric with the median high flow bias between sim
and obs
. If sim
and obs
are matrices, the output value is a vector, with the high flow bias between each column of sim
and obs
.
If out.PerYear=TRUE
: a list of two elements:
HFB.value |
numeric with the median annual high flow bias between |
HFB.PerYear |
-) If -) If |
obs
and sim
has to have the same length/dimension
The missing values in obs
and sim
are removed before the computation proceeds, and only those positions with non-missing values in obs
and sim
are considered in the computation
Mauricio Zambrano-Bigiarini <mzb.devel@gmail.com>
Mizukami, N.; Rakovec, O.; Newman, A.J.; Clark, M.P.; Wood, A.W.; Gupta, H.V.; Kumar, R.: (2019). On the choice of calibration metrics for "high-flow" estimation using hydrologic models, Hydrology Earth System Sciences 23, 2601-2614, doi:10.5194/hess-23-2601-2019.
APFB
, NSE
, wNSE
, , wsNSE
, gof
, ggof
##################
# Example 1: Looking at the difference between 'NSE', 'wNSE', and 'HFB'
# Loading daily streamflows of the Ega River (Spain), from 1961 to 1970
data(EgaEnEstellaQts)
obs <- EgaEnEstellaQts
# Simulated daily time series, created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values.
sim <- obs
hQ.thr <- quantile(obs, probs=0.9, na.rm=TRUE)
hQ.index <- which(obs >= hQ.thr)
hQ.n <- length(hQ.index)
sim[hQ.index] <- sim[hQ.index] + rnorm(hQ.n, mean=mean(sim[hQ.index], na.rm=TRUE))
# Traditional Nash-Sutcliffe eficiency
NSE(sim=sim, obs=obs)
# Weighted Nash-Sutcliffe efficiency (Hundecha and Bardossy, 2004)
wNSE(sim=sim, obs=obs)
# HFB (Garcia et al., 2017):
HFB(sim=sim, obs=obs)
##################
# Example 2:
# Loading daily streamflows of the Ega River (Spain), from 1961 to 1970
data(EgaEnEstellaQts)
obs <- EgaEnEstellaQts
# Generating a simulated daily time series, initially equal to the observed series
sim <- obs
# Computing the 'HFB' for the "best" (unattainable) case
HFB(sim=sim, obs=obs)
##################
# Example 3: HFB for simulated values created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values.
sim <- obs
hQ.thr <- quantile(obs, hQ.thr=0.9, na.rm=TRUE)
hQ.index <- which(obs >= hQ.thr)
hQ.n <- length(hQ.index)
sim[hQ.index] <- sim[hQ.index] + rnorm(hQ.n, mean=mean(sim[hQ.index], na.rm=TRUE))
ggof(sim, obs)
HFB(sim=sim, obs=obs)
##################
# Example 4: HFB for simulated values created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values and applying (natural)
# logarithm to 'sim' and 'obs' during computations.
HFB(sim=sim, obs=obs, fun=log)
# Verifying the previous value:
lsim <- log(sim)
lobs <- log(obs)
HFB(sim=lsim, obs=lobs)
##################
# Example 5: HFB for simulated values created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values and applying a
# user-defined function to 'sim' and 'obs' during computations
fun1 <- function(x) {sqrt(x+1)}
HFB(sim=sim, obs=obs, fun=fun1)
# Verifying the previous value, with the epsilon value following Pushpalatha2012
sim1 <- sqrt(sim+1)
obs1 <- sqrt(obs+1)
HFB(sim=sim1, obs=obs1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.