From ead1f286271923f57d83aed41cb34181a10773ef Mon Sep 17 00:00:00 2001
From: Johannes Ranke
Date: Tue, 5 Nov 2019 00:05:34 +0100
Subject: Fix standardized residual plots in 'plot_res'
---
R/plot.mkinfit.R | 8 +++++---
docs/reference/plot.mkinfit-3.png | Bin 62528 -> 57593 bytes
docs/reference/plot.mkinfit.html | 9 +++++----
man/plot.mkinfit.Rd | 7 ++++---
test.log | 4 ++--
tests/testthat/FOCUS_2006_D.csf | 2 +-
6 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R
index e0b3ad13..4b5bfa3a 100644
--- a/R/plot.mkinfit.R
+++ b/R/plot.mkinfit.R
@@ -33,7 +33,8 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("type", "variable", "obse
#' to the right of the plots of the fitted curves. If this is set to
#' 'standardized', a plot of the residuals divided by the standard deviation
#' given by the fitted error model will be shown.
-#' @param standardized For
+#' @param standardized When calling 'plot_res', should the residuals be
+#' standardized in the residual plot?
#' @param show_errplot Should squared residuals and the error model be shown?
#' If only one plot of the fits is shown, this plot is in the lower third of
#' the plot. Otherwise, i.e. if "sep_obs" is given, the residual plots will
@@ -298,10 +299,11 @@ plot_sep <- function(fit, show_errmin = TRUE,
#' @rdname plot.mkinfit
#' @export
plot_res <- function(fit, sep_obs = FALSE, show_errmin = sep_obs,
- show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE, "standardized"), ...)
+ standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE), ...)
{
plot.mkinfit(fit, sep_obs = sep_obs, show_errmin = show_errmin,
- show_residuals = show_residuals, row_layout = TRUE, ...)
+ show_residuals = ifelse(standardized, "standardized", TRUE),
+ row_layout = TRUE, ...)
}
#' @rdname plot.mkinfit
diff --git a/docs/reference/plot.mkinfit-3.png b/docs/reference/plot.mkinfit-3.png
index 72bc331e..6910ae47 100644
Binary files a/docs/reference/plot.mkinfit-3.png and b/docs/reference/plot.mkinfit-3.png differ
diff --git a/docs/reference/plot.mkinfit.html b/docs/reference/plot.mkinfit.html
index a3b912bb..8dc21b06 100644
--- a/docs/reference/plot.mkinfit.html
+++ b/docs/reference/plot.mkinfit.html
@@ -155,8 +155,8 @@ observed data together with the solution of the fitted model.
"standardized"), ...)
plot_res(fit, sep_obs = FALSE, show_errmin = sep_obs,
- show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE,
- "standardized"), ...)
+ standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE),
+ ...)
plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...)
@@ -282,7 +282,8 @@ chi2 error percentage.
standardized |
- For |
+ When calling 'plot_res', should the residuals be
+standardized in the residual plot? |
@@ -301,7 +302,7 @@ latex is being used for the formatting of the chi2 error level, if
# parent to sink included
# \dontrun{
SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"),
- m1 = mkinsub("SFO", full = "Metabolite M1" ))#> Successfully compiled differential equation model from auto-generated C code.
#> Warning: Observations with value of zero were removed from the data
plot_res(fit)
plot_res(fit, standardized = FALSE)
#> Warning: "standardized" ist kein Grafikparameter
#> Warning: "standardized" ist kein Grafikparameter
#> Warning: "standardized" ist kein Grafikparameter
#> Warning: "standardized" ist kein Grafikparameter
#> Warning: "standardized" ist kein Grafikparameter
#> Warning: "standardized" ist kein Grafikparameter
plot_err(fit)
#> Successfully compiled differential equation model from auto-generated C code.
#> Warning: Observations with value of zero were removed from the data
plot_res(fit)
plot_res(fit, standardized = FALSE)
plot_err(fit)


diff --git a/man/plot.mkinfit.Rd b/man/plot.mkinfit.Rd
index 6824f8a5..47cc08a4 100644
--- a/man/plot.mkinfit.Rd
+++ b/man/plot.mkinfit.Rd
@@ -21,8 +21,8 @@ plot_sep(fit, show_errmin = TRUE,
"standardized"), ...)
plot_res(fit, sep_obs = FALSE, show_errmin = sep_obs,
- show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE,
- "standardized"), ...)
+ standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE),
+ ...)
plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...)
}
@@ -96,7 +96,8 @@ chi2 error percentage.}
\item{\dots}{Further arguments passed to \code{\link{plot}}.}
-\item{standardized}{For}
+\item{standardized}{When calling 'plot_res', should the residuals be
+standardized in the residual plot?}
}
\value{
The function is called for its side effect.
diff --git a/test.log b/test.log
index f0f09d41..806c72b3 100644
--- a/test.log
+++ b/test.log
@@ -3,7 +3,7 @@ Testing mkin
✔ | OK F W S | Context
✔ | 2 | Export dataset for reading into CAKE
✔ | 10 | Confidence intervals and p-values [9.7 s]
-✔ | 14 | Error model fitting [36.6 s]
+✔ | 14 | Error model fitting [36.5 s]
✔ | 4 | Calculation of FOCUS chi2 error levels [2.2 s]
✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.3 s]
✔ | 6 | Test fitting the decline of metabolites from their maximum [0.7 s]
@@ -18,7 +18,7 @@ Testing mkin
✔ | 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.2 s]
+✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s]
✔ | 4 | Fitting the SFORB model [1.7 s]
✔ | 1 | Summaries of old mkinfit objects
✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.1 s]
diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf
index d5d807ab..528e2b61 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: 2019-11-04
+Date: 2019-11-05
Optimiser: IRLS
[Data]
--
cgit v1.2.1