From c73b2f30ec836c949885784ab576e814eb8070a9 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 9 Mar 2021 17:35:47 +0100 Subject: Some improvements for borderline cases - fit_with_errors for saem() - test_log_parms for mean_degparms() and saem() --- docs/dev/reference/saem.html | 72 ++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 23 deletions(-) (limited to 'docs/dev/reference/saem.html') diff --git a/docs/dev/reference/saem.html b/docs/dev/reference/saem.html index bdb1226e..23102df3 100644 --- a/docs/dev/reference/saem.html +++ b/docs/dev/reference/saem.html @@ -74,7 +74,7 @@ Expectation Maximisation algorithm (SAEM)." /> mkin - 1.0.3.9000 + 1.0.4.9000 @@ -158,9 +158,12 @@ Expectation Maximisation algorithm (SAEM).

object, transformations = c("mkin", "saemix"), degparms_start = numeric(), + test_log_parms = FALSE, + conf.level = 0.6, solution_type = "auto", control = list(displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs = FALSE), + fail_with_errors = TRUE, verbose = FALSE, quiet = FALSE, ... @@ -174,6 +177,7 @@ Expectation Maximisation algorithm (SAEM).

solution_type = "auto", transformations = c("mkin", "saemix"), degparms_start = numeric(), + test_log_parms = FALSE, verbose = FALSE, ... ) @@ -204,6 +208,18 @@ SFO or DFOP is used for the parent and there is either no metabolite or one.

degparms_start

Parameter values given as a named numeric vector will be used to override the starting values obtained from the 'mmkin' object.

+ + + test_log_parms +

If TRUE, an attempt is made to use more robust starting +values for population parameters fitted as log parameters in mkin (like +rate constants) by only considering rate constants that pass the t-test +when calculating mean degradation parameters using mean_degparms.

+ + + conf.level +

Possibility to adjust the required confidence level +for parameter that are tested if requested by 'test_log_parms'.

solution_type @@ -214,6 +230,11 @@ automatic choice is not desired

control

Passed to saemix::saemix

+ + fail_with_errors +

Should a failure to compute standard errors +from the inverse of the Fisher Information Matrix be a failure?

+ verbose

Should we print information about created objects of @@ -261,33 +282,36 @@ using mmkin.

state.ini = c(parent = 100), fixed_initials = "parent", quiet = TRUE) f_saem_p0_fixed <- saem(f_mmkin_parent_p0_fixed)
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:32 2021" +#> [1] "Tue Mar 9 17:34:44 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:12:34 2021"
+#> [1] "Tue Mar 9 17:34:45 2021"
f_mmkin_parent <- mmkin(c("SFO", "FOMC", "DFOP"), ds, quiet = TRUE) f_saem_sfo <- saem(f_mmkin_parent["SFO", ])
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:35 2021" +#> [1] "Tue Mar 9 17:34:46 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:12:36 2021"
f_saem_fomc <- saem(f_mmkin_parent["FOMC", ]) +#> [1] "Tue Mar 9 17:34:48 2021"
f_saem_fomc <- saem(f_mmkin_parent["FOMC", ])
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:36 2021" +#> [1] "Tue Mar 9 17:34:48 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:12:38 2021"
f_saem_dfop <- saem(f_mmkin_parent["DFOP", ]) +#> [1] "Tue Mar 9 17:34:50 2021"
f_saem_dfop <- saem(f_mmkin_parent["DFOP", ])
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:39 2021" +#> [1] "Tue Mar 9 17:34:51 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:12:42 2021"
+#> [1] "Tue Mar 9 17:34:53 2021"
# The returned saem.mmkin object contains an SaemixObject, therefore we can use # functions from saemix library(saemix)
#> Package saemix, version 3.1.9000 -#> please direct bugs, questions and feedback to emmanuelle.comets@inserm.fr
compare.saemix(list(f_saem_sfo$so, f_saem_fomc$so, f_saem_dfop$so)) -
#> Error in compare.saemix(list(f_saem_sfo$so, f_saem_fomc$so, f_saem_dfop$so)): 'compare.saemix' requires at least two models.
plot(f_saem_fomc$so, plot.type = "convergence") +#> please direct bugs, questions and feedback to emmanuelle.comets@inserm.fr
compare.saemix(f_saem_sfo$so, f_saem_fomc$so, f_saem_dfop$so) +
#> Likelihoods calculated by importance sampling
#> AIC BIC +#> 1 624.2484 622.2956 +#> 2 467.7096 464.9757 +#> 3 495.4373 491.9222
plot(f_saem_fomc$so, plot.type = "convergence")
#> Plotting convergence plots
plot(f_saem_fomc$so, plot.type = "individual.fit")
#> Plotting individual fits
plot(f_saem_fomc$so, plot.type = "npde")
#> Simulating data using nsim = 1000 simulated datasets @@ -324,11 +348,13 @@ using mmkin.

