Automatically calibrates the model with the help of a general-purpose optimisation function. In contrast to autoCalibrate, this method always utilises the overland and channel deposition rate at the same time and never the respective enrichment ratio for calibration. Beware of local optima and parameters approximately within the convergence tolerance of interval end-points.

# S4 method for RPhosFate
autoCalibrate2(
  x,
  substance,
  col,
  metric,
  method = "Nelder-Mead",
  lower = 0,
  upper = 0.1,
  control = list(fnscale = if (metric %in% c("NSE", "mNSE", "KGE")) -1 else 1)
)

Arguments

x

An S4 RPhosFate river catchment object.

substance

A character string specifying the substance to calculate.

col

A character string specifying the calibration data column with the respective substance river loads.

metric

A character string specifying the metric to optimise. See calibrationQuality for available metrics.

method

A character string specifying the utilised optimisation method. See optim for further information (use autoCalibrate instead of method "Brent").

lower

A numeric scalar or vector specifying the lower end-point(s) of the interval(s) to be searched.

upper

A numeric scalar or vector specifying the upper end-point(s) of the interval(s) to be searched.

control

A list of control parameters passed on to optim. See optim for further information.

Value

An S4 RPhosFate river catchment object and side effects in the form of raster files.

See also

Examples

# \donttest{
# temporary demonstration project copy
cv_dir <- demoProject()
#> Warning: A folder called "demoProject" already exists and is left as is.
# load temporary demonstration project
x <- RPhosFate(
  cv_dir = cv_dir,
  ls_ini = TRUE
)
# presupposed method calls
x <- firstRun(x, "SS")
x <- snapGauges(x)

x <- autoCalibrate2(
  x,
  "SS",
  col = "SS_load",
  metric = "NSE",
  method = "L-BFGS-B",
  lower = c(10e-4, 0),
  upper = c(20e-4, 20e-4),
  control = list(fnscale = -1, parscale = c(1e-3, 1e-3), factr = 1e12)
)# }
#> NSE:   0.7191828
#> mNSE:  0.5345233
#> KGE:   0.7323813
#> RMSE:  5.656556
#> PBIAS: -26.6
#> RSR:   0.4326794
#> RCV:   0.9761362
#> GMRAE: 0.3842057
#> MdRAE: 0.8072484
#> 
#> In-channel retention ratio: -2.220446e-16
#> 
#> NSE:   0.7191828
#> mNSE:  0.5345233
#> KGE:   0.7323813
#> RMSE:  5.656556
#> PBIAS: -26.6
#> RSR:   0.4326794
#> RCV:   0.9761362
#> GMRAE: 0.3842057
#> MdRAE: 0.8072484
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.7199797
#> mNSE:  0.5352918
#> KGE:   0.7328179
#> RMSE:  5.648524
#> PBIAS: -26.5
#> RSR:   0.432065
#> RCV:   0.9761435
#> GMRAE: 0.3835328
#> MdRAE: 0.8062524
#> 
#> In-channel retention ratio: -4.440892e-16
#> 

#> NSE:   0.7175585
#> mNSE:  0.5332522
#> KGE:   0.7316275
#> RMSE:  5.672891
#> PBIAS: -26.7
#> RSR:   0.4339289
#> RCV:   0.9758995
#> GMRAE: 0.3849626
#> MdRAE: 0.8095902
#> 
#> In-channel retention ratio: 0.001423444
#> 

#> NSE:   0.7191828
#> mNSE:  0.5345233
#> KGE:   0.7323813
#> RMSE:  5.656556
#> PBIAS: -26.6
#> RSR:   0.4326794
#> RCV:   0.9761362
#> GMRAE: 0.3842057
#> MdRAE: 0.8072484
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.6910678
#> mNSE:  0.4945718
#> KGE:   0.7090686
#> RMSE:  5.932966
#> PBIAS: 28.9
#> RSR:   0.4538224
#> RCV:   0.9680198
#> GMRAE: 0.3447724
#> MdRAE: 0.4399217
#> 
#> In-channel retention ratio: -6.661338e-16
#> 

#> NSE:   0.6931383
#> mNSE:  0.4965049
#> KGE:   0.7101685
#> RMSE:  5.91305
#> PBIAS: 28.7
#> RSR:   0.4522991
#> RCV:   0.9680672
#> GMRAE: 0.3428975
#> MdRAE: 0.4374743
#> 
#> In-channel retention ratio: 2.220446e-16
#> 

