aboutsummaryrefslogtreecommitdiff
path: root/man
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-05-29 16:05:11 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2020-05-29 16:05:11 +0200
commite6f9e9ca89e35e610d9895b979f1351a47451db0 (patch)
treedd9d389c05e35db7a86abd578751199cd2c6a1be /man
parent510436646b1bdd5b8cfab70be29334bd3cc9c828 (diff)
Improve handling of warnings, reorganize tests
Diffstat (limited to 'man')
-rw-r--r--man/mkinfit.Rd65
1 files changed, 65 insertions, 0 deletions
diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 748dcb50..7f5092c5 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -214,6 +214,71 @@ When using the "IORE" submodel for metabolites, fitting with
numerical ODE solver. In this situation it may help to switch off the
internal rate transformation.
}
+\examples{
+
+# Use shorthand notation for parent only degradation
+fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+summary(fit)
+
+# One parent compound, one metabolite, both single first order.
+# We remove zero values from FOCUS dataset D in order to avoid warnings
+FOCUS_D <- subset(FOCUS_2006_D, value != 0)
+# Use mkinsub for convenience in model formulation. Pathway to sink included per default.
+SFO_SFO <- mkinmod(
+ parent = mkinsub("SFO", "m1"),
+ m1 = mkinsub("SFO"))
+
+# Fit the model quietly to the FOCUS example dataset D using defaults
+fit <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE)
+# Since mkin 0.9.50.3, we get a warning about non-normality of residuals,
+# so we try an alternative error model
+fit.tc <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc")
+# This avoids the warning, and the likelihood ratio test confirms it is preferable
+lrtest(fit.tc, fit)
+# We can also allow for different variances of parent and metabolite as error model
+fit.obs <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "obs")
+# This also avoids the warning about non-normality, but the two-component error model
+# has significantly higher likelihood
+lrtest(fit.obs, fit.tc)
+parms(fit.tc)
+endpoints(fit.tc)
+
+# We can show a quick (only one replication) benchmark for this case, as we
+# have several alternative solution methods for the model. We skip
+# uncompiled deSolve, as it is so slow. More benchmarks are found in the
+# benchmark vignette
+\dontrun{
+if(require(rbenchmark)) {
+ benchmark(replications = 1, order = "relative", columns = c("test", "relative", "elapsed"),
+ deSolve_compiled = mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc",
+ solution_type = "deSolve", use_compiled = TRUE),
+ eigen = mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc",
+ solution_type = "eigen"),
+ analytical = mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc",
+ solution_type = "analytical"))
+}
+}
+
+# Use stepwise fitting, using optimised parameters from parent only fit, FOMC-SFO
+\dontrun{
+FOMC_SFO <- mkinmod(
+ parent = mkinsub("FOMC", "m1"),
+ m1 = mkinsub("SFO"))
+fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE)
+# Again, we get a warning and try a more sophisticated error model
+fit.FOMC_SFO.tc <- mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE, error_model = "tc")
+# This model has a higher likelihood, but not significantly so
+lrtest(fit.tc, fit.FOMC_SFO.tc)
+# Also, the missing standard error for log_beta and the t-tests for alpha
+# and beta indicate overparameterisation
+summary(fit.FOMC_SFO.tc, data = FALSE)
+
+# We can easily use starting parameters from the parent only fit (only for illustration)
+fit.FOMC = mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE, error_model = "tc")
+fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE,
+ parms.ini = fit.FOMC$bparms.ode, error_model = "tc")
+}
+}
\references{
Rocke DM and Lorenzato S (1995) A two-component model
for measurement error in analytical chemistry. \emph{Technometrics} 37(2), 176-184.

Contact - Imprint