From e7751e791f46b2aa334f52109e0bd8211dfd7083 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 11 Jan 2022 19:28:22 +0100 Subject: Update the dimethenamid vignette with current saemix Convergence is faster with this version (@ecomets mentioned that there was a bugfix lately that could lead to faster convergence). However, if I use too many iterations (i.e. 10 000 as in the last version of this vignette), I get an error in solving omega.teta during later iterations, apparently due to overparameterisation of the DFOP model in this case. --- vignettes/web_only/dimethenamid_2018.html | 259 ++++++++++----------- vignettes/web_only/dimethenamid_2018.rmd | 56 ++--- .../f_parent_nlmixr_saem_dfop_const-1.png | Bin 96984 -> 94264 bytes .../figure-html/f_parent_nlmixr_saem_dfop_tc-1.png | Bin 83994 -> 82238 bytes .../f_parent_nlmixr_saem_dfop_tc_10k-1.png | Bin 82918 -> 81793 bytes .../f_parent_nlmixr_saem_dfop_tc_1k-1.png | Bin 81506 -> 77251 bytes .../f_parent_nlmixr_saem_sfo_const-1.png | Bin 74354 -> 71898 bytes .../figure-html/f_parent_nlmixr_saem_sfo_tc-1.png | Bin 76153 -> 77093 bytes .../figure-html/f_parent_saemix_dfop_const-1.png | Bin 38179 -> 36337 bytes .../figure-html/f_parent_saemix_dfop_tc-1.png | Bin 30583 -> 29299 bytes .../figure-html/f_parent_saemix_dfop_tc_mkin-1.png | Bin 32242 -> 31578 bytes .../f_parent_saemix_dfop_tc_mkin_moreiter-1.png | Bin 0 -> 32137 bytes .../figure-html/f_parent_saemix_sfo_const-1.png | Bin 34645 -> 32949 bytes .../figure-html/f_parent_saemix_sfo_tc-1.png | Bin 28683 -> 28655 bytes 14 files changed, 153 insertions(+), 162 deletions(-) create mode 100644 vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin_moreiter-1.png diff --git a/vignettes/web_only/dimethenamid_2018.html b/vignettes/web_only/dimethenamid_2018.html index 95e41c71..cadbcdbf 100644 --- a/vignettes/web_only/dimethenamid_2018.html +++ b/vignettes/web_only/dimethenamid_2018.html @@ -1591,7 +1591,7 @@ div.tocify {

Example evaluations of the dimethenamid data from 2018

Johannes Ranke

-

Last change 27 September 2021, built on 27 Sep 2021

+

Last change 11 January 2022, built on 11 Jan 2022

@@ -1685,66 +1685,70 @@ anova(f_parent_nlme_dfop_tc, f_parent_nlme_dfop_tc_logchol)
library(saemix)
 saemix_control <- saemixControl(nbiter.saemix = c(800, 300), nb.chains = 15,
     print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
-saemix_control_10k <- saemixControl(nbiter.saemix = c(10000, 1000), nb.chains = 15,
+saemix_control_moreiter <- saemixControl(nbiter.saemix = c(1600, 300), nb.chains = 15,
     print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)

The convergence plot for the SFO model using constant variance is shown below.

f_parent_saemix_sfo_const <- mkin::saem(f_parent_mkin_const["SFO", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_sfo_const$so, plot.type = "convergence")
-

+

Obviously the default number of iterations is sufficient to reach convergence. This can also be said for the SFO fit using the two-component error model.

f_parent_saemix_sfo_tc <- mkin::saem(f_parent_mkin_tc["SFO", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_sfo_tc$so, plot.type = "convergence")
-

+

When fitting the DFOP model with constant variance (see below), parameter convergence is not as unambiguous.

f_parent_saemix_dfop_const <- mkin::saem(f_parent_mkin_const["DFOP", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_dfop_const$so, plot.type = "convergence")
-

+

This is improved when the DFOP model is fitted with the two-component error model. Convergence of the variance of k2 is enhanced, it remains more or less stable already after 200 iterations of the first phase.

f_parent_saemix_dfop_tc <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_dfop_tc$so, plot.type = "convergence")
-

-

We also check if using many more iterations (10 000 for the first and 1000 for the second phase) improve the result in a significant way. The AIC values obtained are compared further below.

-
f_parent_saemix_dfop_tc_10k <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
-  control = saemix_control_10k, transformations = "saemix")
-plot(f_parent_saemix_dfop_tc_10k$so, plot.type = "convergence")
-

+

+
# The last time I tried (2022-01-11) this gives an error in solve.default(omega.eta)
+# system is computationally singular: reciprocal condition number = 5e-17
+#f_parent_saemix_dfop_tc_10k <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
+#  control = saemix_control_10k, transformations = "saemix")
+# Now we do not get a significant improvement by using twice the number of iterations
+f_parent_saemix_dfop_tc_moreiter <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
+  control = saemix_control_moreiter, transformations = "saemix")
+#plot(f_parent_saemix_dfop_tc_moreiter$so, plot.type = "convergence")

An alternative way to fit DFOP in combination with the two-component error model is to use the model formulation with transformed parameters as used per default in mkin.

f_parent_saemix_dfop_tc_mkin <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
   control = saemix_control, transformations = "mkin")
 plot(f_parent_saemix_dfop_tc_mkin$so, plot.type = "convergence")
-

-

As the convergence plots do not clearly indicate that the algorithm has converged, we again use a much larger number of iterations, which leads to satisfactory convergence (see below).

-
f_parent_saemix_dfop_tc_mkin_10k <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
-  control = saemix_control_10k, transformations = "mkin")
-plot(f_parent_saemix_dfop_tc_mkin_10k$so, plot.type = "convergence")
-

+

As the convergence plots do not clearly indicate that the algorithm has converged, we again use four times the number of iterations, which leads to almost satisfactory convergence (see below).

+
saemix_control_muchmoreiter <- saemixControl(nbiter.saemix = c(3200, 300), nb.chains = 15,
+    print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
+f_parent_saemix_dfop_tc_mkin_muchmoreiter <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
+  control = saemix_control_muchmoreiter, transformations = "mkin")
+plot(f_parent_saemix_dfop_tc_mkin_muchmoreiter$so, plot.type = "convergence")
+

The four combinations (SFO/const, SFO/tc, DFOP/const and DFOP/tc), including the variations of the DFOP/tc combination can be compared using the model comparison function of the saemix package:

AIC_parent_saemix <- saemix::compare.saemix(
   f_parent_saemix_sfo_const$so,
   f_parent_saemix_sfo_tc$so,
   f_parent_saemix_dfop_const$so,
   f_parent_saemix_dfop_tc$so,
-  f_parent_saemix_dfop_tc_10k$so,
+  f_parent_saemix_dfop_tc_moreiter$so,
   f_parent_saemix_dfop_tc_mkin$so,
-  f_parent_saemix_dfop_tc_mkin_10k$so)
+ f_parent_saemix_dfop_tc_mkin_muchmoreiter$so)
Likelihoods calculated by importance sampling
rownames(AIC_parent_saemix) <- c(
   "SFO const", "SFO tc", "DFOP const", "DFOP tc", "DFOP tc more iterations",
   "DFOP tc mkintrans", "DFOP tc mkintrans more iterations")
 print(AIC_parent_saemix)
                                     AIC    BIC
