From a5874ab7fce4616e80be69366ff0685332f47bf1 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 27 Oct 2020 15:34:14 +0100 Subject: Add summary method for nlme.mmkin objects Improve and update docs --- docs/dev/reference/Rplot001.png | Bin 27839 -> 14324 bytes docs/dev/reference/index.html | 8 +- docs/dev/reference/nlme.mmkin.html | 96 ++++--- docs/dev/reference/plot.nlme.mmkin.html | 14 +- docs/dev/reference/sigma_twocomp.html | 11 +- docs/dev/reference/summary.nlme.mmkin.html | 446 +++++++++++++++++++++++++++++ 6 files changed, 530 insertions(+), 45 deletions(-) create mode 100644 docs/dev/reference/summary.nlme.mmkin.html (limited to 'docs/dev/reference') diff --git a/docs/dev/reference/Rplot001.png b/docs/dev/reference/Rplot001.png index cfc5bc2b..f001da49 100644 Binary files a/docs/dev/reference/Rplot001.png and b/docs/dev/reference/Rplot001.png differ diff --git a/docs/dev/reference/index.html b/docs/dev/reference/index.html index 24056025..fa3ec868 100644 --- a/docs/dev/reference/index.html +++ b/docs/dev/reference/index.html @@ -308,7 +308,7 @@ of an mmkin object

Mixed models

-

Create and work with nonlinear mixed models

+

Create and work with nonlinear mixed effects models

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

Plot a fitted nonlinear mixed model obtained via an mmkin row object

+ +

summary(<nlme.mmkin>) print(<summary.nlme.mmkin>)

+ +

Summary method for class "nlme.mmkin"

+ +

nlme_function() mean_degparms() nlme_data()

diff --git a/docs/dev/reference/nlme.mmkin.html b/docs/dev/reference/nlme.mmkin.html index 90aec9be..3fa4d97b 100644 --- a/docs/dev/reference/nlme.mmkin.html +++ b/docs/dev/reference/nlme.mmkin.html @@ -152,7 +152,7 @@ have been obtained by fitting the same model to a list of datasets.

