From a5874ab7fce4616e80be69366ff0685332f47bf1 Mon Sep 17 00:00:00 2001
From: Johannes Ranke
Create and work with nonlinear mixed models
+Create and work with nonlinear mixed effects models
Plot a fitted nonlinear mixed model obtained via an mmkin row object
Summary method for class "nlme.mmkin"
# S3 method for mmkin -nlme( +nlme( model, data = sys.frame(sys.parent()), fixed, @@ -255,6 +255,11 @@ parameters taken from the mmkin object are usedUpon 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()
andnlme::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#> 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#> $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: 5ds_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.01262414f_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".
Number of columns to use in the legend
Number of rows to use in the legend
The relative height of the legend shown on top