-SFO const                         796.37 795.33
-SFO tc                            798.37 797.13
-DFOP const                        713.16 711.28
-DFOP tc                           666.10 664.01
-DFOP tc more iterations           666.15 664.06
-DFOP tc mkintrans                 682.26 680.17
-DFOP tc mkintrans more iterations 666.12 664.04
-

As in the case of nlme fits, the DFOP model fitted with two-component error (number 4) gives the lowest AIC. Using a much larger number of iterations does not improve the fit a lot. When the mkin transformations are used instead of the saemix transformations, this large number of iterations leads to a goodness of fit that is comparable to the result obtained with saemix transformations.

+SFO const 796.38 795.34 +SFO tc 798.38 797.13 +DFOP const 705.75 703.88 +DFOP tc 665.65 663.57 +DFOP tc more iterations 665.88 663.80 +DFOP tc mkintrans 674.02 671.94 +DFOP tc mkintrans more iterations 667.94 665.86 +

As in the case of nlme fits, the DFOP model fitted with two-component error (number 4) gives the lowest AIC. Using a much larger number of iterations does not significantly change the AIC. When the mkin transformations are used instead of the saemix transformations, we need four times the number of iterations to obtain a goodness of fit that almost as good as the result obtained with saemix transformations.

In order to check the influence of the likelihood calculation algorithms implemented in saemix, the likelihood from Gaussian quadrature is added to the best fit, and the AIC values obtained from the three methods are compared.

