From 575fcacaa33076de97f41a79afb37efb97ca82e0 Mon Sep 17 00:00:00 2001
From: Johannes Ranke
# S3 method for mmkin -plot(x, main = "auto", legends = 1, - resplot = c("time", "errmod"), show_errmin = TRUE, - errmin_var = "All data", errmin_digits = 3, cex = 0.7, - rel.height.middle = 0.9, ymax = "auto", ...)+plot( + x, + main = "auto", + legends = 1, + resplot = c("time", "errmod"), + show_errmin = TRUE, + errmin_var = "All data", + errmin_digits = 3, + cex = 0.7, + rel.height.middle = 0.9, + ymax = "auto", + ... +)
Should the residuals plotted against time, using
|
+
+ |
| standardized | +Should the residuals be standardized? This option
+is passed to |
|---|---|
| show_errmin | diff --git a/man/endpoints.Rd b/man/endpoints.Rd index 13182369..be180737 100644 --- a/man/endpoints.Rd +++ b/man/endpoints.Rd @@ -26,7 +26,7 @@ The function is used internally by \code{\link{summary.mkinfit}}. \examples{ fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) - endpoints(fit) + endpoints(fit) } \author{ diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd index f14e0362..982e8db6 100644 --- a/man/plot.mmkin.Rd +++ b/man/plot.mmkin.Rd @@ -10,6 +10,7 @@ of an mmkin object} main = "auto", legends = 1, resplot = c("time", "errmod"), + standardized = FALSE, show_errmin = TRUE, errmin_var = "All data", errmin_digits = 3, @@ -31,6 +32,10 @@ column.} \code{\link{mkinresplot}}, or as squared residuals against predicted values, with the error model, using \code{\link{mkinerrplot}}.} +\item{standardized}{Should the residuals be standardized? This option +is passed to \code{\link{mkinresplot}}, it only takes effect if +`resplot = "time"`.} + \item{show_errmin}{Should the chi2 error level be shown on top of the plots to the left?} diff --git a/test.log b/test.log index 77130814..84b13a10 100644 --- a/test.log +++ b/test.log @@ -2,35 +2,35 @@ Loading mkin Testing mkin ✔ | OK F W S | Context ✔ | 2 | Export dataset for reading into CAKE -✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.7 s] -✔ | 4 | Calculation of FOCUS chi2 error levels [2.3 s] -✔ | 4 | Fitting the SFORB model [1.8 s] +✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.5 s] +✔ | 4 | Calculation of FOCUS chi2 error levels [2.2 s] +✔ | 4 | Fitting the SFORB model [1.7 s] ✔ | 5 | Calculation of Akaike weights -✔ | 10 | Confidence intervals and p-values [10.7 s] -✔ | 14 | Error model fitting [42.8 s] -✔ | 6 | Test fitting the decline of metabolites from their maximum [0.8 s] -✔ | 1 | Fitting the logistic model [1.0 s] +✔ | 10 | Confidence intervals and p-values [9.6 s] +✔ | 14 | Error model fitting [38.4 s] +✔ | 6 | Test fitting the decline of metabolites from their maximum [0.7 s] +✔ | 1 | Fitting the logistic model [0.9 s] ✔ | 1 | Test dataset class mkinds used in gmkin -✔ | 12 | Special cases of mkinfit calls [2.5 s] +✔ | 12 | Special cases of mkinfit calls [2.2 s] ✔ | 9 | mkinmod model generation and printing [0.2 s] -✔ | 3 | Model predictions with mkinpredict [0.4 s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.4 s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3 s] +✔ | 3 | Model predictions with mkinpredict [0.3 s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.2 s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2 s] ✔ | 3 | Summary ✔ | 11 | Plotting [0.6 s] ✔ | 4 | AIC calculation ✔ | 2 | Residuals extracted from mkinfit models -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.7 s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] ✔ | 1 | Summaries of old mkinfit objects -✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.7 s] -✔ | 7 1 | Hypothesis tests [35.7 s] +✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.1 s] +✔ | 7 1 | Hypothesis tests [32.5 s] ──────────────────────────────────────────────────────────────────────────────── test_tests.R:60: skip: We can do a likelihood ratio test using an update specification Reason: This errors out if called by testthat while it works in a normal R session ──────────────────────────────────────────────────────────────────────────────── ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 123.0 s +Duration: 112.1 s OK: 138 Failed: 0 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index a7f8edaf..fe5e481a 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2020-03-31 +Date: 2020-04-01 Optimiser: IRLS [Data] diff --git a/vignettes/web_only/FOCUS_Z.R b/vignettes/web_only/FOCUS_Z.R new file mode 100644 index 00000000..0c19794e --- /dev/null +++ b/vignettes/web_only/FOCUS_Z.R @@ -0,0 +1,115 @@ +## ---- include = FALSE--------------------------------------------------------- +require(knitr) +options(digits = 5) +opts_chunk$set(engine='R', tidy = FALSE) + +## ---- echo = TRUE, fig = TRUE, fig.width = 8, fig.height = 7------------------ +library(mkin, quietly = TRUE) +LOD = 0.5 +FOCUS_2006_Z = data.frame( + t = c(0, 0.04, 0.125, 0.29, 0.54, 1, 2, 3, 4, 7, 10, 14, 21, + 42, 61, 96, 124), + Z0 = c(100, 81.7, 70.4, 51.1, 41.2, 6.6, 4.6, 3.9, 4.6, 4.3, 6.8, + 2.9, 3.5, 5.3, 4.4, 1.2, 0.7), + Z1 = c(0, 18.3, 29.6, 46.3, 55.1, 65.7, 39.1, 36, 15.3, 5.6, 1.1, + 1.6, 0.6, 0.5 * LOD, NA, NA, NA), + Z2 = c(0, NA, 0.5 * LOD, 2.6, 3.8, 15.3, 37.2, 31.7, 35.6, 14.5, + 0.8, 2.1, 1.9, 0.5 * LOD, NA, NA, NA), + Z3 = c(0, NA, NA, NA, NA, 0.5 * LOD, 9.2, 13.1, 22.3, 28.4, 32.5, + 25.2, 17.2, 4.8, 4.5, 2.8, 4.4)) + +FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z) + +## ----FOCUS_2006_Z_fits_1, echo=TRUE, fig.height=6----------------------------- +Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"), + Z1 = mkinsub("SFO")) +m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.2a) +summary(m.Z.2a, data = FALSE)$bpar + +## ----FOCUS_2006_Z_fits_2, echo=TRUE, fig.height=6----------------------------- +Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"), + Z1 = mkinsub("SFO"), + use_of_ff = "max") + +m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.2a.ff) +summary(m.Z.2a.ff, data = FALSE)$bpar + +## ----FOCUS_2006_Z_fits_3, echo=TRUE, fig.height=6----------------------------- +Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO"), use_of_ff = "max") +m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.3) +summary(m.Z.3, data = FALSE)$bpar + +## ----FOCUS_2006_Z_fits_5, echo=TRUE, fig.height=7----------------------------- +Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO"), use_of_ff = "max") +m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.5) + +## ----FOCUS_2006_Z_fits_6, echo=TRUE, fig.height=8----------------------------- +Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFO"), + use_of_ff = "max") +m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, + parms.ini = m.Z.5$bparms.ode, + quiet = TRUE) +plot_sep(m.Z.FOCUS) +summary(m.Z.FOCUS, data = FALSE)$bpar +endpoints(m.Z.FOCUS) + +## ----FOCUS_2006_Z_fits_7, echo=TRUE, fig.height=8----------------------------- +Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFORB")) +m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.mkin.1) +summary(m.Z.mkin.1, data = FALSE)$cov.unscaled + +## ----FOCUS_2006_Z_fits_9, echo=TRUE, fig.height=8----------------------------- +Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO")) +m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.mkin.3) + +## ----FOCUS_2006_Z_fits_10, echo=TRUE, fig.height=8---------------------------- +Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFO")) +m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin, + parms.ini = m.Z.mkin.3$bparms.ode, + quiet = TRUE) +plot_sep(m.Z.mkin.4) + +## ----FOCUS_2006_Z_fits_11, echo=TRUE, fig.height=8---------------------------- +Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFORB")) +m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, + parms.ini = m.Z.mkin.4$bparms.ode[1:4], + quiet = TRUE) +plot_sep(m.Z.mkin.5) + +## ----FOCUS_2006_Z_fits_11a, echo=TRUE----------------------------------------- +m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, + parms.ini = c(m.Z.mkin.5$bparms.ode[1:7], + k_Z3_bound_free = 0), + fixed_parms = "k_Z3_bound_free", + quiet = TRUE) +plot_sep(m.Z.mkin.5a) + +## ----FOCUS_2006_Z_fits_11b, echo=TRUE----------------------------------------- +mkinparplot(m.Z.mkin.5a) + +## ----FOCUS_2006_Z_fits_11b_endpoints, echo=TRUE------------------------------- +endpoints(m.Z.mkin.5a) + diff --git a/vignettes/web_only/FOCUS_Z.html b/vignettes/web_only/FOCUS_Z.html index d7f0f88c..e8e6e2b4 100644 --- a/vignettes/web_only/FOCUS_Z.html +++ b/vignettes/web_only/FOCUS_Z.html @@ -1,17 +1,17 @@ - + - + - +