ErrorCrit: Error criterion using the provided function

Description Usage Arguments Value Author(s) See Also Examples

View source: R/ErrorCrit.R

Description

Function which computes an error criterion with the provided function.

Usage

1
ErrorCrit(InputsCrit, OutputsModel, FUN_CRIT, warnings = TRUE, verbose = TRUE)

Arguments

InputsCrit

[object of class InputsCrit] see CreateInputsCrit for details

OutputsModel

[object of class OutputsModel] see RunModel_GR4J or RunModel_CemaNeigeGR4J for details

FUN_CRIT

(deprecated) [function] error criterion function (e.g. ErrorCrit_RMSE, ErrorCrit_NSE)

warnings

(optional) [boolean] boolean indicating if the warning messages are shown, default = TRUE

verbose

(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = TRUE

Value

If InputsCrit is of class Single:

[list] containing the ErrorCrit_* functions outputs, see ErrorCrit_RMSE or ErrorCrit_NSE for details

If InputsCrit is of class Multi:

[list] of list containing the ErrorCrit_* functions outputs, see ErrorCrit_RMSE or ErrorCrit_NSE for details

If InputsCrit is of class Compo:

$CritValue [numeric] value of the composite criterion
$CritName [character] name of the composite criterion
$CritBestValue [numeric] theoretical best criterion value
$Multiplier [numeric] integer indicating whether the criterion is indeed an error (+1) or an efficiency (-1)
$CritCompo$MultiCritValues [numeric] values of the sub-criteria
$CritCompo$MultiCritNames [numeric] names of the sub-criteria
$CritCompo$MultiCritWeights [character] weighted values of the sub-criteria
$MultiCrit [list] of list containing the ErrorCrit_* functions outputs, see ErrorCrit_NSE or ErrorCrit_KGE for details

Author(s)

Olivier Delaigue

See Also

CreateInputsCrit, ErrorCrit_RMSE, ErrorCrit_NSE, ErrorCrit_KGE, ErrorCrit_KGE2

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
41
42
43
44
45
46
library(airGR)

## loading catchment data
data(L0123001)

## preparation of the InputsModel object
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, 
                                 Precip = BasinObs$P, PotEvap = BasinObs$E)

## calibration period selection
Ind_Run <- seq(which(format(BasinObs$DatesR, format = "%Y-%m-%d")=="1990-01-01"), 
               which(format(BasinObs$DatesR, format = "%Y-%m-%d")=="1999-12-31"))

## preparation of RunOptions object
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel, 
                               IndPeriod_Run = Ind_Run)

## simulation
Param <- c(X1 = 257.238, X2 = 1.012, X3 = 88.235, X4 = 2.208)
OutputsModel <- RunModel_GR4J(InputsModel = InputsModel,
                              RunOptions = RunOptions, Param = Param)

## single efficiency criterion: Nash-Sutcliffe Efficiency
InputsCritSingle <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE,
                                     InputsModel = InputsModel, RunOptions = RunOptions,
                                     Obs = list(BasinObs$Qmm[Ind_Run]),
                                     VarObs = "Q", transfo = "",
                                     Weights = NULL) 
str(ErrorCrit(InputsCrit = InputsCritSingle, OutputsModel = OutputsModel))

## 2 efficiency critera:  RMSE and the Nash-Sutcliffe Efficiency
InputsCritMulti <- CreateInputsCrit(FUN_CRIT = list(ErrorCrit_RMSE, ErrorCrit_NSE),
                                    InputsModel = InputsModel, RunOptions = RunOptions,
                                    Obs = list(BasinObs$Qmm[Ind_Run], BasinObs$Qmm[Ind_Run]),
                                    VarObs = list("Q", "Q"), transfo = list("", "sqrt"),
                                    Weights = NULL) 
str(ErrorCrit(InputsCrit = InputsCritMulti, OutputsModel = OutputsModel))