f_parent_saemix_dfop_tc$so <-
   saemix::llgq.saemix(f_parent_saemix_dfop_tc$so)
@@ -1755,7 +1759,7 @@ AIC_parent_saemix_methods <- c(
 )
 print(AIC_parent_saemix_methods)
    is     gq    lin 
-666.10 666.03 665.48 
+665.65 665.68 665.11

The AIC values based on importance sampling and Gaussian quadrature are very similar. Using linearisation is known to be less accurate, but still gives a similar value.

@@ -1781,7 +1785,13 @@ aic_nlme_nlmixr_focei <- data.frame( "AIC (nlme)" = aic_nlme, "AIC (nlmixr with FOCEI)" = aic_nlmixr_focei, check.names = FALSE -) +) +print(aic_nlme_nlmixr_focei) +
  Degradation model       Error model AIC (nlme) AIC (nlmixr with FOCEI)
+1               SFO constant variance     796.60                  796.60
+2               SFO     two-component         NA                  798.64
+3              DFOP constant variance     798.60                  745.87
+4              DFOP     two-component     671.91                  740.42

Secondly, we use the SAEM estimation routine and check the convergence plots. The control parameters also used for the saemix fits are defined beforehand.

nlmixr_saem_control_800 <- saemControl(logLik = TRUE,
   nBurn = 800, nEm = 300, nmc = 15)
@@ -1789,49 +1799,49 @@ nlmixr_saem_control_1000 <- saemControl(logLik = TRUE,
   nBurn = 1000, nEm = 300, nmc = 15)
 nlmixr_saem_control_10k <- saemControl(logLik = TRUE,
   nBurn = 10000, nEm = 1000, nmc = 15)
-

The we fit SFO with constant variance

+

Then we fit SFO with constant variance

f_parent_nlmixr_saem_sfo_const <- nlmixr(f_parent_mkin_const["SFO", ], est = "saem",
-  control = nlmixr_saem_control)
+  control = nlmixr_saem_control_800)
 traceplot(f_parent_nlmixr_saem_sfo_const$nm)
-

+

and SFO with two-component error.

f_parent_nlmixr_saem_sfo_tc <- nlmixr(f_parent_mkin_tc["SFO", ], est = "saem",
   control = nlmixr_saem_control_800)
 traceplot(f_parent_nlmixr_saem_sfo_tc$nm)
-

-

For DFOP with constant variance, the convergence plots show considerable instability of the fit, which indicates overparameterisation which was already observed earlier for this model combination.

+

+

For DFOP with constant variance, the convergence plots show considerable instability of the fit, which indicates overparameterisation which was already observed above for this model combination.

f_parent_nlmixr_saem_dfop_const <- nlmixr(f_parent_mkin_const["DFOP", ], est = "saem",
   control = nlmixr_saem_control_800)
 traceplot(f_parent_nlmixr_saem_dfop_const$nm)
-

+

For DFOP with two-component error, a less erratic convergence is seen.

