aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DESCRIPTION2
-rw-r--r--NEWS.md4
-rw-r--r--R/mkinfit.R1
-rw-r--r--build.log9
-rw-r--r--tests/testthat/test_FOCUS_chi2_error_level.R45
5 files changed, 32 insertions, 29 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index 0fcc052c..66d22a95 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,7 +2,7 @@ Package: mkin
Type: Package
Title: Kinetic Evaluation of Chemical Degradation Data
Version: 0.9.49.4
-Date: 2019-05-07
+Date: 2019-05-23
Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"),
email = "jranke@uni-bremen.de",
comment = c(ORCID = "0000-0003-4371-6538")),
diff --git a/NEWS.md b/NEWS.md
index f250ceba..7ee35676 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,4 @@
-# mkin 0.9.49.4 (2019-05-08)
+# mkin 0.9.49.4 (2019-05-23)
- Direct minimization of the negative log-likelihood for non-constant error models (two-component and variance by variable). In the case the error model is constant variance, least squares is used as this is more stable
@@ -18,6 +18,8 @@
- Adapt tests
+- Fix an error in the FOCUS chi2 error level calculations that occurred if parameters were specified in parms.ini that were not in the model. A warning was already issued, but when fitting via mmkin this could easily go unnoticed.
+
# mkin 0.9.48.1 (2019-03-04)
- Add the function 'logLik.mkinfit' which makes it possible to calculate an AIC for mkinfit objects
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 5e7b5bd3..bc8b9d11 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -91,6 +91,7 @@ mkinfit <- function(mkinmod, observed,
if (length(wrongpar.names) > 0) {
warning("Initial parameter(s) ", paste(wrongpar.names, collapse = ", "),
" not used in the model")
+ parms.ini <- parms.ini[setdiff(names(parms.ini), wrongpar.names)]
}
# Warn that the sum of formation fractions may exceed one if they are not
diff --git a/build.log b/build.log
index 9728241a..976d27d4 100644
--- a/build.log
+++ b/build.log
@@ -1,10 +1 @@
* checking for file ‘./DESCRIPTION’ ... OK
-* preparing ‘mkin’:
-* checking DESCRIPTION meta-information ... OK
-* installing the package to build vignettes
-* creating vignettes ... OK
-* checking for LF line-endings in source and make files and shell scripts
-* checking for empty or unneeded directories
-* looking to see if a ‘data/datalist’ file should be added
-* building ‘mkin_0.9.49.4.tar.gz’
-
diff --git a/tests/testthat/test_FOCUS_chi2_error_level.R b/tests/testthat/test_FOCUS_chi2_error_level.R
index 69a8c2ad..d7f8d9e7 100644
--- a/tests/testthat/test_FOCUS_chi2_error_level.R
+++ b/tests/testthat/test_FOCUS_chi2_error_level.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2014,2015,2018 Johannes Ranke
+# Copyright (C) 2014,2015,2018,2019 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -16,40 +16,49 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>
-# These tests were migrated from inst/unitTests/runit.mkinerrmin.R
-
context("Calculation of FOCUS chi2 error levels")
SFO_SFO.ff <- mkinmod(parent = list(type = "SFO", to = "m1"),
- m1 = list(type = "SFO"),
+ m1 = list(type = "SFO"),
use_of_ff = "max", quiet = TRUE)
+errmin.FOCUS_2006_D_rounded = data.frame(
+ err.min = c(0.0640, 0.0646, 0.0469),
+ n.optim = c(4, 2, 2),
+ df = c(15, 7, 8),
+ row.names = c("All data", "parent", "m1"))
+
+errmin.FOCUS_2006_E_rounded = data.frame(
+ err.min = c(0.1544, 0.1659, 0.1095),
+ n.optim = c(4, 2, 2),
+ df = c(13, 7, 6),
+ row.names = c("All data", "parent", "m1"))
+
test_that("Chi2 error levels for FOCUS D are as in mkin 0.9-33", {
- fit <- expect_warning(mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE),
+ fit <- expect_warning(mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE),
"Observations with value of zero")
- errmin.FOCUS_2006_D_rounded = data.frame(
- err.min = c(0.0640, 0.0646, 0.0469),
- n.optim = c(4, 2, 2),
- df = c(15, 7, 8),
- row.names = c("All data", "parent", "m1"))
expect_equal(round(mkinerrmin(fit), 4),
errmin.FOCUS_2006_D_rounded)
})
+test_that("Chi2 error levels are independent of setting parms.ini that are not in the model", {
+
+ fit.2 <- expect_warning(mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE,
+ parms.ini = c(tb = 5)),
+ "Observations with value of zero")
+
+ expect_equal(round(mkinerrmin(fit.2), 4),
+ errmin.FOCUS_2006_D_rounded)
+})
+
test_that("Chi2 error levels for FOCUS E are as in mkin 0.9-33", {
skip_on_cran()
- fit <- mkinfit(SFO_SFO.ff, FOCUS_2006_E, quiet = TRUE)
+ fit.3 <- mkinfit(SFO_SFO.ff, FOCUS_2006_E, quiet = TRUE)
- errmin.FOCUS_2006_E_rounded = data.frame(
- err.min = c(0.1544, 0.1659, 0.1095),
- n.optim = c(4, 2, 2),
- df = c(13, 7, 6),
- row.names = c("All data", "parent", "m1"))
-
- expect_equal(round(mkinerrmin(fit), 4),
+ expect_equal(round(mkinerrmin(fit.3), 4),
errmin.FOCUS_2006_E_rounded)
})

Contact - Imprint