#> NSE:   0.6889864
#> mNSE:  0.4926358
#> KGE:   0.7079669
#> RMSE:  5.952919
#> PBIAS: 29
#> RSR:   0.4553487
#> RCV:   0.9679721
#> GMRAE: 0.3466493
#> MdRAE: 0.4423725
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.6932698
#> mNSE:  0.4967668
#> KGE:   0.7102748
#> RMSE:  5.911784
#> PBIAS: 28.7
#> RSR:   0.4522022
#> RCV:   0.9677696
#> GMRAE: 0.3435012
#> MdRAE: 0.4358586
#> 
#> In-channel retention ratio: 0.00140475
#> 

#> NSE:   0.6910678
#> mNSE:  0.4945718
#> KGE:   0.7090686
#> RMSE:  5.932966
#> PBIAS: 28.9
#> RSR:   0.4538224
#> RCV:   0.9680198
#> GMRAE: 0.3447724
#> MdRAE: 0.4399217
#> 
#> In-channel retention ratio: -6.661338e-16
#> 

#> NSE:   0.9575214
#> mNSE:  0.8027044
#> KGE:   0.9541649
#> RMSE:  2.200014
#> PBIAS: -3.4
#> RSR:   0.1682827
#> RCV:   0.9767316
#> GMRAE: 0.1806504
#> MdRAE: 0.2834657
#> 
#> In-channel retention ratio: 4.440892e-16
#> 

#> NSE:   0.957352
#> mNSE:  0.8025559
#> KGE:   0.9536547
#> RMSE:  2.204395
#> PBIAS: -3.5
#> RSR:   0.1686178
#> RCV:   0.9767387
#> GMRAE: 0.1807294
#> MdRAE: 0.2849978
#> 
#> In-channel retention ratio: 3.330669e-16
#> 

#> NSE:   0.9576878
#> mNSE:  0.8028532
#> KGE:   0.9546712
#> RMSE:  2.1957
#> PBIAS: -3.4
#> RSR:   0.1679527
#> RCV:   0.9767245
#> GMRAE: 0.1805653
#> MdRAE: 0.2819319
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.95699
#> mNSE:  0.8018995
#> KGE:   0.9532673
#> RMSE:  2.213733
#> PBIAS: -3.5
#> RSR:   0.1693321
#> RCV:   0.9764926
#> GMRAE: 0.1809222
#> MdRAE: 0.2865275
#> 
#> In-channel retention ratio: 0.001411654
#> 

#> NSE:   0.9575214
#> mNSE:  0.8027044
#> KGE:   0.9541649
#> RMSE:  2.200014
#> PBIAS: -3.4
#> RSR:   0.1682827
#> RCV:   0.9767316
#> GMRAE: 0.1806504
#> MdRAE: 0.2834657
#> 
#> In-channel retention ratio: 4.440892e-16
#> 

#> NSE:   0.9552136
#> mNSE:  0.8208966
#> KGE:   0.9431924
#> RMSE:  2.258985
#> PBIAS: 4.8
#> RSR:   0.1727935
#> RCV:   0.9755208
#> GMRAE: 0.129613
#> MdRAE: 0.09851233
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.9554464
#> mNSE:  0.8207224
#> KGE:   0.9438469
#> RMSE:  2.253107
#> PBIAS: 4.7
#> RSR:   0.1723439
#> RCV:   0.9755355
#> GMRAE: 0.1305188
#> MdRAE: 0.1002579
#> 
#> In-channel retention ratio: 1.110223e-16
#> 

#> NSE:   0.9549765
#> mNSE:  0.8210711
#> KGE:   0.9425341
#> RMSE:  2.264957
#> PBIAS: 4.8
#> RSR:   0.1732503
#> RCV:   0.975506
#> GMRAE: 0.1286952
#> MdRAE: 0.09676464
#> 
#> In-channel retention ratio: -4.440892e-16
#> 

#> NSE:   0.9552449
#> mNSE:  0.8200235
#> KGE:   0.9438915
#> RMSE:  2.258194
#> PBIAS: 4.7
#> RSR:   0.172733
#> RCV:   0.9752798
#> GMRAE: 0.1308988
#> MdRAE: 0.1018289
#> 
#> In-channel retention ratio: 0.001408951
#> 