f_parent_nlmixr_saem_dfop_tc <- nlmixr(f_parent_mkin_tc["DFOP", ], est = "saem",
   control = nlmixr_saem_control_800)
 traceplot(f_parent_nlmixr_saem_dfop_tc$nm)
-

+

To check if an increase in the number of iterations improves the fit, we repeat the fit with 1000 iterations for the burn in phase and 300 iterations for the second phase.

f_parent_nlmixr_saem_dfop_tc_1000 <- nlmixr(f_parent_mkin_tc["DFOP", ], est = "saem",
   control = nlmixr_saem_control_1000)
 traceplot(f_parent_nlmixr_saem_dfop_tc_1000$nm)
-

+

Here the fit looks very similar, but we will see below that it shows a higher AIC than the fit with 800 iterations in the burn in phase. Next we choose 10 000 iterations for the burn in phase and 1000 iterations for the second phase for comparison with saemix.

f_parent_nlmixr_saem_dfop_tc_10k <- nlmixr(f_parent_mkin_tc["DFOP", ], est = "saem",
   control = nlmixr_saem_control_10k)
 traceplot(f_parent_nlmixr_saem_dfop_tc_10k$nm)
-

+

In the above convergence plot, the time course of ‘eta.DMTA_0’ and ‘log_k2’ indicate a false convergence.

The AIC values are internally calculated using Gaussian quadrature.

AIC(f_parent_nlmixr_saem_sfo_const$nm, f_parent_nlmixr_saem_sfo_tc$nm,
   f_parent_nlmixr_saem_dfop_const$nm, f_parent_nlmixr_saem_dfop_tc$nm,
   f_parent_nlmixr_saem_dfop_tc_1000$nm,
   f_parent_nlmixr_saem_dfop_tc_10k$nm)
-
                                     df    AIC
-f_parent_nlmixr_saem_sfo_const$nm     5 798.69
-f_parent_nlmixr_saem_sfo_tc$nm        6 810.33
-f_parent_nlmixr_saem_dfop_const$nm    9 736.00
-f_parent_nlmixr_saem_dfop_tc$nm      10 664.85
-f_parent_nlmixr_saem_dfop_tc_1000$nm 10 669.57
-f_parent_nlmixr_saem_dfop_tc_10k$nm  10    Inf
+
                                     df     AIC
+f_parent_nlmixr_saem_sfo_const$nm     5  798.71
+f_parent_nlmixr_saem_sfo_tc$nm        6  808.64
+f_parent_nlmixr_saem_dfop_const$nm    9 1995.96
+f_parent_nlmixr_saem_dfop_tc$nm      10  664.96
+f_parent_nlmixr_saem_dfop_tc_1000$nm 10  667.39
+f_parent_nlmixr_saem_dfop_tc_10k$nm  10     Inf

We can see that again, the DFOP/tc model shows the best goodness of fit. However, increasing the number of burn-in iterations from 800 to 1000 results in a higher AIC. If we further increase the number of iterations to 10 000 (burn-in) and 1000 (second phase), the AIC cannot be calculated for the nlmixr/saem fit, supporting that the fit did not converge properly.

