aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2016-04-21 17:34:38 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2016-04-21 17:37:54 +0200
commit0b36fb666b84321814eabbc1a25687ee70d789e6 (patch)
treec2cecc577993eb641504b6c2d2f1c82b59ece744 /tests/testthat
parentae5e2bf30393a1a97dcc2da4f8e8fd7be7028117 (diff)
Avoid unnecessary stop in edge case, improve warnings
mkinfit: Do not error out in cases where the fit converges, but the Jacobian for the untransformed model cost can not be estimated. Give a warning instead and return NA for the t-test results. summary.mkinfit: Give a warning message when the covariance matrix can not be obtained. A test has been added to containing such an edge case to check that the warnings are correctly issued and the fit does not terminate.
Diffstat (limited to 'tests/testthat')
-rw-r--r--tests/testthat/test_FOMC_ill-defined.R42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/testthat/test_FOMC_ill-defined.R b/tests/testthat/test_FOMC_ill-defined.R
new file mode 100644
index 00000000..b036a0af
--- /dev/null
+++ b/tests/testthat/test_FOMC_ill-defined.R
@@ -0,0 +1,42 @@
+# Copyright (C) 2016 Johannes Ranke
+# Contact: jranke@uni-bremen.de
+
+# This file is part of the R package mkin
+
+# mkin is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>
+
+context("Fitting the FOMC model with large parameter correlation")
+
+# Dataset that I ran across during my work and for which the calculation of the
+# Jacobian failed. Data were slightly fuzzed.
+FOMC_test <- data.frame(
+ name = "test_compound",
+ time = c(0, 14, 31, 59, 91),
+ value = c(45.8, 28.0, 28.5, 35.1, 35.6))
+
+test_that("Fitting with large parameter correlation gives warnings", {
+
+ # When fitting from the maximum, the Port algorithm does not converge (with
+ # default settings)
+ expect_warning(
+ fit.FOMC.Port <- mkinfit("FOMC", FOMC_test, method.modFit = "Port"),
+ "Optimisation by method Port did not converge")
+
+ # When we use Levenberg-Marquardt, we get a problem estimating the Jacobian
+ # for the untransformed model
+ expect_warning(
+ fit.FOMC.Marq <- mkinfit("FOMC", FOMC_test, method.modFit = "Marq"),
+ "Calculation of the Jacobian failed for the cost function of the untransformed model")
+
+})

Contact - Imprint