From ac183c732317cf6ede26a2ee127604a407f0a6b3 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 4 Feb 2021 11:24:22 +0100 Subject: Documentation improvements, mainly fixing example code The errors in the example code were in the \dontrun sections, so they were not caught by CRAN checks. In addition, the static help files generated with pkgdown were cached, so I noticed the errors only after completely regenerating the documentation for version 1.0.0. --- docs/reference/Rplot001.png | Bin 13995 -> 1011 bytes docs/reference/Rplot002.png | Bin 13648 -> 37427 bytes docs/reference/Rplot003.png | Bin 15333 -> 33263 bytes docs/reference/Rplot004.png | Bin 10670 -> 24137 bytes docs/reference/Rplot005.png | Bin 19414 -> 24137 bytes docs/reference/Rplot006.png | Bin 24624 -> 22141 bytes docs/reference/confint.mkinfit.html | 85 +++++++++++++++++---------------- docs/reference/index.html | 10 +--- docs/reference/logLik.mkinfit.html | 8 ++-- docs/reference/mkinresplot.html | 2 +- docs/reference/mmkin.html | 15 ++++-- docs/reference/nlme.mmkin-3.png | Bin 79703 -> 172659 bytes docs/reference/nlme.mmkin.html | 66 +++++++++++++++---------- docs/reference/transform_odeparms.html | 78 +++++++++++++++++------------- 14 files changed, 148 insertions(+), 116 deletions(-) (limited to 'docs/reference') diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png index 7f498242..17a35806 100644 Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png index 54c31a3f..bb624e64 100644 Binary files a/docs/reference/Rplot002.png and b/docs/reference/Rplot002.png differ diff --git a/docs/reference/Rplot003.png b/docs/reference/Rplot003.png index 19198739..e96adeb3 100644 Binary files a/docs/reference/Rplot003.png and b/docs/reference/Rplot003.png differ diff --git a/docs/reference/Rplot004.png b/docs/reference/Rplot004.png index ead98fba..91058d4b 100644 Binary files a/docs/reference/Rplot004.png and b/docs/reference/Rplot004.png differ diff --git a/docs/reference/Rplot005.png b/docs/reference/Rplot005.png index 949a9283..91058d4b 100644 Binary files a/docs/reference/Rplot005.png and b/docs/reference/Rplot005.png differ diff --git a/docs/reference/Rplot006.png b/docs/reference/Rplot006.png index da52f580..74f43dfa 100644 Binary files a/docs/reference/Rplot006.png and b/docs/reference/Rplot006.png differ diff --git a/docs/reference/confint.mkinfit.html b/docs/reference/confint.mkinfit.html index 4f7e8872..b71e039a 100644 --- a/docs/reference/confint.mkinfit.html +++ b/docs/reference/confint.mkinfit.html @@ -273,68 +273,69 @@ Profile-Likelihood Based Confidence Intervals, Applied Statistics, 37, if (identical(Sys.getenv("NOT_CRAN"), "true")) { n_cores <- parallel::detectCores() - 1 } else { - n_cores <- 1 + n_cores <- 1 } if (Sys.getenv("TRAVIS") != "") n_cores = 1 if (Sys.info()["sysname"] == "Windows") n_cores = 1 -SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), quiet = TRUE) +SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), + use_of_ff = "min", quiet = TRUE) SFO_SFO.ff <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) f_d_1 <- mkinfit(SFO_SFO, subset(FOCUS_2006_D, value != 0), quiet = TRUE) system.time(ci_profile <- confint(f_d_1, method = "profile", cores = 1, quiet = TRUE))
#> user system elapsed -#> 3.796 1.056 3.506
# Using more cores does not save much time here, as parent_0 takes up most of the time +#> 4.324 0.980 3.960
# Using more cores does not save much time here, as parent_0 takes up most of the time # If we additionally exclude parent_0 (the confidence of which is often of -# minor interest), we get a nice performance improvement from about 50 -# seconds to about 12 seconds if we use at least four cores +# minor interest), we get a nice performance improvement if we use at least 4 cores system.time(ci_profile_no_parent_0 <- confint(f_d_1, method = "profile", c("k_parent_sink", "k_parent_m1", "k_m1_sink", "sigma"), cores = n_cores)) -
#> Profiling the likelihood
#> Warning: scheduled cores 2, 1, 3 encountered errors in user code, all values of the jobs will be affected
#> Error in dimnames(x) <- dn: length of 'dimnames' [2] not equal to array extent
#> Timing stopped at: 0 0.043 0.246
ci_profile -
#> 2.5% 97.5% -#> parent_0 96.456003640 1.027703e+02 -#> k_parent 0.090911032 1.071578e-01 -#> k_m1 0.003892606 6.702775e-03 -#> f_parent_to_m1 0.471328495 5.611550e-01 -#> sigma 2.535612399 3.985263e+00
ci_quadratic_transformed <- confint(f_d_1, method = "quadratic") +
#> Profiling the likelihood
#> user system elapsed +#> 1.480 0.109 0.905
ci_profile +
#> 2.5% 97.5% +#> parent_0 96.456003640 1.027703e+02 +#> k_parent_sink 0.040762501 5.549764e-02 +#> k_parent_m1 0.046786482 5.500879e-02 +#> k_m1_sink 0.003892605 6.702778e-03 +#> sigma 2.535612399 3.985263e+00
ci_quadratic_transformed <- confint(f_d_1, method = "quadratic") ci_quadratic_transformed -
#> 2.5% 97.5% -#> parent_0 96.403833585 102.79311650 -#> k_parent 0.090823771 0.10725430 -#> k_m1 0.004012219 0.00689755 -#> f_parent_to_m1 0.469118824 0.55959615 -#> sigma 2.396089689 3.85491806
ci_quadratic_untransformed <- confint(f_d_1, method = "quadratic", transformed = FALSE) +
#> 2.5% 97.5% +#> parent_0 96.403841640 1.027931e+02 +#> k_parent_sink 0.041033378 5.596269e-02 +#> k_parent_m1 0.046777902 5.511931e-02 +#> k_m1_sink 0.004012217 6.897547e-03 +#> sigma 2.396089689 3.854918e+00
ci_quadratic_untransformed <- confint(f_d_1, method = "quadratic", transformed = FALSE) ci_quadratic_untransformed -
#> 2.5% 97.5% -#> parent_0 96.403833589 1.027931e+02 -#> k_parent 0.090491913 1.069035e-01 -#> k_m1 0.003835485 6.685823e-03 -#> f_parent_to_m1 0.469113477 5.598387e-01 -#> sigma 2.396089689 3.854918e+00
# Against the expectation based on Bates and Watts (1988), the confidence +
#> 2.5% 97.5% +#> parent_0 96.403841645 102.79312449 +#> k_parent_sink 0.040485331 0.05535491 +#> k_parent_m1 0.046611582 0.05494364 +#> k_m1_sink 0.003835483 0.00668582 +#> sigma 2.396089689 3.85491806
# Against the expectation based on Bates and Watts (1988), the confidence # intervals based on the internal parameter transformation are less # congruent with the likelihood based intervals. Note the superiority of the # interval based on the untransformed fit for k_m1_sink rel_diffs_transformed <- abs((ci_quadratic_transformed - ci_profile)/ci_profile) rel_diffs_untransformed <- abs((ci_quadratic_untransformed - ci_profile)/ci_profile) rel_diffs_transformed < rel_diffs_untransformed -
#> 2.5% 97.5% -#> parent_0 FALSE FALSE -#> k_parent TRUE TRUE -#> k_m1 FALSE FALSE -#> f_parent_to_m1 TRUE FALSE -#> sigma TRUE FALSE
signif(rel_diffs_transformed, 3) -
#> 2.5% 97.5% -#> parent_0 0.000541 0.000222 -#> k_parent 0.000960 0.000900 -#> k_m1 0.030700 0.029100 -#> f_parent_to_m1 0.004690 0.002780 -#> sigma 0.055000 0.032700
signif(rel_diffs_untransformed, 3) -
#> 2.5% 97.5% -#> parent_0 0.000541 0.000222 -#> k_parent 0.004610 0.002370 -#> k_m1 0.014700 0.002530 -#> f_parent_to_m1 0.004700 0.002350 -#> sigma 0.055000 0.032700
+
#> 2.5% 97.5% +#> parent_0 FALSE FALSE +#> k_parent_sink TRUE FALSE +#> k_parent_m1 TRUE FALSE +#> k_m1_sink FALSE FALSE +#> sigma FALSE FALSE
signif(rel_diffs_transformed, 3) +
#> 2.5% 97.5% +#> parent_0 0.000541 0.000222 +#> k_parent_sink 0.006650 0.008380 +#> k_parent_m1 0.000183 0.002010 +#> k_m1_sink 0.030700 0.029100 +#> sigma 0.055000 0.032700
signif(rel_diffs_untransformed, 3) +
#> 2.5% 97.5% +#> parent_0 0.000541 0.000222 +#> k_parent_sink 0.006800 0.002570 +#> k_parent_m1 0.003740 0.001180 +#> k_m1_sink 0.014700 0.002530 +#> sigma 0.055000 0.032700
# Investigate a case with formation fractions f_d_2 <- mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), quiet = TRUE) diff --git a/docs/reference/index.html b/docs/reference/index.html index c9f66992..0859a152 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ mkin - 1.0.0 + 1.0.1
@@ -175,7 +175,7 @@ -

