# Generalist parameter sets for the GR4J model

#### Olivier Delaigue, Guillaume Thirel

# Introduction

## Scope

In the airGR package, the classical way to calibrate a model is to use the Michel’s algorithm (see the `Calibration_Michel()` function).

The Michel’s algorithm combines a global and a local approach. A screening is first performed either based on a rough predefined grid (considering various initial values for each parameter) or from a list of initial parameter sets. The best set identified in this screening is then used as a starting point for the steepest descent local search algorithm.

In some specific situations, for example if the calibration period is too short and by consequence non representative of the catchment behaviour, a local calibration algorithm can give poor results.

In this vignette, we show a method using a known parameter set that can be used as an alternative for the grid-screening calibration procedure, and we well compare to two methods using the `Calibration_Michel()` function. The generalist parameters sets introduced here are taken from Andréassian et al. (2014).

## Data preparation

We load an example data set from the package and the GR4J parameter sets.

    ## loading catchment data
    data(L0123001)

    ## loading generalist parameter sets
    data(Param_Sets_GR4J)

The given GR4J X4u variable does not correspond to the actual GR4J X4 parameter. As explained in Andréassian et al. (2014, sec. 2.1), the given GR4J X4u value has to be adjusted (rescaled) using catchment area (S) [km2] as follows: `X4 = X4u / 5.995 * S^0.3` (please= note that the formula is erroneous in the publication).

It means we need first to transform the X4 parameter.

    Param_Sets_GR4J$X4 <- Param_Sets_GR4J$X4u / 5.995 * BasinInfo$BasinArea^0.3
    Param_Sets_GR4J$X4u <- NULL
    Param_Sets_GR4J <- as.matrix(Param_Sets_GR4J)

Please, find below the summary of the 27 sets of the 4 parameters.

    ##        X1             X2              X3            X4
    ##  Min.   : 126   Min.   :-54.5   Min.   :  8   Min.   :1.21
    ##  1st Qu.: 208   1st Qu.: -2.0   1st Qu.: 35   1st Qu.:1.75
    ##  Median : 291   Median : -1.1   Median : 76   Median :2.10
    ##  Mean   : 471   Mean   : -3.4   Mean   : 90   Mean   :2.09
    ##  3rd Qu.: 359   3rd Qu.: -0.6   3rd Qu.:106   3rd Qu.:2.45
    ##  Max.   :4006   Max.   :  0.8   Max.   :318   Max.   :3.47

## Object model preparation

We assume that the R global environment contains data and functions from the Get Started vignette.

The calibration period has been defined from 1990-01-01 to 1990-02-28, and the validation period from 1990-03-01 to 1999-12-31.

As a consequence, in this example the calibration period is very short, less than 6 months.

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

    ## ---- calibration step

    ## short calibration period selection (< 6 months)
    Ind_Cal <- seq(which(format(BasinObs$DatesR, format = "%d/%m/%Y %H:%M")=="01/01/1990 00:00"),
                   which(format(BasinObs$DatesR, format = "%d/%m/%Y %H:%M")=="28/02/1990 00:00"))

    ## preparation of the RunOptions object for the calibration period
    RunOptions_Cal <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
                                       InputsModel = InputsModel, IndPeriod_Run = Ind_Cal)

    ## efficiency criterion: Nash-Sutcliffe Efficiency
    InputsCrit_Cal  <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
                                        RunOptions = RunOptions_Cal, Obs = BasinObs$Qmm[Ind_Cal])

    ## ---- validation step

    ## validation period selection
    Ind_Val <- seq(which(format(BasinObs$DatesR, format = "%d/%m/%Y %H:%M")=="01/03/1990 00:00"),
                   which(format(BasinObs$DatesR, format = "%d/%m/%Y %H:%M")=="31/12/1999 00:00"))

    ## preparation of the RunOptions object for the validation period
    RunOptions_Val <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
                                       InputsModel = InputsModel, IndPeriod_Run = Ind_Val)

    ## efficiency criterion (Nash-Sutcliffe Efficiency) on the validation period
    InputsCrit_Val  <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
                                        RunOptions = RunOptions_Val, Obs = BasinObs$Qmm[Ind_Val])

