diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-05-23 19:19:27 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-05-23 19:19:27 +0200 |
commit | db472848915a8065347b8f81477a86928b89fbcf (patch) | |
tree | ffb55c76d96d2b83677064bd01317c8f9fba1875 /tests | |
parent | 84abde72967691d82bbad66eeff4d1ab161530dd (diff) |
Fix a bug that could lead to wrong chi2 error levels
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testthat/test_FOCUS_chi2_error_level.R | 45 |
1 files changed, 27 insertions, 18 deletions
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) }) |