diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2016-06-27 13:21:39 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2016-06-27 13:38:38 +0200 |
commit | 4b0b5346a9f026c5a19d452e4649326fe56d464c (patch) | |
tree | 2795eb7eaf6f68dfd6fbbcb8a3cf92224cf81f0d | |
parent | b14fe21e176f523e800793102fb5634e468b3165 (diff) |
Improve listing of weights in output, update NEWS
-rw-r--r-- | NEWS.md | 8 | ||||
-rw-r--r-- | R/mkinfit.R | 8 | ||||
-rw-r--r-- | man/add_err.Rd | 7 | ||||
-rw-r--r-- | man/mkinfit.Rd | 11 |
4 files changed, 23 insertions, 11 deletions
@@ -8,6 +8,8 @@ - `plot.mkinfit`: Add the possibility to show fits (and residual plots if requested) separately for the observed variables +- `plot.mkinfit`: Add the possibility to show the chi2 error levels in the plot, similar to the way they are shown in `plot.mmkin` + - The main vignette `mkin` was converted to R markdown and updated - The function `add_err` was added to the package, making it easy to generate simulated data using an error model based on the normal distribution @@ -22,13 +24,17 @@ - A test has been added to containing a corresponding edge case to check that the warnings are correctly issued and the fit does not terminate. +- `plot.mmkin`: Round the chi2 error value to three significant digits, instead of two decimal digits. + +- `mkinfit`: Return the `err` values used on weighted fits as a column named `err`. Also include these inverse weights when the column `value` in the observed data is used, which is returned as `observed` in the data component of the mkinfit object. + ### Bug fixes - `endpoints`: When the name of a substance degrading to a metabolite (e.g. a parent compound) used in the model formulation ended in the letter `f`, some rate parameters could be listed as formation fractions with mixed up names. These would also appear in the summary. - `mkinfit`: Check for all observed variables when checking if the user tried to fix formation fractions when fitting them using ilr transformation. -- `plot.mmkin`: Removed some leftover code that set the plot margins wrongly in the case of a single fit to be plotted, so the main title was misplaced. +- `plot.mmkin`: Set the plot margins correctly, also in the case of a single fit to be plotted, so the main title is placed in a reasonable way. - `plot.mkinfit`: Correct default values for `col_obs`, `pch_obs` and `lty_obs` for the case that `obs_vars` is specified. diff --git a/R/mkinfit.R b/R/mkinfit.R index c6b6915c..4c4a9717 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -513,13 +513,19 @@ mkinfit <- function(mkinmod, observed, data$name <- ordered(data$name, levels = obs_vars)
data <- data[order(data$name, data$time), ]
+ # Add a column named "value" holding the observed values for the case
+ # that this column was selected for manual weighting, so it can be
+ # shown in the summary as "err"
+ data$value <- data$value.x
+
fit$data <- data.frame(time = data$time,
variable = data$name,
observed = data$value.x,
predicted = data$value.y)
+
fit$data$residual <- fit$data$observed - fit$data$predicted
if (!is.null(data$err.ini)) fit$data$err.ini <- data$err.ini
- if (!is.null(err)) fit$data[[err]] <- data[[err]]
+ if (!is.null(err)) fit$data[["err"]] <- data[[err]]
fit$atol <- atol
fit$rtol <- rtol
diff --git a/man/add_err.Rd b/man/add_err.Rd index a0a5106f..a0068b59 100644 --- a/man/add_err.Rd +++ b/man/add_err.Rd @@ -76,11 +76,12 @@ d_SFO_SFO_err <- add_err(d_SFO_SFO, function(x) 10, n = 3, seed = 123456789 ) names(d_SFO_SFO_err) <- paste("Dataset", 1:3) # Name the model in the list of models (with only one member in this case) -# for nicer plotting later on +# for nicer plotting later on. # Be quiet and use the faster Levenberg-Marquardt algorithm, as the datasets -# are easy and examples are run often +# are easy and examples are run often. Use only one core not to offend CRAN +# checks f_SFO_SFO <- mmkin(list("SFO-SFO" = m_SFO_SFO), - d_SFO_SFO_err, + d_SFO_SFO_err, cores = 1, quiet = TRUE, method.modFit = "Marq") plot(f_SFO_SFO) diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index e4041755..db2f7fda 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -51,9 +51,9 @@ mkinfit(mkinmod, observed, name of the observed variable for each data point. The second column must contain the times of observation, named "time". The third column must be named "value" and contain the observed values. Optionally, a further column - can contain weights for each data point. If it is not named "err", its name - must be passed as a further argument named \code{err} which is then passed - on to \code{\link{modFit}}. + can contain weights for each data point. Its name must be passed as a + further argument named \code{err} which is then passed on to + \code{\link{modFit}}. } \item{parms.ini}{ A named vector of initial values for the parameters, including parameters @@ -303,9 +303,8 @@ f.irls <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, reweight.method = "obs") summary(f.irls) f.w.mean <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, weight = "mean") summary(f.w.mean) -f.w.mean.irls <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, weight = "mean", - reweight.method = "obs") -summary(f.w.mean.irls) +f.w.value <- mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), err = "value") +summary(f.w.value) } \dontrun{ |