objFunVal {hydromad}R Documentation

Calculate objective function value for a fitted model.


Calculate objective function value for a fitted model.


objFunVal(x, objective, ...)

## S3 method for class 'hydromad'
objFunVal(x, objective = hydromad.getOption("objective"),
          ..., all = FALSE, nan.ok = FALSE)

## Default S3 method:
objFunVal(x, objective = hydromad.getOption("objective"),
          ..., nan.ok = FALSE)



object from which to calculate stats. For the hydromad method, this should be a fitted hydromad model object, i.e. it must have specific parameter values, not ranges. For the default method, this should be a matrix-like object with named columns Q, X and optionally U and P.


the objective function, or a list of objective functions. See Details.




passed to fitted and observed.


by default, an error is thrown if the result is NaN. Set this argument to TRUE to suppress the error.


The objective function is given as a function with arguments Q, X and ..., and optionally other arguments. Q and X represent observed and modelled flow, respectively. It should return a single numeric value.

For more advanced use it may also refer to arguments U (modelled effective rainfall), or P (observed rainfall), and more generally it may refer to model, and so may extract other items of data, parameters, etc.

The default (unless changed in hydromad.options("objective")) is a weighted sum of the R Squared (coefficient of determination) of square-root transformed data, and the relative bias.

See hydromad.stats for examples of how to specify other fit statistics.


the objective function value, or a list of objective function values. They must be numeric and of length one; anything else is an error.


Felix Andrews felix@nfrac.org

See Also

hydromad.stats, hydromad.object


dat <- data.frame(Q = rnorm(10), X = rnorm(10))
objFunVal(dat, hmadstat("RMSE"))
[Package hydromad version 0.9-18 Index]