From 2f9d46b395eb3d15998065ccb6b540d1e4e0d027 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.fr>
Date: Thu, 25 Mar 2021 09:04:11 +0100
Subject: [PATCH] docs(vignette): fix the starting points used for the
 multi-start approach in the param_optim vignette - replace real space by
 transformed space Refs #101

---
 vignettes/V02.1_param_optim.Rmd | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/vignettes/V02.1_param_optim.Rmd b/vignettes/V02.1_param_optim.Rmd
index 2dd121e9..e8aa8a00 100644
--- a/vignettes/V02.1_param_optim.Rmd
+++ b/vignettes/V02.1_param_optim.Rmd
@@ -78,6 +78,7 @@ OptimGR4J <- function(ParamOptim) {
 
 
 In addition, we need to define the lower and upper bounds of the four **GR4J** parameters in the transformed parameter space:
+
 ```{r, warning=FALSE, results='hide', eval=FALSE}
 lowerGR4J <- rep(-9.99, times = 4)
 upperGR4J <- rep(+9.99, times = 4)
@@ -86,6 +87,7 @@ upperGR4J <- rep(+9.99, times = 4)
 # Local optimization
 
 We start with a local optimization strategy by using the PORT routines (using the `nlminb()` of the `stats` package) and by setting a starting point in the transformed parameter space:
+
 ```{r, warning=FALSE, results='hide', eval=FALSE}
 startGR4J <- c(4.1, 3.9, -0.9, -8.7)
 optPORT <- stats::nlminb(start = startGR4J,
@@ -93,13 +95,17 @@ optPORT <- stats::nlminb(start = startGR4J,
                          lower = lowerGR4J, upper = upperGR4J,
                          control = list(trace = 1))
 ```
+
 The RMSE value reaches a local minimum value after 35 iterations.
 
 We can also try a multi-start approach to test the consistency of the local optimization.
 Here we use the same grid used for the filtering step of the Michel's calibration strategy (`Calibration_Michel()` function).
 For each starting point, a local optimization is performed.
+
 ```{r, warning=FALSE, results='hide', eval=FALSE}
-startGR4J <- expand.grid(data.frame(CalibOptions$StartParamDistrib))
+StarttGR4JDistrib <- TransfoParam_GR4J(ParamIn = CalibOptions$StartParamDistrib,
+                                       Direction = "RT")
+startGR4J <- expand.grid(data.frame(StarttGR4JDistrib))
 optPORT_ <- function(x) {
   opt <- stats::nlminb(start = x,
                        objective = OptimGR4J,
@@ -110,6 +116,7 @@ listOptPORT <- apply(startGR4J, MARGIN = 1, FUN = optPORT_)
 ```
 
 We can then extract the best parameter sets and the value of the performance criteria:
+
 ```{r, warning=FALSE, results='hide', eval=FALSE}
 parPORT <- t(sapply(listOptPORT, function(x) x$par))
 objPORT <- sapply(listOptPORT, function(x) x$objective)
@@ -117,6 +124,7 @@ resPORT <- data.frame(parPORT, RMSE = objPORT)
 ```
 
 As can be seen below, the optimum performance criterion values (column *objective*) can differ from the global optimum value in many cases, resulting in various parameter sets.
+
 ```{r, warning=FALSE}
 summary(resPORT)
 ```
-- 
GitLab