#> NSE:   0.9552136
#> mNSE:  0.8208966
#> KGE:   0.9431924
#> RMSE:  2.258985
#> PBIAS: 4.8
#> RSR:   0.1727935
#> RCV:   0.9755208
#> GMRAE: 0.129613
#> MdRAE: 0.09851233
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.962066
#> mNSE:  0.8106337
#> KGE:   0.969484
#> RMSE:  2.079
#> PBIAS: 0.2
#> RSR:   0.1590262
#> RCV:   0.9762867
#> GMRAE: 0.1683249
#> MdRAE: 0.2021909
#> 
#> In-channel retention ratio: 0
#> 

#> NSE:   0.9620605
#> mNSE:  0.8104743
#> KGE:   0.9695189
#> RMSE:  2.079151
#> PBIAS: 0.1
#> RSR:   0.1590377
#> RCV:   0.9762969
#> GMRAE: 0.1687208
#> MdRAE: 0.2038152
#> 
#> In-channel retention ratio: 0
#> 

#> NSE:   0.962068
#> mNSE:  0.8107934
#> KGE:   0.969432
#> RMSE:  2.078945
#> PBIAS: 0.2
#> RSR:   0.159022
#> RCV:   0.9762764
#> GMRAE: 0.1679225
#> MdRAE: 0.2005647
#> 
#> In-channel retention ratio: 1.110223e-16
#> 

#> NSE:   0.9617705
#> mNSE:  0.8097989
#> KGE:   0.9692383
#> RMSE:  2.087083
#> PBIAS: 0.1
#> RSR:   0.1596444
#> RCV:   0.9760469
#> GMRAE: 0.1689422
#> MdRAE: 0.2053646
#> 
#> In-channel retention ratio: 0.001410382
#> 

#> NSE:   0.962066
#> mNSE:  0.8106337
#> KGE:   0.969484
#> RMSE:  2.079
#> PBIAS: 0.2
#> RSR:   0.1590262
#> RCV:   0.9762867
#> GMRAE: 0.1683249
#> MdRAE: 0.2021909
#> 
#> In-channel retention ratio: 0
#> 

#> NSE:   0.962068
#> mNSE:  0.8108216
#> KGE:   0.969421
#> RMSE:  2.078945
#> PBIAS: 0.2
#> RSR:   0.159022
#> RCV:   0.9762746
#> GMRAE: 0.1678508
#> MdRAE: 0.2002773
#> 
#> In-channel retention ratio: -4.440892e-16
#> 

#> NSE:   0.9620666
#> mNSE:  0.8106619
#> KGE:   0.9694761
#> RMSE:  2.078983
#> PBIAS: 0.2
#> RSR:   0.1590249
#> RCV:   0.9762849
#> GMRAE: 0.1682543
#> MdRAE: 0.2019038
#> 
#> In-channel retention ratio: -2.220446e-16
#> 

#> NSE:   0.9620659
#> mNSE:  0.8109816
#> KGE:   0.969349
#> RMSE:  2.079003
#> PBIAS: 0.3
#> RSR:   0.1590264
#> RCV:   0.9762642
#> GMRAE: 0.1674407
#> MdRAE: 0.1986489
#> 
#> In-channel retention ratio: 4.440892e-16
#> 

#> NSE:   0.9617783
#> mNSE:  0.809986
#> KGE:   0.9692028
#> RMSE:  2.08687
#> PBIAS: 0.1
#> RSR:   0.1596282
#> RCV:   0.9760347
#> GMRAE: 0.1684769
#> MdRAE: 0.2034537
#> 
#> In-channel retention ratio: 0.001410353
#> 

#> NSE:   0.962068
#> mNSE:  0.8108216
#> KGE:   0.969421
#> RMSE:  2.078945
#> PBIAS: 0.2
#> RSR:   0.159022
#> RCV:   0.9762746
#> GMRAE: 0.1678508
#> MdRAE: 0.2002773
#> 
#> In-channel retention ratio: -4.440892e-16
#> 

#> $par
#> [1] 0.001523864 0.000000000
#> 
#> $value
#> [1] 0.962068
#> 
#> $counts
#> function gradient 
#>        6        6 
#> 
#> $convergence
#> [1] 0
#> 
#> $message
#> [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"
#>