mmkin()

+

mmkin() print(<mmkin>)

Fit one or more kinetic models with one or more state variables to one or more datasets

@@ -297,12 +297,6 @@ of an mmkin object

AIC(<mmkin>) BIC(<mmkin>)

Calculate the AIC for a column of an mmkin object

- - - -

print(<mmkin>)

- -

Print method for mmkin objects

diff --git a/docs/reference/logLik.mkinfit.html b/docs/reference/logLik.mkinfit.html index ac3f570c..8d984e55 100644 --- a/docs/reference/logLik.mkinfit.html +++ b/docs/reference/logLik.mkinfit.html @@ -196,11 +196,11 @@ and the fitted error model parameters.

parent = mkinsub("SFO", to = "m1"), m1 = mkinsub("SFO") ) -
#> Temporary DLL for differentials generated and loaded
d_t <- FOCUS_2006_D +
#> Temporary DLL for differentials generated and loaded
d_t <- subset(FOCUS_2006_D, value != 0) f_nw <- mkinfit(sfo_sfo, d_t, quiet = TRUE) # no weighting (weights are unity) -
#> Warning: Observations with value of zero were removed from the data
f_obs <- mkinfit(sfo_sfo, d_t, error_model = "obs", quiet = TRUE) -
#> Warning: Observations with value of zero were removed from the data
f_tc <- mkinfit(sfo_sfo, d_t, error_model = "tc", quiet = TRUE) -
#> Warning: Observations with value of zero were removed from the data
AIC(f_nw, f_obs, f_tc) + f_obs <- update(f_nw, error_model = "obs") + f_tc <- update(f_nw, error_model = "tc") + AIC(f_nw, f_obs, f_tc)
#> df AIC #> f_nw 5 204.4486 #> f_obs 6 205.8727 diff --git a/docs/reference/mkinresplot.html b/docs/reference/mkinresplot.html index a9638c93..69517f36 100644 --- a/docs/reference/mkinresplot.html +++ b/docs/reference/mkinresplot.html @@ -242,7 +242,7 @@ lines of the mkinfit object, and plot_res< combining the plot of the fit and the residual plot.

