aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-11-05 00:05:34 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2019-11-05 00:05:34 +0100
commitead1f286271923f57d83aed41cb34181a10773ef (patch)
tree86335c3b59ddd93d51bb18e326543fa957983912
parentaa5aeeb5d55017774eff1066a495df59b97ca233 (diff)
Fix standardized residual plots in 'plot_res'
-rw-r--r--R/plot.mkinfit.R8
-rw-r--r--docs/reference/plot.mkinfit-3.pngbin62528 -> 57593 bytes
-rw-r--r--docs/reference/plot.mkinfit.html9
-rw-r--r--man/plot.mkinfit.Rd7
-rw-r--r--test.log4
-rw-r--r--tests/testthat/FOCUS_2006_D.csf2
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
--- a/docs/reference/plot.mkinfit-3.png
+++ b/docs/reference/plot.mkinfit-3.png
Binary files 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.</p>
<span class='st'>"standardized"</span>), <span class='no'>...</span>)
<span class='fu'>plot_res</span>(<span class='no'>fit</span>, <span class='kw'>sep_obs</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>show_errmin</span> <span class='kw'>=</span> <span class='no'>sep_obs</span>,
- <span class='kw'>show_residuals</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/ifelse.html'>ifelse</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/identical.html'>identical</a></span>(<span class='no'>fit</span>$<span class='no'>err_mod</span>, <span class='st'>"const"</span>), <span class='fl'>TRUE</span>,
- <span class='st'>"standardized"</span>), <span class='no'>...</span>)
+ <span class='kw'>standardized</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/ifelse.html'>ifelse</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/identical.html'>identical</a></span>(<span class='no'>fit</span>$<span class='no'>err_mod</span>, <span class='st'>"const"</span>), <span class='fl'>FALSE</span>, <span class='fl'>TRUE</span>),
+ <span class='no'>...</span>)
<span class='fu'>plot_err</span>(<span class='no'>fit</span>, <span class='kw'>sep_obs</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>show_errmin</span> <span class='kw'>=</span> <span class='no'>sep_obs</span>, <span class='no'>...</span>)</pre>
@@ -282,7 +282,8 @@ chi2 error percentage.</p></td>
</tr>
<tr>
<th>standardized</th>
- <td><p>For</p></td>
+ <td><p>When calling 'plot_res', should the residuals be
+standardized in the residual plot?</p></td>
</tr>
</table>
@@ -301,7 +302,7 @@ latex is being used for the formatting of the chi2 error level, if
<span class='co'># parent to sink included</span>
<span class='co'># \dontrun{</span>
<span class='no'>SFO_SFO</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>, <span class='kw'>full</span> <span class='kw'>=</span> <span class='st'>"Parent"</span>),
- <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='kw'>full</span> <span class='kw'>=</span> <span class='st'>"Metabolite M1"</span> ))</div><div class='output co'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinfit.html'>mkinfit</a></span>(<span class='no'>SFO_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>error_model</span> <span class='kw'>=</span> <span class='st'>"tc"</span>)</div><div class='output co'>#&gt; <span class='warning'>Warning: Observations with value of zero were removed from the data</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>fit</span>)</div><div class='img'><img src='plot.mkinfit-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'>plot_res</span>(<span class='no'>fit</span>)</div><div class='img'><img src='plot.mkinfit-2.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'>plot_res</span>(<span class='no'>fit</span>, <span class='kw'>standardized</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt; <span class='warning'>Warning: "standardized" ist kein Grafikparameter</span></div><div class='output co'>#&gt; <span class='warning'>Warning: "standardized" ist kein Grafikparameter</span></div><div class='output co'>#&gt; <span class='warning'>Warning: "standardized" ist kein Grafikparameter</span></div><div class='output co'>#&gt; <span class='warning'>Warning: "standardized" ist kein Grafikparameter</span></div><div class='output co'>#&gt; <span class='warning'>Warning: "standardized" ist kein Grafikparameter</span></div><div class='output co'>#&gt; <span class='warning'>Warning: "standardized" ist kein Grafikparameter</span></div><div class='img'><img src='plot.mkinfit-3.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'>plot_err</span>(<span class='no'>fit</span>)</div><div class='img'><img src='plot.mkinfit-4.png' alt='' width='700' height='433' /></div><div class='input'>
+ <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='kw'>full</span> <span class='kw'>=</span> <span class='st'>"Metabolite M1"</span> ))</div><div class='output co'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinfit.html'>mkinfit</a></span>(<span class='no'>SFO_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>error_model</span> <span class='kw'>=</span> <span class='st'>"tc"</span>)</div><div class='output co'>#&gt; <span class='warning'>Warning: Observations with value of zero were removed from the data</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>fit</span>)</div><div class='img'><img src='plot.mkinfit-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'>plot_res</span>(<span class='no'>fit</span>)</div><div class='img'><img src='plot.mkinfit-2.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'>plot_res</span>(<span class='no'>fit</span>, <span class='kw'>standardized</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='img'><img src='plot.mkinfit-3.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'>plot_err</span>(<span class='no'>fit</span>)</div><div class='img'><img src='plot.mkinfit-4.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># Show the observed variables separately, with residuals</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>fit</span>, <span class='kw'>sep_obs</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>show_residuals</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>lpos</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"topright"</span>, <span class='st'>"bottomright"</span>),
<span class='kw'>show_errmin</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='img'><img src='plot.mkinfit-5.png' alt='' width='700' height='433' /></div><div class='input'>
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]

Contact - Imprint