@@ -1866,33 +1876,33 @@ kable(AIC_all) SFO const 796.60 -796.62 -796.37 -798.69 +796.60 +796.38 +798.71 SFO tc 798.60 -798.61 -798.37 -810.33 +798.64 +798.38 +808.64 DFOP const NA -750.91 -713.16 -736.00 +745.87 +705.75 +1995.96 DFOP tc 671.91 -666.60 -666.10 -664.85 +740.42 +665.65 +664.96 @@ -1901,127 +1911,106 @@ kable(AIC_all) Fixed effects: lower est. upper -DMTA_0 96.2802274 98.2761977 100.272168 -k1 0.0339753 0.0645487 0.095122 -k2 0.0058977 0.0088887 0.011880 -g 0.9064373 0.9514417 0.996446 +DMTA_0 96.3087887 98.2761715 100.243554 +k1 0.0336893 0.0643651 0.095041 +k2 0.0062993 0.0088001 0.011301 +g 0.9100426 0.9524920 0.994941 Random effects: - lower est. upper -sd(DMTA_0) 0.44404 2.102366 3.76069 -sd(k1) 0.25433 0.589731 0.92514 -sd(k2) -0.33139 0.099797 0.53099 -sd(g) 0.39606 1.092234 1.78841 + lower est. upper +sd(DMTA_0) 0.41868 2.0607469 3.70281 +sd(k1) 0.25611 0.5935653 0.93102 +sd(k2) -10.29603 0.0029188 10.30187 +sd(g) 0.38083 1.0572543 1.73368 - lower est. upper -a.1 0.863644 1.063021 1.262398 -b.1 0.022555 0.029599 0.036643 + lower est. upper +a.1 0.86253 1.061610 1.260690 +b.1 0.02262 0.029666 0.036712
intervals(f_parent_saemix_dfop_tc)
Approximate 95% confidence intervals
 
  Fixed effects:
             lower       est.      upper
-DMTA_0 96.2802274 98.2761977 100.272168
-k1      0.0339753  0.0645487   0.095122
-k2      0.0058977  0.0088887   0.011880
-g       0.9064373  0.9514417   0.996446
+DMTA_0 96.3087887 98.2761715 100.243554
+k1      0.0336893  0.0643651   0.095041
+k2      0.0062993  0.0088001   0.011301
+g       0.9100426  0.9524920   0.994941
 
  Random effects:
-              lower     est.   upper
-sd(DMTA_0)  0.44404 2.102366 3.76069
-sd(k1)      0.25433 0.589731 0.92514
-sd(k2)     -0.33139 0.099797 0.53099
-sd(g)       0.39606 1.092234 1.78841
+               lower      est.    upper
+sd(DMTA_0)   0.41868 2.0607469  3.70281
+sd(k1)       0.25611 0.5935653  0.93102
+sd(k2)     -10.29603 0.0029188 10.30187
+sd(g)        0.38083 1.0572543  1.73368
 
  
-       lower     est.    upper
-a.1 0.863644 1.063021 1.262398
-b.1 0.022555 0.029599 0.036643
-
intervals(f_parent_saemix_dfop_tc_10k)
+ lower est. upper +a.1 0.86253 1.061610 1.260690 +b.1 0.02262 0.029666 0.036712 +
intervals(f_parent_saemix_dfop_tc_mkin_muchmoreiter)
Approximate 95% confidence intervals
 
  Fixed effects:
             lower       est.      upper
-DMTA_0 96.3027896 98.2641150 100.225440
-k1      0.0338214  0.0644055   0.094990
-k2      0.0058857  0.0087896   0.011693
-g       0.9086138  0.9521421   0.995670
+DMTA_0 96.3402070 98.2789378 100.217669
+k1      0.0397896  0.0641976   0.103578
+k2      0.0041987  0.0084427   0.016977
+g       0.8656257  0.9521509   0.983992
 
  Random effects:
-              lower    est.   upper
-sd(DMTA_0)  0.41448 2.05327 3.69206
-sd(k1)      0.25507 0.59132 0.92758
-sd(k2)     -0.36781 0.09016 0.54813
-sd(g)       0.38585 1.06994 1.75402
+                lower    est.   upper
+sd(DMTA_0)    0.38907 2.01821 3.64735
+sd(log_k1)    0.25653 0.59512 0.93371
+sd(log_k2)   -0.20501 0.37610 0.95721
+sd(g_qlogis)  0.39712 1.18296 1.96879
 
  
        lower     est.    upper