Author

-

Johannes Ranke

+

Johannes Ranke and Katrin Lindenberger

Examples

diff --git a/docs/reference/mmkin.html b/docs/reference/mmkin.html index 20134030..77f815da 100644 --- a/docs/reference/mmkin.html +++ b/docs/reference/mmkin.html @@ -158,7 +158,10 @@ datasets specified in its first two arguments.

cores = parallel::detectCores(), cluster = NULL, ... -)
+) + +# S3 method for mmkin +print(x, ...)

Arguments

@@ -189,7 +192,11 @@ for parallel execution.

- + + + + +
...

Further arguments that will be passed to mkinfit.

Not used.

x

An mmkin object.

@@ -227,9 +234,9 @@ plotting.

time_default
#> user system elapsed -#> 4.869 0.357 1.415
time_1 +#> 4.634 0.317 1.280
time_1
#> user system elapsed -#> 5.502 0.002 5.507
+#> 5.249 0.016 5.267
endpoints(fits.0[["SFO_lin", 2]])
#> $ff #> parent_M1 parent_sink M1_M2 M1_sink diff --git a/docs/reference/nlme.mmkin-3.png b/docs/reference/nlme.mmkin-3.png index 0b7ce0f6..7c04df4b 100644 Binary files a/docs/reference/nlme.mmkin-3.png and b/docs/reference/nlme.mmkin-3.png differ diff --git a/docs/reference/nlme.mmkin.html b/docs/reference/nlme.mmkin.html index dd1670fe..2e4f6337 100644 --- a/docs/reference/nlme.mmkin.html +++ b/docs/reference/nlme.mmkin.html @@ -157,7 +157,7 @@ have been obtained by fitting the same model to a list of datasets.

data = "auto", fixed = lapply(as.list(names(mean_degparms(model))), function(el) eval(parse(text = paste(el, 1, sep = "~")))), - random = pdDiag(fixed), + random = pdDiag(fixed), groups, start = mean_degparms(model, random = TRUE), correlation = NULL, @@ -262,6 +262,12 @@ parameters taken from the mmkin object are used

Upon success, a fitted 'nlme.mmkin' object, which is an nlme object with additional elements. It also inherits from 'mixed.mmkin'.

+

Details

+ +

Note that the convergence of the nlme algorithms depends on the quality +of the data. In degradation kinetics, we often only have few datasets +(e.g. data for few soils) and complicated degradation models, which may +make it impossible to obtain convergence with nlme.

Note

