diff options
-rw-r--r-- | DESCRIPTION | 2 | ||||
-rw-r--r-- | NEWS.md | 2 | ||||
-rw-r--r-- | R/mkinfit.R | 14 |
3 files changed, 10 insertions, 8 deletions
diff --git a/DESCRIPTION b/DESCRIPTION index 3898f69a..e8b7195d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Type: Package Title: Routines for fitting kinetic models with one or more state variables to chemical degradation data Version: 0.9-33 -Date: 2014-08-19 +Date: 2014-08-20 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de"), person("Katrin", "Lindenberger", role = "ctb"), @@ -8,6 +8,8 @@ - `mkinfit()`: The internally fitted parameter for `g` was named `g_ilr` even when `transform_fractions=FALSE` +- `mkinfit()`: The initial value (state.ini) for the parent compound was not set when the parent was not the (only) variable with the highest value in the observed data. + ## MINOR CHANGES - The formatting of differential equations in the summary was improved by wrapping overly long lines diff --git a/R/mkinfit.R b/R/mkinfit.R index 92c8f8bf..0f488ec8 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -41,11 +41,11 @@ mkinfit <- function(mkinmod, observed, trace_parms = FALSE,
...)
{
- # Check mkinmod and generate a model for the variable whithe the highest value
+ # Check mkinmod and generate a model for the variable whith the highest value
# if a suitable string is given
parent_models_available = c("SFO", "FOMC", "DFOP", "HS", "SFORB")
- presumed_parent_name = observed[which.max(observed$value), "name"]
if (class(mkinmod) != "mkinmod") {
+ presumed_parent_name = observed[which.max(observed$value), "name"]
if (mkinmod[[1]] %in% parent_models_available) {
speclist <- list(list(type = mkinmod, sink = TRUE))
names(speclist) <- presumed_parent_name
@@ -153,14 +153,14 @@ mkinfit <- function(mkinmod, observed, }
# Set default for state.ini if appropriate
+ parent_name = names(mkinmod$spec)[[1]]
if (state.ini[1] == "auto") {
- presumed_parent_time_0 = subset(observed,
- time == 0 & name == presumed_parent_name)$value
- presumed_parent_time_0_mean = mean(presumed_parent_time_0, na.rm = TRUE)
- if (is.na(presumed_parent_time_0_mean)) {
+ parent_time_0 = subset(observed, time == 0 & name == parent_name)$value
+ parent_time_0_mean = mean(parent_time_0, na.rm = TRUE)
+ if (is.na(parent_time_0_mean)) {
state.ini = c(100, rep(0, length(mkinmod$diffs) - 1))
} else {
- state.ini = c(presumed_parent_time_0_mean, rep(0, length(mkinmod$diffs) - 1))
+ state.ini = c(parent_time_0_mean, rep(0, length(mkinmod$diffs) - 1))
}
}
|