-a.1 0.866273 1.066115 1.265957
-b.1 0.022501 0.029541 0.036581
-
intervals(f_parent_saemix_dfop_tc_mkin_10k)
-
Approximate 95% confidence intervals
-
- Fixed effects:
-            lower       est.      upper
-DMTA_0 96.3021306 98.2736091 100.245088
-k1      0.0401701  0.0645140   0.103611
-k2      0.0064706  0.0089398   0.012351
-g       0.8817692  0.9511605   0.980716
-
- Random effects:
-                lower     est.   upper
-sd(DMTA_0)    0.42392 2.068018 3.71212
-sd(log_k1)    0.25440 0.589877 0.92536
-sd(log_k2)   -0.38431 0.084334 0.55298
-sd(g_qlogis)  0.39107 1.077303 1.76353
-
- 
-       lower     est.    upper
-a.1 0.865291 1.064897 1.264504
-b.1 0.022491 0.029526 0.036561
+a.1 0.868558 1.070260 1.271963 +b.1 0.022461 0.029505 0.036548
intervals(f_parent_nlmixr_saem_dfop_tc)
Approximate 95% confidence intervals
 
  Fixed effects:
             lower       est.      upper
-DMTA_0 96.3059406 98.2990616 100.292183
-k1      0.0402306  0.0648255   0.104456
-k2      0.0067864  0.0093097   0.012771
-g       0.8769017  0.9505258   0.981067
+DMTA_0 96.3224806 98.2941093 100.265738
+k1      0.0402270  0.0648200   0.104448
+k2      0.0068547  0.0093928   0.012871
+g       0.8764066  0.9501419   0.980848
 
  Random effects:
              lower     est. upper
-sd(DMTA_0)      NA 1.724654    NA
-sd(log_k1)      NA 0.592808    NA
-sd(log_k2)      NA 0.010741    NA
-sd(g_qlogis)    NA 1.087349    NA
+sd(DMTA_0)      NA 1.686509    NA
+sd(log_k1)      NA 0.592805    NA
+sd(log_k2)      NA 0.009766    NA
+sd(g_qlogis)    NA 1.082616    NA
 
  
           lower     est. upper
-sigma_low    NA 1.081809    NA
-rsd_high     NA 0.032051    NA
+sigma_low NA 1.081677 NA +rsd_high NA 0.032073 NA
intervals(f_parent_nlmixr_saem_dfop_tc_10k)
Approximate 95% confidence intervals
 
  Fixed effects:
-           lower       est.     upper
-DMTA_0 96.426510 97.8987836 99.371057
-k1      0.040006  0.0644407  0.103799
-k2      0.006748  0.0092476  0.012673
-g       0.879251  0.9511399  0.981147
+            lower       est.      upper
+DMTA_0 96.2302085 98.1641090 100.098010
+k1      0.0398514  0.0643909   0.104041
+k2      0.0066292  0.0090784   0.012432
+g       0.8831478  0.9527284   0.981734
 
  Random effects:
              lower       est. upper
-sd(DMTA_0)      NA 3.7049e-04    NA
-sd(log_k1)      NA 5.9221e-01    NA
-sd(log_k2)      NA 3.8628e-07    NA
-sd(g_qlogis)    NA 1.0694e+00    NA
+sd(DMTA_0)      NA 1.6257e+00    NA
+sd(log_k1)      NA 5.9627e-01    NA
+sd(log_k2)      NA 5.8400e-07    NA
+sd(g_qlogis)    NA 1.0676e+00    NA
 
  
           lower     est. upper