As the object inherits from nlme::nlme, there is a wealth of @@ -335,16 +341,17 @@ methods that will automatically work on 'nlme.mmkin' objects, such as # f_nlme_sfo_sfo_ff <- nlme(f_2["SFO-SFO-ff", ]) #plot(f_nlme_sfo_sfo_ff) - # With the log-Cholesky parameterization, this converges in 11 - # iterations and around 100 seconds, but without tweaking control - # parameters (with pdDiag, increasing the tolerance and pnlsMaxIter was - # necessary) - f_nlme_dfop_sfo <- nlme(f_2["DFOP-SFO", ]) -

#> Error in nlme.formula(model = value ~ (mkin::get_deg_func())(name, time, parent_0, log_k_A1, f_parent_qlogis, log_k1, log_k2, g_qlogis), data = structure(list(ds = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L ), .Label = c("1", "2", "3", "4", "5"), class = c("ordered", "factor")), name = c("parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1"), time = c(0, 0, 3, 3, 6, 6, 10, 10, 20, 20, 34, 34, 55, 55, 90, 90, 112, 112, 132, 132, 3, 3, 6, 6, 10, 10, 20, 20, 34, 34, 55, 55, 90, 90, 112, 112, 132, 132, 0, 0, 3, 3, 7, 7, 14, 14, 30, 30, 60, 60, 90, 90, 120, 120, 180, 180, 3, 3, 7, 7, 14, 14, 30, 30, 60, 60, 90, 90, 120, 120, 180, 180, 0, 0, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 0, 0, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 91, 91, 120, 120, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 91, 91, 120, 120, 0, 0, 8, 8, 14, 14, 21, 21, 41, 41, 63, 63, 91, 91, 120, 120, 8, 8, 14, 14, 21, 21, 41, 41, 63, 63, 91, 91, 120, 120), value = c(97.2, 96.4, 71.1, 69.2, 58.1, 56.6, 44.4, 43.4, 33.3, 29.2, 17.6, 18, 10.5, 9.3, 4.5, 4.7, 3, 3.4, 2.3, 2.7, 4.3, 4.6, 7, 7.2, 8.2, 8, 11, 13.7, 11.5, 12.7, 14.9, 14.5, 12.1, 12.3, 9.9, 10.2, 8.8, 7.8, 93.6, 92.3, 87, 82.2, 74, 73.9, 64.2, 69.5, 54, 54.6, 41.1, 38.4, 32.5, 35.5, 28.1, 29, 26.5, 27.6, 3.9, 3.1, 6.9, 6.6, 10.4, 8.3, 14.4, 13.7, 22.1, 22.3, 27.5, 25.4, 28, 26.6, 25.8, 25.3, 91.9, 90.8, 64.9, 66.2, 43.5, 44.1, 18.3, 18.1, 10.2, 10.8, 4.9, 3.3, 1.6, 1.5, 1.1, 0.9, 9.6, 7.7, 15, 15.1, 21.2, 21.1, 19.7, 18.9, 17.5, 15.9, 9.5, 9.8, 6.2, 6.1, 99.8, 98.3, 77.1, 77.2, 59, 58.1, 27.4, 29.2, 19.1, 29.6, 10.1, 18.2, 4.5, 9.1, 2.3, 2.9, 2, 1.8, 2, 2.2, 4.2, 3.9, 7.4, 7.9, 14.5, 13.7, 14.2, 12.2, 13.7, 13.2, 13.6, 15.4, 10.4, 11.6, 10, 9.5, 9.1, 9, 96.1, 94.3, 73.9, 73.9, 69.4, 73.1, 65.6, 65.3, 55.9, 54.4, 47, 49.3, 44.7, 46.7, 42.1, 41.3, 3.3, 3.4, 3.9, 2.9, 6.4, 7.2, 9.1, 8.5, 11.7, 12, 13.3, 13.2, 14.3, 12.1)), row.names = c(NA, -170L), class = c("nfnGroupedData", "nfGroupedData", "groupedData", "data.frame"), formula = value ~ time | ds, FUN = function (x) max(x, na.rm = TRUE), order.groups = FALSE), start = list( fixed = c(parent_0 = 93.8101519326534, log_k_A1 = -9.76474551635931, f_parent_qlogis = -0.971114801595408, log_k1 = -1.87993711571859, log_k2 = -4.27081421366622, g_qlogis = 0.135644115277507 ), random = list(ds = structure(c(2.56569977430371, -3.49441920289139, -3.32614443321494, 4.35347873814922, -0.0986148763466161, 4.65850590018027, 1.8618544764481, 6.12693257601545, 4.91792724701579, -17.5652201996596, -0.466203822618637, 0.746660653597927, 0.282193987271096, -0.42053488943072, -0.142115928819667, 0.369240076779088, -1.38985563501659, 1.02592753494098, 0.73090914081534, -0.736221117518819, 0.768170629350299, -1.89347658079869, 1.72168783460352, 0.844607177798114, -1.44098906095325, -0.377731855445672, 0.168180098477565, 0.469683412912104, 0.500717664434525, -0.760849320378522), .Dim = 5:6, .Dimnames = list(c("1", "2", "3", "4", "5"), c("parent_0", "log_k_A1", "f_parent_qlogis", "log_k1", "log_k2", "g_qlogis"))))), fixed = list(parent_0 ~ 1, log_k_A1 ~ 1, f_parent_qlogis ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1), random = structure(numeric(0), class = c("pdDiag", "pdMat"), formula = structure(list(parent_0 ~ 1, log_k_A1 ~ 1, f_parent_qlogis ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1), class = "listForm"), Dimnames = list(NULL, NULL))): maximum number of iterations (maxIter = 50) reached without convergence
#> Timing stopped at: 48.39 16.98 43
+ # For the following, we need to increase pnlsMaxIter and the tolerance + # to get convergence + f_nlme_dfop_sfo <- nlme(f_2["DFOP-SFO", ], + control = list(pnlsMaxIter = 120, tolerance = 5e-4)) + plot(f_nlme_dfop_sfo) -
#> Error in plot(f_nlme_dfop_sfo): object 'f_nlme_dfop_sfo' not found
+
anova(f_nlme_dfop_sfo, f_nlme_sfo_sfo) -
#> Error in anova(f_nlme_dfop_sfo, f_nlme_sfo_sfo): object 'f_nlme_dfop_sfo' not found
+
#> Model df AIC BIC logLik Test L.Ratio p-value +#> f_nlme_dfop_sfo 1 13 843.8547 884.6201 -408.9274 +#> f_nlme_sfo_sfo 2 9 1085.1821 1113.4043 -533.5910 1 vs 2 249.3274 <.0001
endpoints(f_nlme_sfo_sfo)
#> $ff #> parent_sink parent_A1 A1_sink @@ -355,7 +362,15 @@ methods that will automatically work on 'nlme.mmkin' objects, such as #> parent 19.13518 63.5657 #> A1 66.02155 219.3189 #>
endpoints(f_nlme_dfop_sfo) -
#> Error in endpoints(f_nlme_dfop_sfo): object 'f_nlme_dfop_sfo' not found
+
#> $ff +#> parent_A1 parent_sink +#> 0.2768574 0.7231426 +#> +#> $distimes +#> DT50 DT90 DT50back DT50_k1 DT50_k2 +#> parent 11.07091 104.6320 31.49738 4.462384 46.20825 +#> A1 162.30523 539.1663 NA NA NA +#>
if (length(findFunction("varConstProp")) > 0) { # tc error model for nlme available # Attempts to fit metabolite kinetics with the tc error model are possible, # but need tweeking of control values and sometimes do not converge @@ -396,9 +411,7 @@ methods that will automatically work on 'nlme.mmkin' objects, such as #> Parameter estimates: #> const prop #> 2.23224114 0.01262341
- f_2_obs <- mmkin(list("SFO-SFO" = m_sfo_sfo, - "DFOP-SFO" = m_dfop_sfo), - ds_2, quiet = TRUE, error_model = "obs") + f_2_obs <- update(f_2, error_model = "obs") f_nlme_sfo_sfo_obs <- nlme(f_2_obs["SFO-SFO", ]) print(f_nlme_sfo_sfo_obs)
#> Kinetic nonlinear mixed-effects model fit by maximum likelihood @@ -429,18 +442,21 @@ methods that will automatically work on 'nlme.mmkin' objects, such as #> Formula: ~1 | name #> Parameter estimates: #> parent A1 -#> 1.0000000 0.2050003
f_nlme_dfop_sfo_obs <- nlme(f_2_obs["DFOP-SFO", ]) -
#> Error in nlme.formula(model = value ~ (mkin::get_deg_func())(name, time, parent_0, log_k_A1, f_parent_qlogis, log_k1, log_k2, g_qlogis), data = structure(list(ds = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L ), .Label = c("1", "2", "3", "4", "5"), class = c("ordered", "factor")), name = c("parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "parent", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1"), time = c(0, 0, 3, 3, 6, 6, 10, 10, 20, 20, 34, 34, 55, 55, 90, 90, 112, 112, 132, 132, 3, 3, 6, 6, 10, 10, 20, 20, 34, 34, 55, 55, 90, 90, 112, 112, 132, 132, 0, 0, 3, 3, 7, 7, 14, 14, 30, 30, 60, 60, 90, 90, 120, 120, 180, 180, 3, 3, 7, 7, 14, 14, 30, 30, 60, 60, 90, 90, 120, 120, 180, 180, 0, 0, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 0, 0, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 91, 91, 120, 120, 1, 1, 3, 3, 8, 8, 14, 14, 27, 27, 48, 48, 70, 70, 91, 91, 120, 120, 0, 0, 8, 8, 14, 14, 21, 21, 41, 41, 63, 63, 91, 91, 120, 120, 8, 8, 14, 14, 21, 21, 41, 41, 63, 63, 91, 91, 120, 120), value = c(97.2, 96.4, 71.1, 69.2, 58.1, 56.6, 44.4, 43.4, 33.3, 29.2, 17.6, 18, 10.5, 9.3, 4.5, 4.7, 3, 3.4, 2.3, 2.7, 4.3, 4.6, 7, 7.2, 8.2, 8, 11, 13.7, 11.5, 12.7, 14.9, 14.5, 12.1, 12.3, 9.9, 10.2, 8.8, 7.8, 93.6, 92.3, 87, 82.2, 74, 73.9, 64.2, 69.5, 54, 54.6, 41.1, 38.4, 32.5, 35.5, 28.1, 29, 26.5, 27.6, 3.9, 3.1, 6.9, 6.6, 10.4, 8.3, 14.4, 13.7, 22.1, 22.3, 27.5, 25.4, 28, 26.6, 25.8, 25.3, 91.9, 90.8, 64.9, 66.2, 43.5, 44.1, 18.3, 18.1, 10.2, 10.8, 4.9, 3.3, 1.6, 1.5, 1.1, 0.9, 9.6, 7.7, 15, 15.1, 21.2, 21.1, 19.7, 18.9, 17.5, 15.9, 9.5, 9.8, 6.2, 6.1, 99.8, 98.3, 77.1, 77.2, 59, 58.1, 27.4, 29.2, 19.1, 29.6, 10.1, 18.2, 4.5, 9.1, 2.3, 2.9, 2, 1.8, 2, 2.2, 4.2, 3.9, 7.4, 7.9, 14.5, 13.7, 14.2, 12.2, 13.7, 13.2, 13.6, 15.4, 10.4, 11.6, 10, 9.5, 9.1, 9, 96.1, 94.3, 73.9, 73.9, 69.4, 73.1, 65.6, 65.3, 55.9, 54.4, 47, 49.3, 44.7, 46.7, 42.1, 41.3, 3.3, 3.4, 3.9, 2.9, 6.4, 7.2, 9.1, 8.5, 11.7, 12, 13.3, 13.2, 14.3, 12.1)), row.names = c(NA, -170L), class = c("nfnGroupedData", "nfGroupedData", "groupedData", "data.frame"), formula = value ~ time | ds, FUN = function (x) max(x, na.rm = TRUE), order.groups = FALSE), start = list( fixed = c(parent_0 = 93.4272167134207, log_k_A1 = -9.71590717106959, f_parent_qlogis = -0.953712099744438, log_k1 = -1.95256957646888, log_k2 = -4.42919226610318, g_qlogis = 0.193023137298073 ), random = list(ds = structure(c(2.85557330683041, -3.87630303729395, -2.78062140212751, 4.82042042600536, -1.01906929341432, 4.613992019697, 2.05871276943309, 6.0766404049189, 4.86471337131288, -17.6140585653619, -0.480721175257541, 0.773079218835614, 0.260464433006093, -0.440615012802434, -0.112207463781733, 0.445812953745225, -1.49588630006094, 1.13602040717272, 0.801850880762046, -0.887797941619048, 0.936480292463262, -2.43093808171905, 1.91256225793793, 0.984827519864443, -1.40293198854659, -0.455176326336681, 0.376355651864385, 0.343919720700401, 0.46329187713133, -0.728390923359434 ), .Dim = 5:6, .Dimnames = list(c("1", "2", "3", "4", "5"), c("parent_0", "log_k_A1", "f_parent_qlogis", "log_k1", "log_k2", "g_qlogis"))))), fixed = list(parent_0 ~ 1, log_k_A1 ~ 1, f_parent_qlogis ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1), random = structure(numeric(0), class = c("pdDiag", "pdMat"), formula = structure(list(parent_0 ~ 1, log_k_A1 ~ 1, f_parent_qlogis ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1), class = "listForm"), Dimnames = list(NULL, NULL)), weights = structure(numeric(0), formula = ~1 | name, class = c("varIdent", "varFunc"))): maximum number of iterations (maxIter = 50) reached without convergence
#> Timing stopped at: 58.24 16.62 52.48
- f_2_tc <- mmkin(list("SFO-SFO" = m_sfo_sfo, - "DFOP-SFO" = m_dfop_sfo), - ds_2, quiet = TRUE, error_model = "tc") - # f_nlme_sfo_sfo_tc <- nlme(f_2_tc["SFO-SFO", ]) # stops with error message - f_nlme_dfop_sfo_tc <- nlme(f_2_tc["DFOP-SFO", ]) -
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Warning: longer object length is not a multiple of shorter object length
#> Error in X[, fmap[[nm]]] <- gradnm: number of items to replace is not a multiple of replacement length
#> Timing stopped at: 6.327 2.686 5.428
# We get warnings about false convergence in the LME step in several iterations - # but as the last such warning occurs in iteration 25 and we have 28 iterations - # we can ignore these - anova(f_nlme_dfop_sfo, f_nlme_dfop_sfo_obs, f_nlme_dfop_sfo_tc) -
#> Error in anova(f_nlme_dfop_sfo, f_nlme_dfop_sfo_obs, f_nlme_dfop_sfo_tc): object 'f_nlme_dfop_sfo' not found
+#> 1.0000000 0.2050003
f_nlme_dfop_sfo_obs <- nlme(f_2_obs["DFOP-SFO", ], + control = list(pnlsMaxIter = 120, tolerance = 5e-4)) + + f_2_tc <- update(f_2, error_model = "tc") + # f_nlme_sfo_sfo_tc <- nlme(f_2_tc["SFO-SFO", ]) # No convergence with 50 iterations + # f_nlme_dfop_sfo_tc <- nlme(f_2_tc["DFOP-SFO", ], + # control = list(pnlsMaxIter = 120, tolerance = 5e-4)) # Error in X[, fmap[[nm]]] <- gradnm + + anova(f_nlme_dfop_sfo, f_nlme_dfop_sfo_obs) +
#> Model df AIC BIC logLik Test L.Ratio +#> f_nlme_dfop_sfo 1 13 843.8547 884.6201 -408.9274 +#> f_nlme_dfop_sfo_obs 2 14 817.5338 861.4350 -394.7669 1 vs 2 28.32089 +#> p-value +#> f_nlme_dfop_sfo +#> f_nlme_dfop_sfo_obs <.0001
# }
diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index efaf7b46..e2cb876b 100644 --- a/docs/reference/transform_odeparms.html +++ b/docs/reference/transform_odeparms.html @@ -77,7 +77,7 @@ the ilr transformation is used." /> mkin - 1.0.0 + 1.0.1 @@ -231,50 +231,64 @@ This is no problem for the internal use in mkinfit.
SFO_SFO <- mkinmod( parent = list(type = "SFO", to = "m1", sink = TRUE), - m1 = list(type = "SFO")) -
#> Temporary DLL for differentials generated and loaded
# Fit the model to the FOCUS example dataset D using defaults -fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) -
#> Warning: Observations with value of zero were removed from the data
fit.s <- summary(fit) + m1 = list(type = "SFO"), use_of_ff = "min") +
#> Temporary DLL for differentials generated and loaded
+# Fit the model to the FOCUS example dataset D using defaults +FOCUS_D <- subset(FOCUS_2006_D, value != 0) # remove zero values to avoid warning +fit <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE) +fit.s <- summary(fit) # Transformed and backtransformed parameters print(fit.s$par, 3) -
#> Estimate Std. Error Lower Upper -#> parent_0 99.5985 1.5702 96.404 102.79 -#> log_k_parent -2.3157 0.0409 -2.399 -2.23 -#> log_k_m1 -5.2475 0.1332 -5.518 -4.98 -#> f_parent_qlogis 0.0579 0.0893 -0.124 0.24 -#> sigma 3.1255 0.3585 2.396 3.85
print(fit.s$bpar, 3) -
#> Estimate se_notrans t value Pr(>t) Lower Upper -#> parent_0 99.59848 1.57022 63.43 2.30e-36 96.40383 102.7931 -#> k_parent 0.09870 0.00403 24.47 4.96e-23 0.09082 0.1073 -#> k_m1 0.00526 0.00070 7.51 6.16e-09 0.00401 0.0069 -#> f_parent_to_m1 0.51448 0.02230 23.07 3.10e-22 0.46912 0.5596 -#> sigma 3.12550 0.35852 8.72 2.24e-10 2.39609 3.8549
+
#> Estimate Std. Error Lower Upper +#> parent_0 99.60 1.5702 96.40 102.79 +#> log_k_parent_sink -3.04 0.0763 -3.19 -2.88 +#> log_k_parent_m1 -2.98 0.0403 -3.06 -2.90 +#> log_k_m1_sink -5.25 0.1332 -5.52 -4.98 +#> sigma 3.13 0.3585 2.40 3.85
print(fit.s$bpar, 3) +
#> Estimate se_notrans t value Pr(>t) Lower Upper +#> parent_0 99.59848 1.57022 63.43 2.30e-36 96.40384 102.7931 +#> k_parent_sink 0.04792 0.00365 13.11 6.13e-15 0.04103 0.0560 +#> k_parent_m1 0.05078 0.00205 24.80 3.27e-23 0.04678 0.0551 +#> k_m1_sink 0.00526 0.00070 7.51 6.16e-09 0.00401 0.0069 +#> sigma 3.12550 0.35852 8.72 2.24e-10 2.39609 3.8549
# \dontrun{ -# Compare to the version without transforming rate parameters -fit.2 <- mkinfit(SFO_SFO, FOCUS_2006_D, transform_rates = FALSE, quiet = TRUE) -
#> Warning: Observations with value of zero were removed from the data
#> Error in if (cost < cost.current) { assign("cost.current", cost, inherits = TRUE) if (!quiet) cat(ifelse(OLS, "Sum of squared residuals", "Negative log-likelihood"), " at call ", calls, ": ", signif(cost.current, 6), "\n", sep = "")}: missing value where TRUE/FALSE needed
#> Timing stopped at: 0.003 0 0.003
fit.2.s <- summary(fit.2) -
#> Error in summary(fit.2): object 'fit.2' not found
print(fit.2.s$par, 3) -
#> Error in print(fit.2.s$par, 3): object 'fit.2.s' not found
print(fit.2.s$bpar, 3) -
#> Error in print(fit.2.s$bpar, 3): object 'fit.2.s' not found
# } +# Compare to the version without transforming rate parameters (does not work +# with analytical solution, we get NA values for m1 in predictions) +fit.2 <- mkinfit(SFO_SFO, FOCUS_D, transform_rates = FALSE, + solution_type = "deSolve", quiet = TRUE) +fit.2.s <- summary(fit.2) +print(fit.2.s$par, 3) +
#> Estimate Std. Error Lower Upper +#> parent_0 99.59849 1.57022 96.40385 1.03e+02 +#> k_parent_sink 0.04792 0.00365 0.04049 5.54e-02 +#> k_parent_m1 0.05078 0.00205 0.04661 5.49e-02 +#> k_m1_sink 0.00526 0.00070 0.00384 6.69e-03 +#> sigma 3.12550 0.35852 2.39609 3.85e+00
print(fit.2.s$bpar, 3) +
#> Estimate se_notrans t value Pr(>t) Lower Upper +#> parent_0 99.59849 1.57022 63.43 2.30e-36 96.40385 1.03e+02 +#> k_parent_sink 0.04792 0.00365 13.11 6.13e-15 0.04049 5.54e-02 +#> k_parent_m1 0.05078 0.00205 24.80 3.27e-23 0.04661 5.49e-02 +#> k_m1_sink 0.00526 0.00070 7.51 6.16e-09 0.00384 6.69e-03 +#> sigma 3.12550 0.35852 8.72 2.24e-10 2.39609 3.85e+00
# } initials <- fit$start$value names(initials) <- rownames(fit$start) transformed <- fit$start_transformed$value names(transformed) <- rownames(fit$start_transformed) transform_odeparms(initials, SFO_SFO) -
#> parent_0 log_k_parent log_k_m1 f_parent_qlogis -#> 100.750000 -2.302585 -2.301586 0.000000
backtransform_odeparms(transformed, SFO_SFO) -
#> parent_0 k_parent k_m1 f_parent_to_m1 -#> 100.7500 0.1000 0.1001 0.5000
+
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 100.750000 -2.302585 -2.301586 -2.300587
backtransform_odeparms(transformed, SFO_SFO) +
#> parent_0 k_parent_sink k_parent_m1 k_m1_sink +#> 100.7500 0.1000 0.1001 0.1002
# \dontrun{ -# The case of formation fractions +# The case of formation fractions (this is now the default) SFO_SFO.ff <- mkinmod( parent = list(type = "SFO", to = "m1", sink = TRUE), m1 = list(type = "SFO"), use_of_ff = "max")
#> Temporary DLL for differentials generated and loaded
-fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) -
#> Warning: Observations with value of zero were removed from the data
fit.ff.s <- summary(fit.ff) +fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_D, quiet = TRUE) +fit.ff.s <- summary(fit.ff) print(fit.ff.s$par, 3)
#> Estimate Std. Error Lower Upper #> parent_0 99.5985 1.5702 96.404 102.79 @@ -299,8 +313,8 @@ This is no problem for the internal use in mkinfit.= "max")
#> Temporary DLL for differentials generated and loaded
-fit.ff.2 <- mkinfit(SFO_SFO.ff.2, FOCUS_2006_D, quiet = TRUE) -
#> Warning: Observations with value of zero were removed from the data
fit.ff.2.s <- summary(fit.ff.2) +fit.ff.2 <- mkinfit(SFO_SFO.ff.2, FOCUS_D, quiet = TRUE) +fit.ff.2.s <- summary(fit.ff.2) print(fit.ff.2.s$par, 3)
#> Estimate Std. Error Lower Upper #> parent_0 84.79 3.012 78.67 90.91 -- cgit v1.2.1