# Calibration of the GR4J model with the generalist parameter sets

It is recommended to use the generalist parameter sets when the calibration period is less than 6 months.

As shown in Andréassian et al. (2014, fig. 4), a recommended way to use the `Param_Sets_GR4J` `data.frame` is to run the GR4J model with each parameter set and to select the best one according to an objective function (here we use the Nash-Sutcliffe Efficiency criterion).

    OutputsCrit_Loop <- apply(Param_Sets_GR4J, 1, function(iParam) {
      OutputsModel_Cal <- RunModel_GR4J(InputsModel = InputsModel, RunOptions = RunOptions_Cal,
                                        Param = iParam)
      OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit_Cal, OutputsModel = OutputsModel_Cal)
      return(OutputsCrit$CritValue)
    })

Find below the 27 criteria corresponding to the different parameter sets.

The criterion values are quite low (from -1.639 to 0.336), which can be expected as this does not represents an actual calibration.

    ##  [1]  0.0573  0.1331 -0.0168  0.1613  0.0345  0.1046 -0.0458  0.3359  0.2440
    ## [10] -0.3858 -0.0830 -1.0930  0.2843  0.2792  0.1505 -0.0209 -0.0825  0.1298
    ## [19]  0.2903 -0.1188 -0.3834 -0.0836  0.0279 -0.0488 -0.1675  0.1719 -1.6386

The parameter set corresponding to the best criterion is the following:

    ##     X1     X2     X3     X4
    ## 291.00   0.30 109.10   2.01

Now we can compute the Nash-Sutcliffe Efficiency criterion on the validation period. A quite good value (0.777) is found.

# Calibration of the GR4J model with the built-in Calibration_Michel function

As seen above, the Michel’s calibration algorithm is based on a local search procedure.

It is not recommanded to use the `Calibration_Michel()` function when the calibration period is less than 6 month. We will show below its application on the same short period for two configurations of the grid-screening step to demonstrate that it is less efficient than the generalist parameters sets calibration.

## GR4J parameter distributions quantiles used in the grid-screening step

By default, the predefined grid used by the `Calibration_Michel()` function contains parameters quantiles computed after recursive calibrations on 1200 basins (from Australia, France and USA).

    CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibration_Michel)

The parameter set corresponding to the best criterion is the following:

    ##     X1     X2     X3     X4
    ## 165.05   6.46 422.50   2.45

The Nash-Sutcliffe Efficiency criterion computed on the calibration period is better (0.495) than with the generalist parameter sets, but the one computed on the validation period is lower (0.57). This shows that the generalist parameter sets give more robust model in this case.

## GR4J parameter sets used in the grid-screening step

It is also possible to give to the `CreateCalibOptions()` function a matrix of parameter sets used for the grid-screening calibration procedure. So, it possible is to use by this way the GR4J generalist parameter sets.

    CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibration_Michel,
                                       StartParamList = Param_Sets_GR4J)

Here is the parameter set corresponding to the best criteria found.

    ##     X1     X2     X3     X4
    ## 161.62   6.53 429.00   2.45

The results are the same here. The Nash-Sutcliffe Efficiency criterion computed on the calibration period is better (0.495), but the one computed on the validation period is just a little bit lower (0.568) than the classical calibration.

Generally, the advantage of using GR4J parameter sets rather than the GR4J generalist parameter quantiles is that they make more sense than a simple exploration of combinations of quantiles of parameter distributions (each parameter set represents a consistent ensemble). In addition, for the first step, the number of iterations is smaller (27 runs instead of 81), which can save time if one wants to run a very large number of calibrations.

# References

Andréassian, Vazken, François Bourgin, Ludovic Oudin, Thibault Mathevet, Charles Perrin, Julien Lerat, Laurent Coron, and Lionel Berthet. 2014. “Seeking Genericity in the Selection of Parameter Sets: Impact on Hydrological Model Efficiency.” Water Resources Research 50 (10): 8356–66. https://doi.org/10.1002/2013WR014761.