f_mmkin_parent_tc <- update(f_mmkin_parent, error_model = "tc") f_saem_fomc_tc <- saem(f_mmkin_parent_tc["FOMC", ])
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:44 2021" +#> [1] "Tue Mar 9 17:34:55 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:12:49 2021"
compare.saemix(list(f_saem_fomc$so, f_saem_fomc_tc$so)) -
#> Error in compare.saemix(list(f_saem_fomc$so, f_saem_fomc_tc$so)): 'compare.saemix' requires at least two models.
+#> [1] "Tue Mar 9 17:35:00 2021"
compare.saemix(f_saem_fomc$so, f_saem_fomc_tc$so) +
#> Likelihoods calculated by importance sampling
#> AIC BIC +#> 1 467.7096 464.9757 +#> 2 469.6831 466.5586
sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"), A1 = mkinsub("SFO"))
#> Temporary DLL for differentials generated and loaded
fomc_sfo <- mkinmod(parent = mkinsub("FOMC", "A1"), @@ -346,15 +372,15 @@ using mmkin.

# four minutes f_saem_sfo_sfo <- saem(f_mmkin["SFO-SFO", ])
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:51 2021" +#> [1] "Tue Mar 9 17:35:02 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:12:56 2021"
f_saem_dfop_sfo <- saem(f_mmkin["DFOP-SFO", ]) +#> [1] "Tue Mar 9 17:35:07 2021"
f_saem_dfop_sfo <- saem(f_mmkin["DFOP-SFO", ])
#> Running main SAEM algorithm -#> [1] "Mon Feb 15 17:12:56 2021" +#> [1] "Tue Mar 9 17:35:07 2021" #> .... #> Minimisation finished -#> [1] "Mon Feb 15 17:13:05 2021"
# We can use print, plot and summary methods to check the results +#> [1] "Tue Mar 9 17:35:15 2021"
# We can use print, plot and summary methods to check the results print(f_saem_dfop_sfo)
#> Kinetic nonlinear mixed-effects model fit by SAEM #> Structural model: @@ -395,10 +421,10 @@ using mmkin.

#> SD.g_qlogis 0.44771 -0.86417 1.7596
plot(f_saem_dfop_sfo)
summary(f_saem_dfop_sfo, data = TRUE)
#> saemix version used for fitting: 3.1.9000 -#> mkin version used for pre-fitting: 1.0.3.9000 -#> R version used for fitting: 4.0.3 -#> Date of fit: Mon Feb 15 17:13:05 2021 -#> Date of summary: Mon Feb 15 17:13:06 2021 +#> mkin version used for pre-fitting: 1.0.4.9000 +#> R version used for fitting: 4.0.4 +#> Date of fit: Tue Mar 9 17:35:16 2021 +#> Date of summary: Tue Mar 9 17:35:16 2021 #> #> Equations: #> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * @@ -413,7 +439,7 @@ using mmkin.

#> #> Model predictions using solution type analytical #> -#> Fitted in 8.985 s using 300, 100 iterations +#> Fitted in 8.668 s using 300, 100 iterations #> #> Variance model: Constant variance #> -- cgit v1.2.1