aboutsummaryrefslogtreecommitdiff
path: root/man
diff options
context:
space:
mode:
Diffstat (limited to 'man')
-rw-r--r--man/memkin.Rd84
-rw-r--r--man/mkinsub.Rd11
-rw-r--r--man/nlme.Rd134
3 files changed, 140 insertions, 89 deletions
diff --git a/man/memkin.Rd b/man/memkin.Rd
deleted file mode 100644
index 8ae6100a..00000000
--- a/man/memkin.Rd
+++ /dev/null
@@ -1,84 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/memkin.R
-\name{memkin}
-\alias{memkin}
-\title{Estimation of parameter distributions from mmkin row objects}
-\usage{
-memkin(object, random_spec = "auto", ...)
-}
-\arguments{
-\item{object}{An mmkin row object containing several fits of the same model to different datasets}
-
-\item{random_spec}{Either "auto" or a specification of random effects for \code{\link{nlme}}
-given as a character vector}
-
-\item{...}{Additional arguments passed to \code{\link{nlme}}}
-}
-\value{
-An nlme object
-}
-\description{
-This function sets up and attempts to fit a mixed effects model to
-an mmkin row object which is essentially a list of mkinfit objects
-that have been obtained by fitting the same model to a list of
-datasets.
-}
-\examples{
-sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
-m_SFO <- mkinmod(parent = mkinsub("SFO"))
-d_SFO_1 <- mkinpredict(m_SFO,
- c(k_parent_sink = 0.1),
- c(parent = 98), sampling_times)
-d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time")
-d_SFO_2 <- mkinpredict(m_SFO,
- c(k_parent_sink = 0.05),
- c(parent = 102), sampling_times)
-d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time")
-d_SFO_3 <- mkinpredict(m_SFO,
- c(k_parent_sink = 0.02),
- c(parent = 103), sampling_times)
-d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time")
-
-d1 <- add_err(d_SFO_1, function(value) 3, n = 1)
-d2 <- add_err(d_SFO_2, function(value) 2, n = 1)
-d3 <- add_err(d_SFO_3, function(value) 4, n = 1)
-ds <- c(d1 = d1, d2 = d2, d3 = d3)
-
-f <- mmkin("SFO", ds)
-x <- memkin(f)
-summary(x)
-
-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")
-m_sfo_sfo_ff <- mkinmod(parent = mkinsub("SFO", "A1"),
- A1 = mkinsub("SFO"), use_of_ff = "max")
-m_fomc_sfo <- mkinmod(parent = mkinsub("FOMC", "A1"),
- A1 = mkinsub("SFO"))
-m_dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
- A1 = mkinsub("SFO"))
-m_sforb_sfo <- mkinmod(parent = mkinsub("SFORB", "A1"),
- A1 = mkinsub("SFO"))
-
-f_2 <- mmkin(list("SFO-SFO" = m_sfo_sfo,
- "SFO-SFO-ff" = m_sfo_sfo_ff,
- "FOMC-SFO" = m_fomc_sfo,
- "DFOP-SFO" = m_dfop_sfo,
- "SFORB-SFO" = m_sforb_sfo),
- ds_2)
-
-f_nlme_sfo_sfo <- memkin(f_2[1, ])
-f_nlme_sfo_sfo_2 <- memkin(f_2[1, ], "pdDiag(parent_0 + log_k_parent_sink + log_k_parent_A1 + log_k_A1_sink ~ 1)") # explicit
-f_nlme_sfo_sfo_3 <- memkin(f_2[1, ], "pdDiag(parent_0 + log_k_parent_sink + log_k_parent_A1 ~ 1)") # reduced
-f_nlme_sfo_sfo_4 <- memkin(f_2[1, ], "pdDiag(parent_0 + log_k_parent_sink ~ 1)") # further reduced
-\dontrun{
- f_nlme_sfo_sfo_ff <- memkin(f_2[2, ]) # does not converge with maxIter = 50
-}
-f_nlme_fomc_sfo <- memkin(f_2[3, ])
-\dontrun{
- f_nlme_dfop_sfo <- memkin(f_2[4, ]) # apparently underdetermined
- f_nlme_sforb_sfo <- memkin(f_2[5, ]) # also does not converge
-}
-anova(f_nlme_fomc_sfo, f_nlme_sfo_sfo, f_nlme_sfo_sfo_4)
-}
diff --git a/man/mkinsub.Rd b/man/mkinsub.Rd
index 6522a37e..81615a00 100644
--- a/man/mkinsub.Rd
+++ b/man/mkinsub.Rd
@@ -40,11 +40,12 @@ SFO_SFO.2 <- mkinmod(
parent = mkinsub("SFO", "m1"),
m1 = mkinsub("SFO"))
-# Now supplying full names
-SFO_SFO.2 <- mkinmod(
- parent = mkinsub("SFO", "m1", full_name = "Test compound"),
- m1 = mkinsub("SFO", full_name = "Metabolite M1"))
-
+\dontrun{
+ # Now supplying full names
+ SFO_SFO.2 <- mkinmod(
+ parent = mkinsub("SFO", "m1", full_name = "Test compound"),
+ m1 = mkinsub("SFO", full_name = "Metabolite M1"))
+ }
}
\author{
Johannes Ranke
diff --git a/man/nlme.Rd b/man/nlme.Rd
new file mode 100644
index 00000000..e74ba16d
--- /dev/null
+++ b/man/nlme.Rd
@@ -0,0 +1,134 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/nlme.R
+\name{mean_degparms}
+\alias{mean_degparms}
+\alias{nlme_data}
+\alias{nlme_function}
+\title{Estimation of parameter distributions from mmkin row objects}
+\usage{
+mean_degparms(object)
+
+nlme_data(object)
+
+nlme_function(object)
+}
+\arguments{
+\item{object}{An mmkin row object containing several fits of the same model to different datasets}
+}
+\value{
+A named vector containing mean values of the fitted degradation model parameters
+
+A groupedData data object
+
+A function that can be used with nlme
+}
+\description{
+This function sets up and attempts to fit a mixed effects model to
+an mmkin row object. An mmkin row object is essentially a list of mkinfit
+objects that have been obtained by fitting the same model to a list of
+datasets.
+}
+\examples{
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+m_SFO <- mkinmod(parent = mkinsub("SFO"))
+d_SFO_1 <- mkinpredict(m_SFO,
+ c(k_parent_sink = 0.1),
+ c(parent = 98), sampling_times)
+d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time")
+d_SFO_2 <- mkinpredict(m_SFO,
+ c(k_parent_sink = 0.05),
+ c(parent = 102), sampling_times)
+d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time")
+d_SFO_3 <- mkinpredict(m_SFO,
+ c(k_parent_sink = 0.02),
+ c(parent = 103), sampling_times)
+d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time")
+
+d1 <- add_err(d_SFO_1, function(value) 3, n = 1)
+d2 <- add_err(d_SFO_2, function(value) 2, n = 1)
+d3 <- add_err(d_SFO_3, function(value) 4, n = 1)
+ds <- c(d1 = d1, d2 = d2, d3 = d3)
+
+f <- mmkin("SFO", ds, cores = 1, quiet = TRUE)
+mean_dp <- mean_degparms(f)
+grouped_data <- nlme_data(f)
+nlme_f <- nlme_function(f)
+
+library(nlme)
+m_nlme <- nlme(value ~ nlme_f(name, time, parent_0, log_k_parent_sink),
+ data = grouped_data,
+ fixed = parent_0 + log_k_parent_sink ~ 1,
+ random = pdDiag(parent_0 + log_k_parent_sink ~ 1),
+ start = mean_dp)
+summary(m_nlme)
+
+\dontrun{
+ Test on some real data
+ 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")
+ m_sfo_sfo_ff <- mkinmod(parent = mkinsub("SFO", "A1"),
+ A1 = mkinsub("SFO"), use_of_ff = "max")
+ m_fomc_sfo <- mkinmod(parent = mkinsub("FOMC", "A1"),
+ A1 = mkinsub("SFO"))
+ m_dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
+ A1 = mkinsub("SFO"))
+ m_sforb_sfo <- mkinmod(parent = mkinsub("SFORB", "A1"),
+ A1 = mkinsub("SFO"))
+
+ f_2 <- mmkin(list("SFO-SFO" = m_sfo_sfo,
+ "SFO-SFO-ff" = m_sfo_sfo_ff,
+ "FOMC-SFO" = m_fomc_sfo,
+ "DFOP-SFO" = m_dfop_sfo,
+ "SFORB-SFO" = m_sforb_sfo),
+ ds_2)
+
+ grouped_data_2 <- nlme_data(f_2["SFO-SFO", ])
+
+ mean_dp_sfo_sfo <- mean_degparms(f_2["SFO-SFO", ])
+ mean_dp_sfo_sfo_ff <- mean_degparms(f_2["SFO-SFO-ff", ])
+ mean_dp_fomc_sfo <- mean_degparms(f_2["FOMC-SFO", ])
+ mean_dp_dfop_sfo <- mean_degparms(f_2["DFOP-SFO", ])
+ mean_dp_sforb_sfo <- mean_degparms(f_2["SFORB-SFO", ])
+
+ nlme_f_sfo_sfo <- nlme_function(f_2["SFO-SFO", ])
+ nlme_f_sfo_sfo_ff <- nlme_function(f_2["SFO-SFO-ff", ])
+ nlme_f_fomc_sfo <- nlme_function(f_2["FOMC-SFO", ])
+
+ # Allowing for correlations between random effects leads to non-convergence
+ f_nlme_sfo_sfo <- nlme(value ~ nlme_f_sfo_sfo(name, time,
+ parent_0, log_k_parent_sink, log_k_parent_A1, log_k_A1_sink),
+ data = grouped_data_2,
+ fixed = parent_0 + log_k_parent_sink + log_k_parent_A1 + log_k_A1_sink ~ 1,
+ random = pdDiag(parent_0 + log_k_parent_sink + log_k_parent_A1 + log_k_A1_sink ~ 1),
+ start = mean_dp_sfo_sfo)
+
+ # The same model fitted with transformed formation fractions does not converge
+ f_nlme_sfo_sfo_ff <- nlme(value ~ nlme_f_sfo_sfo_ff(name, time,
+ parent_0, log_k_parent, log_k_A1, f_parent_ilr_1),
+ data = grouped_data_2,
+ fixed = parent_0 + log_k_parent + log_k_A1 + f_parent_ilr_1 ~ 1,
+ random = pdDiag(parent_0 + log_k_parent + log_k_A1 + f_parent_ilr_1 ~ 1),
+ start = mean_dp_sfo_sfo_ff)
+
+ # It does converge with this version of reduced random effects
+ f_nlme_sfo_sfo_ff <- nlme(value ~ nlme_f_sfo_sfo_ff(name, time,
+ parent_0, log_k_parent, log_k_A1, f_parent_ilr_1),
+ data = grouped_data_2,
+ fixed = parent_0 + log_k_parent + log_k_A1 + f_parent_ilr_1 ~ 1,
+ random = pdDiag(parent_0 + log_k_parent ~ 1),
+ start = mean_dp_sfo_sfo_ff)
+
+ f_nlme_fomc_sfo <- nlme(value ~ nlme_f_fomc_sfo(name, time,
+ parent_0, log_alpha, log_beta, log_k_A1, f_parent_ilr_1),
+ data = grouped_data_2,
+ fixed = parent_0 + log_alpha + log_beta + log_k_A1 + f_parent_ilr_1 ~ 1,
+ random = pdDiag(parent_0 + log_alpha + log_beta + log_k_A1 + f_parent_ilr_1 ~ 1),
+ start = mean_dp_fomc_sfo)
+
+ # DFOP-SFO and SFORB-SFO did not converge with full random effects
+
+ anova(f_nlme_fomc_sfo, f_nlme_sfo_sfo)
+}
+}

Contact - Imprint