-sigma_low    NA 1.082343    NA
-rsd_high     NA 0.034895    NA
+sigma_low NA 1.087722 NA +rsd_high NA 0.031883 NA
diff --git a/vignettes/web_only/dimethenamid_2018.rmd b/vignettes/web_only/dimethenamid_2018.rmd index ae93984d..08661b5a 100644 --- a/vignettes/web_only/dimethenamid_2018.rmd +++ b/vignettes/web_only/dimethenamid_2018.rmd @@ -1,7 +1,7 @@ --- title: Example evaluations of the dimethenamid data from 2018 author: Johannes Ranke -date: Last change 27 September 2021, built on `r format(Sys.Date(), format = "%d %b %Y")` +date: Last change 11 January 2022, built on `r format(Sys.Date(), format = "%d %b %Y")` output: html_document: toc: true @@ -230,11 +230,11 @@ fit. As we will compare the SAEM implementation of saemix to the results obtained using the nlmixr package later, we define control settings that work well for all the parent data fits shown in this vignette. -```{r saemix_control} +```{r saemix_control, results='hide'} library(saemix) saemix_control <- saemixControl(nbiter.saemix = c(800, 300), nb.chains = 15, print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE) -saemix_control_10k <- saemixControl(nbiter.saemix = c(10000, 1000), nb.chains = 15, +saemix_control_moreiter <- saemixControl(nbiter.saemix = c(1600, 300), nb.chains = 15, print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE) ``` @@ -274,14 +274,15 @@ f_parent_saemix_dfop_tc <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE, plot(f_parent_saemix_dfop_tc$so, plot.type = "convergence") ``` -We also check if using many more iterations (10 000 for the first and 1000 for -the second phase) improve the result in a significant way. The AIC values -obtained are compared further below. - -```{r f_parent_saemix_dfop_tc_10k, results = 'hide', dependson = "saemix_control"} -f_parent_saemix_dfop_tc_10k <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE, - control = saemix_control_10k, transformations = "saemix") -plot(f_parent_saemix_dfop_tc_10k$so, plot.type = "convergence") +```{r f_parent_saemix_dfop_tc_moreiter, results = 'hide', dependson = "saemix_control"} +# The last time I tried (2022-01-11) this gives an error in solve.default(omega.eta) +# system is computationally singular: reciprocal condition number = 5e-17 +#f_parent_saemix_dfop_tc_10k <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE, +# control = saemix_control_10k, transformations = "saemix") +# Now we do not get a significant improvement by using twice the number of iterations +f_parent_saemix_dfop_tc_moreiter <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE, + control = saemix_control_moreiter, transformations = "saemix") +#plot(f_parent_saemix_dfop_tc_moreiter$so, plot.type = "convergence") ``` An alternative way to fit DFOP in combination with the two-component error model @@ -293,15 +294,16 @@ f_parent_saemix_dfop_tc_mkin <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = T control = saemix_control, transformations = "mkin") plot(f_parent_saemix_dfop_tc_mkin$so, plot.type = "convergence") ``` - As the convergence plots do not clearly indicate that the algorithm has converged, we -again use a much larger number of iterations, which leads to satisfactory +again use four times the number of iterations, which leads to almost satisfactory convergence (see below). -```{r f_parent_saemix_dfop_tc_mkin_10k, results = 'hide', dependson = "saemix_control"} -f_parent_saemix_dfop_tc_mkin_10k <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE, - control = saemix_control_10k, transformations = "mkin") -plot(f_parent_saemix_dfop_tc_mkin_10k$so, plot.type = "convergence") +```{r f_parent_saemix_dfop_tc_mkin_moreiter, results = 'hide', dependson = "saemix_control"} +saemix_control_muchmoreiter <- saemixControl(nbiter.saemix = c(3200, 300), nb.chains = 15, + print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE) +f_parent_saemix_dfop_tc_mkin_muchmoreiter <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE, + control = saemix_control_muchmoreiter, transformations = "mkin") +plot(f_parent_saemix_dfop_tc_mkin_muchmoreiter$so, plot.type = "convergence") ``` The four combinations (SFO/const, SFO/tc, DFOP/const and DFOP/tc), including @@ -314,9 +316,9 @@ AIC_parent_saemix <- saemix::compare.saemix( f_parent_saemix_sfo_tc$so, f_parent_saemix_dfop_const$so, f_parent_saemix_dfop_tc$so, - f_parent_saemix_dfop_tc_10k$so, + f_parent_saemix_dfop_tc_moreiter$so, f_parent_saemix_dfop_tc_mkin$so, - f_parent_saemix_dfop_tc_mkin_10k$so) + f_parent_saemix_dfop_tc_mkin_muchmoreiter$so) rownames(AIC_parent_saemix) <- c( "SFO const", "SFO tc", "DFOP const", "DFOP tc", "DFOP tc more iterations", "DFOP tc mkintrans", "DFOP tc mkintrans more iterations") @@ -325,10 +327,10 @@ print(AIC_parent_saemix) As in the case of nlme fits, the DFOP model fitted with two-component error (number 4) gives the lowest AIC. Using a much larger number of iterations -does not improve the fit a lot. When the mkin transformations are used -instead of the saemix transformations, this large number of iterations leads -to a goodness of fit that is comparable to the result obtained with saemix -transformations. +does not significantly change the AIC. When the mkin transformations are used +instead of the saemix transformations, we need four times the number of +iterations to obtain a goodness of fit that almost as good as the result +obtained with saemix transformations. In order to check the influence of the likelihood calculation algorithms implemented in saemix, the likelihood from Gaussian quadrature is added @@ -393,6 +395,7 @@ aic_nlme_nlmixr_focei <- data.frame( "AIC (nlmixr with FOCEI)" = aic_nlmixr_focei, check.names = FALSE ) +print(aic_nlme_nlmixr_focei) ``` Secondly, we use the SAEM estimation routine and check the convergence plots. The @@ -407,7 +410,7 @@ nlmixr_saem_control_10k <- saemControl(logLik = TRUE, nBurn = 10000, nEm = 1000, nmc = 15) ``` -The we fit SFO with constant variance +Then we fit SFO with constant variance ```{r f_parent_nlmixr_saem_sfo_const, results = "hide", warning = FALSE, message = FALSE, dependson = "nlmixr_saem_control"} f_parent_nlmixr_saem_sfo_const <- nlmixr(f_parent_mkin_const["SFO", ], est = "saem", @@ -425,7 +428,7 @@ traceplot(f_parent_nlmixr_saem_sfo_tc$nm) For DFOP with constant variance, the convergence plots show considerable instability of the fit, which indicates overparameterisation which was already -observed earlier for this model combination. +observed above for this model combination. ```{r f_parent_nlmixr_saem_dfop_const, results = "hide", warning = FALSE, message = FALSE, dependson = "nlmixr_saem_control"} f_parent_nlmixr_saem_dfop_const <- nlmixr(f_parent_mkin_const["DFOP", ], est = "saem", @@ -505,8 +508,7 @@ kable(AIC_all) ```{r parms_all, cache = FALSE} intervals(f_parent_saemix_dfop_tc) intervals(f_parent_saemix_dfop_tc) -intervals(f_parent_saemix_dfop_tc_10k) -intervals(f_parent_saemix_dfop_tc_mkin_10k) +intervals(f_parent_saemix_dfop_tc_mkin_muchmoreiter) intervals(f_parent_nlmixr_saem_dfop_tc) intervals(f_parent_nlmixr_saem_dfop_tc_10k) ``` diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_const-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_const-1.png index 4dd55f98..88089aaf 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_const-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_const-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc-1.png index c8bb7c91..efc37a5f 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_10k-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_10k-1.png index fb410d33..ab2b1b2d 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_10k-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_10k-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_1k-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_1k-1.png index 21a381a5..aac73dbe 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_1k-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_1k-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_const-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_const-1.png index dccef3d2..de0a0ded 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_const-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_const-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_tc-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_tc-1.png index 8695b61c..0b7f5090 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_tc-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_tc-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_const-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_const-1.png index 81a4b97f..84a6fc92 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_const-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_const-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc-1.png index bcd023c5..d154dc9b 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin-1.png index 0900f33d..c676406e 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin_moreiter-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin_moreiter-1.png new file mode 100644 index 00000000..e3c21563 Binary files /dev/null and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin_moreiter-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_const-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_const-1.png index 30c2325e..7862fc65 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_const-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_const-1.png differ diff --git a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_tc-1.png b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_tc-1.png index 111d8753..800c320b 100644 Binary files a/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_tc-1.png and b/vignettes/web_only/dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_tc-1.png differ -- cgit v1.2.1