## efficiency composite criterion: Nash-Sutcliffe Efficiency mixing
##                                 both raw and log-transformed flows
InputsCritCompo <- CreateInputsCrit(FUN_CRIT = list(ErrorCrit_NSE, ErrorCrit_NSE),
                                    InputsModel = InputsModel, RunOptions = RunOptions,
                                    Obs = list(BasinObs$Qmm[Ind_Run], BasinObs$Qmm[Ind_Run]),
                                    VarObs = list("Q", "Q"), transfo = list("", "log"),
                                    Weights = list(0.4, 0.6)) 
str(ErrorCrit(InputsCrit = InputsCritCompo, OutputsModel = OutputsModel))

Example output

Warning message:
In CreateRunOptions(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel,  :
  model warm up period not defined: default configuration used
  the year preceding the run period is used 

Crit. NSE[Q] = 0.7988
List of 5
 $ CritValue      : num 0.799
 $ CritName       : chr "NSE[Q]"
 $ CritBestValue  : num 1
 $ Multiplier     : num -1
 $ Ind_notcomputed: int [1:57] 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 ...
 - attr(*, "class")= chr [1:2] "NSE" "ErrorCrit"
Crit. RMSE[Q] = 0.7864
Crit. NSE[sqrt(Q)] = 0.8478
List of 2
 $ IC1:List of 5
  ..$ CritValue      : num 0.786
  ..$ CritName       : chr "RMSE[Q]"
  ..$ CritBestValue  : num 1
  ..$ Multiplier     : num 1
  ..$ Ind_notcomputed: int [1:57] 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 ...
  ..- attr(*, "class")= chr [1:2] "RMSE" "ErrorCrit"
 $ IC2:List of 5
  ..$ CritValue      : num 0.848
  ..$ CritName       : chr "NSE[sqrt(Q)]"
  ..$ CritBestValue  : num 1
  ..$ Multiplier     : num -1
  ..$ Ind_notcomputed: int [1:57] 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 ...
  ..- attr(*, "class")= chr [1:2] "NSE" "ErrorCrit"
 - attr(*, "class")= chr [1:2] "Multi" "ErrorCrit"
Crit. NSE[Q] = 0.7988
Crit. NSE[log(Q)] = 0.8159
------------------------------------

Crit. Composite = 0.8091
	Formula: sum(0.40 * NSE[Q], 0.60 * NSE[log(Q)])

List of 7
 $ CritValue      : num 0.809
 $ CritName       : chr "Composite"
 $ CritBestValue  : num 1
 $ Multiplier     : num -1
 $ Ind_notcomputed: NULL
 $ CritCompo      :List of 3
  ..$ MultiCritValues : Named num [1:2] 0.799 0.816
  .. ..- attr(*, "names")= chr [1:2] "IC1" "IC2"
  ..$ MultiCritNames  : Named chr [1:2] "NSE[Q]" "NSE[log(Q)]"
  .. ..- attr(*, "names")= chr [1:2] "IC1" "IC2"
  ..$ MultiCritWeights: Named num [1:2] 0.4 0.6
  .. ..- attr(*, "names")= chr [1:2] "IC1" "IC2"
 $ MultiCrit      :List of 2
  ..$ IC1:List of 5
  .. ..$ CritValue      : num 0.799
  .. ..$ CritName       : chr "NSE[Q]"
  .. ..$ CritBestValue  : num 1
  .. ..$ Multiplier     : num -1
  .. ..$ Ind_notcomputed: int [1:57] 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 ...
  .. ..- attr(*, "class")= chr [1:2] "NSE" "ErrorCrit"
  ..$ IC2:List of 5
  .. ..$ CritValue      : num 0.816
  .. ..$ CritName       : chr "NSE[log(Q)]"
  .. ..$ CritBestValue  : num 1
  .. ..$ Multiplier     : num -1
  .. ..$ Ind_notcomputed: int [1:57] 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 ...
  .. ..- attr(*, "class")= chr [1:2] "NSE" "ErrorCrit"
 - attr(*, "class")= chr [1:2] "Compo" "ErrorCrit"

airGR documentation built on April 27, 2021, 9:07 a.m.