From 004fce2520d6889d82226e21bc443426e81d93f2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 17 Apr 2023 19:39:09 +0200 Subject: Improve docs of multistart method --- vignettes/web_only/multistart.html | 52 ++++++++++++++++---------------------- vignettes/web_only/multistart.rmd | 31 ++++++++++------------- 2 files changed, 36 insertions(+), 47 deletions(-) (limited to 'vignettes') diff --git a/vignettes/web_only/multistart.html b/vignettes/web_only/multistart.html index 5568ad2c..93f08ca3 100644 --- a/vignettes/web_only/multistart.html +++ b/vignettes/web_only/multistart.html @@ -299,8 +299,8 @@ pre code { border-radius: 4px; } -.tabset-dropdown > .nav-tabs > li.active:before { - content: ""; +.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before { + content: "\e259"; font-family: 'Glyphicons Halflings'; display: inline-block; padding: 10px; @@ -308,16 +308,9 @@ pre code { } .tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before { - content: ""; - border: none; -} - -.tabset-dropdown > .nav-tabs.nav-tabs-open:before { - content: ""; + content: "\e258"; font-family: 'Glyphicons Halflings'; - display: inline-block; - padding: 10px; - border-right: 1px solid #ddd; + border: none; } .tabset-dropdown > .nav-tabs > li.active { @@ -364,7 +357,7 @@ pre code {

Short demo of the multistart method

Johannes Ranke

-

Last change 26 September 2022 (rebuilt 2022-10-26)

+

Last change 17 April 2023 (rebuilt 2023-04-17)

@@ -386,31 +379,30 @@ f_saem_full <- saem(f_mmkin) illparms(f_saem_full)
## [1] "sd(log_k2)"

We see that not all variability parameters are identifiable. The illparms function tells us that the confidence interval for the standard deviation of ‘log_k2’ includes zero. We check this assessment using multiple runs with different starting values.

-
f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 16)
-parhist(f_saem_full_multi)
-

+
f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 8)
+parplot(f_saem_full_multi, lpos = "topleft")
+

This confirms that the variance of k2 is the most problematic parameter, so we reduce the parameter distribution model by removing the intersoil variability for k2.

f_saem_reduced <- update(f_saem_full, no_random_effect = "log_k2")
-illparms(f_saem_reduced)
-
## character(0)
-
f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cores = 16)
-parhist(f_saem_reduced_multi, lpos = "topright")
-

+illparms(f_saem_reduced) +f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cores = 8) +parplot(f_saem_reduced_multi, lpos = "topright", ylim = c(0.5, 2)) +

The results confirm that all remaining parameters can be determined with sufficient certainty.

We can also analyse the log-likelihoods obtained in the multiple runs:

llhist(f_saem_reduced_multi)
-

-

The parameter histograms can be further improved by excluding the result with the low likelihood.

-
parhist(f_saem_reduced_multi, lpos = "topright", llmin = -326, ylim = c(0.5, 2))
-

-

We can use the anova method to compare the models, including a likelihood ratio test if the models are nested.

-
anova(f_saem_full, best(f_saem_reduced_multi), test = TRUE)
+

+

We can use the anova method to compare the models.

+
anova(f_saem_full, best(f_saem_full_multi),
+  f_saem_reduced, best(f_saem_reduced_multi), test = TRUE)
## Data: 155 observations of 1 variable(s) grouped in 6 datasets
 ## 
-##                            npar    AIC    BIC     Lik Chisq Df Pr(>Chisq)
-## best(f_saem_reduced_multi)    9 663.81 661.93 -322.90                    
-## f_saem_full                  10 668.27 666.19 -324.13     0  1          1
-

While AIC and BIC are lower for the reduced model, the likelihood ratio test does not indicate a significant difference between the fits.

+## npar AIC BIC Lik Chisq Df Pr(>Chisq) +## f_saem_reduced 9 663.74 661.87 -322.87 +## best(f_saem_reduced_multi) 9 663.60 661.72 -322.80 0.1476 0 +## f_saem_full 10 670.35 668.26 -325.17 0.0000 1 1 +## best(f_saem_full_multi) 10 665.61 663.53 -322.80 4.7372 0 +

The reduced model results in lower AIC and BIC values, so it is clearly preferable. Using multiple starting values gives a large improvement in case of the full model, because it is less well-defined, which impedes convergence. For the reduced model, using multiple starting values only results in a small improvement of the model fit.

diff --git a/vignettes/web_only/multistart.rmd b/vignettes/web_only/multistart.rmd index 27a8a96a..ccf26b3d 100644 --- a/vignettes/web_only/multistart.rmd +++ b/vignettes/web_only/multistart.rmd @@ -1,7 +1,7 @@ --- title: Short demo of the multistart method author: Johannes Ranke -date: Last change 26 September 2022 (rebuilt `r Sys.Date()`) +date: Last change 17 April 2023 (rebuilt `r Sys.Date()`) output: html_document vignette: > @@ -39,8 +39,8 @@ of 'log_k2' includes zero. We check this assessment using multiple runs with different starting values. ```{r} -f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 16) -parplot(f_saem_full_multi) +f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 8) +parplot(f_saem_full_multi, lpos = "topleft") ``` This confirms that the variance of k2 is the most problematic parameter, so we @@ -50,8 +50,8 @@ for k2. ```{r} f_saem_reduced <- update(f_saem_full, no_random_effect = "log_k2") illparms(f_saem_reduced) -f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cores = 16) -parplot(f_saem_reduced_multi, lpos = "topright") +f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cores = 8) +parplot(f_saem_reduced_multi, lpos = "topright", ylim = c(0.5, 2)) ``` The results confirm that all remaining parameters can be determined with sufficient @@ -63,20 +63,17 @@ We can also analyse the log-likelihoods obtained in the multiple runs: llhist(f_saem_reduced_multi) ``` -The parameter histograms can be further improved by excluding the result with -the low likelihood. +We can use the `anova` method to compare the models. ```{r} -parplot(f_saem_reduced_multi, lpos = "topright", llmin = -326, ylim = c(0.5, 2)) +anova(f_saem_full, best(f_saem_full_multi), + f_saem_reduced, best(f_saem_reduced_multi), test = TRUE) ``` -We can use the `anova` method to compare the models, including a likelihood ratio -test if the models are nested. - -```{r} -anova(f_saem_full, best(f_saem_reduced_multi), test = TRUE) -``` - -While AIC and BIC are lower for the reduced model, the likelihood ratio test -does not indicate a significant difference between the fits. +The reduced model results in lower AIC and BIC values, so it +is clearly preferable. Using multiple starting values gives +a large improvement in case of the full model, because it is +less well-defined, which impedes convergence. For the reduced +model, using multiple starting values only results in a small +improvement of the model fit. -- cgit v1.2.1