# S3 method for mmkin
-nlme(
+nlme(
   model,
   data = sys.frame(sys.parent()),
   fixed,
@@ -255,6 +255,11 @@ parameters taken from the mmkin object are used

Upon success, a fitted nlme.mmkin object, which is an nlme object with additional elements

+

Note

+ +

As the object inherits from nlme::nlme, there is a wealth of +methods that will automatically work on 'nlme.mmkin' objects, such as +nlme::intervals(), nlme::anova.lme() and nlme::coef.lme().

See also

@@ -270,11 +275,20 @@ with additional elements

#> df AIC #> f_nlme_sfo 5 625.0539 #> f_nlme_dfop 9 495.1270
print(f_nlme_dfop) -
#> Nonlinear mixed-effects model fit by maximum likelihood -#> Model: value ~ (mkin::get_deg_func())(name, time, parent_0, log_k1, log_k2, g_ilr) -#> Data: "Not shown" -#> Log-likelihood: -238.5635 -#> Fixed: list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1) +
#> Kinetic nonlinear mixed-effects model fit by maximum likelihood +#> +#> Structural model: +#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * +#> time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time))) +#> * parent +#> +#> Data: +#> 90 observations of 1 variable(s) grouped in 5 datasets +#> +#> Log-likelihood: -238.5635 +#> +#> Fixed effects: +#> list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1) #> parent_0 log_k1 log_k2 g_ilr #> 94.17015133 -1.80015306 -4.14738870 0.02290935 #> @@ -284,9 +298,7 @@ with additional elements

#> Structure: Diagonal #> parent_0 log_k1 log_k2 g_ilr Residual #> StdDev: 2.488249 0.8447273 1.32965 0.3289311 2.321364 -#> -#> Number of Observations: 90 -#> Number of Groups: 5
plot(f_nlme_dfop) +#>
plot(f_nlme_dfop)
endpoints(f_nlme_dfop)
#> $distimes #> DT50 DT90 DT50back DT50_k1 DT50_k2 @@ -295,11 +307,18 @@ with additional elements

# \dontrun{ f_nlme_2 <- nlme(f["SFO", ], start = c(parent_0 = 100, log_k_parent = 0.1)) update(f_nlme_2, random = parent_0 ~ 1) -
#> Nonlinear mixed-effects model fit by maximum likelihood -#> Model: value ~ (mkin::get_deg_func())(name, time, parent_0, log_k_parent) -#> Data: "Not shown" -#> Log-likelihood: -404.3729 -#> Fixed: list(parent_0 ~ 1, log_k_parent ~ 1) +
#> Kinetic nonlinear mixed-effects model fit by maximum likelihood +#> +#> Structural model: +#> d_parent/dt = - k_parent * parent +#> +#> Data: +#> observations of 0 variable(s) grouped in 0 datasets +#> +#> Log-likelihood: -404.3729 +#> +#> Fixed effects: +#> list(parent_0 ~ 1, log_k_parent ~ 1) #> parent_0 log_k_parent #> 75.933480 -3.555983 #> @@ -307,9 +326,7 @@ with additional elements

#> Formula: parent_0 ~ 1 | ds #> parent_0 Residual #> StdDev: 0.002416792 21.63027 -#> -#> Number of Observations: 90 -#> Number of Groups: 5
ds_2 <- lapply(experimental_data_for_UBA_2019[6:10], +#>
ds_2 <- lapply(experimental_data_for_UBA_2019[6:10], function(x) x$data[c("name", "time", "value")]) m_sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"), A1 = mkinsub("SFO"), use_of_ff = "min", quiet = TRUE) @@ -395,11 +412,20 @@ with additional elements

AIC(f_nlme_sfo, f_nlme_sfo_tc, f_nlme_dfop, f_nlme_dfop_tc) print(f_nlme_dfop_tc) } -
#> Nonlinear mixed-effects model fit by maximum likelihood -#> Model: value ~ (mkin::get_deg_func())(name, time, parent_0, log_k1, log_k2, g_ilr) -#> Data: "Not shown" -#> Log-likelihood: -238.4298 -#> Fixed: list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1) +
#> Kinetic nonlinear mixed-effects model fit by maximum likelihood +#> +#> Structural model: +#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * +#> time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time))) +#> * parent +#> +#> Data: +#> 90 observations of 1 variable(s) grouped in 5 datasets +#> +#> Log-likelihood: -238.4298 +#> +#> Fixed effects: +#> list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1) #> parent_0 log_k1 log_k2 g_ilr #> 94.04774463 -1.82339924 -4.16715509 0.04020161 #> @@ -415,19 +441,25 @@ with additional elements

#> Formula: ~fitted(.) #> Parameter estimates: #> const prop -#> 2.23222625 0.01262414 -#> Number of Observations: 90 -#> Number of Groups: 5
+#> 2.23222625 0.01262414
f_2_obs <- mmkin(list("SFO-SFO" = m_sfo_sfo, "DFOP-SFO" = m_dfop_sfo), ds_2, quiet = TRUE, error_model = "obs") f_nlme_sfo_sfo_obs <- nlme(f_2_obs["SFO-SFO", ]) print(f_nlme_sfo_sfo_obs) -
#> Nonlinear mixed-effects model fit by maximum likelihood -#> Model: value ~ (mkin::get_deg_func())(name, time, parent_0, log_k_parent_sink, log_k_parent_A1, log_k_A1_sink) -#> Data: "Not shown" -#> Log-likelihood: -472.976 -#> Fixed: list(parent_0 ~ 1, log_k_parent_sink ~ 1, log_k_parent_A1 ~ 1, log_k_A1_sink ~ 1) +
#> Kinetic nonlinear mixed-effects model fit by maximum likelihood +#> +#> Structural model: +#> d_parent/dt = - k_parent_sink * parent - k_parent_A1 * parent +#> d_A1/dt = + k_parent_A1 * parent - k_A1_sink * A1 +#> +#> Data: +#> 170 observations of 2 variable(s) grouped in 5 datasets +#> +#> Log-likelihood: -472.976 +#> +#> Fixed effects: +#> list(parent_0 ~ 1, log_k_parent_sink ~ 1, log_k_parent_A1 ~ 1, log_k_A1_sink ~ 1) #> parent_0 log_k_parent_sink log_k_parent_A1 log_k_A1_sink #> 87.975536 -3.669816 -4.164127 -4.645073 #> @@ -443,9 +475,7 @@ with additional elements

#> Formula: ~1 | name #> Parameter estimates: #> parent A1 -#> 1.0000000 0.2050003 -#> Number of Observations: 170 -#> Number of Groups: 5
# The same with DFOP-SFO does not converge, apparently the variances of +#> 1.0000000 0.2050003
# The same with DFOP-SFO does not converge, apparently the variances of # parent and A1 are too similar in this case, so that the model is # overparameterised #f_nlme_dfop_sfo_obs <- nlme(f_2_obs["DFOP-SFO", ], control = list(maxIter = 100)) diff --git a/docs/dev/reference/plot.nlme.mmkin.html b/docs/dev/reference/plot.nlme.mmkin.html index afd9d8d0..267bef05 100644 --- a/docs/dev/reference/plot.nlme.mmkin.html +++ b/docs/dev/reference/plot.nlme.mmkin.html @@ -214,6 +214,14 @@ predicted values?

Maximum absolute value of the residuals. This is used for the scaling of the y axis and defaults to "auto".

+ + ncol.legend +

Number of columns to use in the legend

+ + + nrow.legend +

Number of rows to use in the legend

+ rel.height.legend

The relative height of the legend shown on top

@@ -259,7 +267,8 @@ corresponding model prediction lines for the different datasets.

names(ds) <- paste0("ds ", 6:10) dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"), A1 = mkinsub("SFO"), quiet = TRUE) -f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE, cores = 1) +# \dontrun{ +f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE) plot(f[, 3:4], standardized = TRUE)
library(nlme) @@ -267,7 +276,8 @@ corresponding model prediction lines for the different datasets.

# tolerance in order to speed up the fit for this example evaluation f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3)) plot(f_nlme) -
+
# } +