aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2018-02-06 17:15:22 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2018-02-06 17:15:22 +0100
commit9cb1cebc1dcb85b1474b560210bf3939c0dc8da0 (patch)
treec4481a97689dc0a7087bdb8724f0a1867440ef45 /tests/testthat
parent6dd10cb60c040e1c74e2bc109094fe3217ed7df6 (diff)
Skip some tests on CRAN, more quiet examplesv0.9.47.1
Diffstat (limited to 'tests/testthat')
-rw-r--r--tests/testthat/test_irls.R2
-rw-r--r--tests/testthat/test_schaefer07_complex_case.R26
-rw-r--r--tests/testthat/test_synthetic_data_for_UBA_2014.R49
3 files changed, 37 insertions, 40 deletions
diff --git a/tests/testthat/test_irls.R b/tests/testthat/test_irls.R
index 0b005182..6389b662 100644
--- a/tests/testthat/test_irls.R
+++ b/tests/testthat/test_irls.R
@@ -34,12 +34,14 @@ SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data
DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
test_that("Reweighting method 'obs' works", {
+ skip_on_cran()
fit_irls_1 <- mkinfit(m_synth_SFO_lin, SFO_lin_a, reweight.method = "obs", quiet = TRUE)
parms_1 <- round(fit_irls_1$bparms.optim, c(1, 4, 4, 4, 4, 4))
expect_equivalent(parms_1, c(102.1, 0.7389, 0.2982, 0.0203, 0.7677, 0.7246))
})
test_that("Reweighting method 'tc' works", {
+ skip_on_cran()
fit_irls_2 <- mkinfit(m_synth_DFOP_par, DFOP_par_c, reweight.method = "tc", quiet = TRUE)
parms_2 <- signif(fit_irls_2$bparms.optim, 3)
expect_equivalent(parms_2, c(99.3, 0.041, 0.00962, 0.597, 0.393, 0.298, 0.0203, 0.707))
diff --git a/tests/testthat/test_schaefer07_complex_case.R b/tests/testthat/test_schaefer07_complex_case.R
index 1b51e5d2..80306bbe 100644
--- a/tests/testthat/test_schaefer07_complex_case.R
+++ b/tests/testthat/test_schaefer07_complex_case.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2015 Johannes Ranke
+# Copyright (C) 2014-2015,2018 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -20,19 +20,20 @@
context("Complex test case from Schaefer et al. (2007) Piacenza paper")
-schaefer07_complex_model <- mkinmod(
- parent = list(type = "SFO", to = c("A1", "B1", "C1"), sink = FALSE),
- A1 = list(type = "SFO", to = "A2"),
- B1 = list(type = "SFO"),
- C1 = list(type = "SFO"),
- A2 = list(type = "SFO"), use_of_ff = "max", quiet = TRUE)
+test_that("Complex test case from Schaefer (2007) can be reproduced (10% tolerance)", {
+
+ skip_on_cran()
+ schaefer07_complex_model <- mkinmod(
+ parent = list(type = "SFO", to = c("A1", "B1", "C1"), sink = FALSE),
+ A1 = list(type = "SFO", to = "A2"),
+ B1 = list(type = "SFO"),
+ C1 = list(type = "SFO"),
+ A2 = list(type = "SFO"), use_of_ff = "max", quiet = TRUE)
-schaefer07_long <- mkin_wide_to_long(schaefer07_complex_case, time = "time")
+ schaefer07_long <- mkin_wide_to_long(schaefer07_complex_case, time = "time")
-fit.default <- mkinfit(schaefer07_complex_model, schaefer07_long, quiet = TRUE)
+ fit.default <- mkinfit(schaefer07_complex_model, schaefer07_long, quiet = TRUE)
-test_that("Complex test case from Schaefer (2007) can be reproduced (10% tolerance)", {
-
s <- summary(fit.default)
r <- schaefer07_complex_results
@@ -57,12 +58,11 @@ test_that("Complex test case from Schaefer (2007) can be reproduced (10% toleran
r$means <- (r$KinGUI + r$ModelMaker)/2
r$mkin.deviation <- abs(round(100 * ((r$mkin - r$means)/r$means), digits=1))
expect_equal(r$mkin.deviation < 10, rep(TRUE, 14))
-})
-test_that("We avoid the local minumum with default settings", {
# If we use optimisation algorithm 'Marq' we get a local minimum with a
# sum of squared residuals of 273.3707
# When using 'Marq', we need to give a good starting estimate e.g. for k_A2 in
# order to get the optimum with sum of squared residuals 240.5686
expect_equal(round(fit.default$ssr, 4), 240.5686)
})
+
diff --git a/tests/testthat/test_synthetic_data_for_UBA_2014.R b/tests/testthat/test_synthetic_data_for_UBA_2014.R
index ea762353..fd3e8bba 100644
--- a/tests/testthat/test_synthetic_data_for_UBA_2014.R
+++ b/tests/testthat/test_synthetic_data_for_UBA_2014.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 Johannes Ranke
+# Copyright (C) 2015, 2018 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -19,46 +19,41 @@
context("Results for synthetic data established in expertise for UBA (Ranke 2014)")
-m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
- M1 = mkinsub("SFO", "M2"),
- M2 = mkinsub("SFO"),
- use_of_ff = "max", quiet = TRUE)
+test_that("Results are correct for SFO_lin_a", {
+ m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
+ M1 = mkinsub("SFO", "M2"),
+ M2 = mkinsub("SFO"),
+ use_of_ff = "max", quiet = TRUE)
+ fit_SFO_lin_a <- mkinfit(m_synth_SFO_lin,
+ synthetic_data_for_UBA_2014[[1]]$data,
+ quiet = TRUE)
+ # Results for SFO_lin_a from p. 48
-m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
- M1 = mkinsub("SFO"),
- M2 = mkinsub("SFO"),
- use_of_ff = "max", quiet = TRUE)
-
-fit_SFO_lin_a <- mkinfit(m_synth_SFO_lin,
- synthetic_data_for_UBA_2014[[1]]$data,
- quiet = TRUE)
-fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par,
- synthetic_data_for_UBA_2014[[12]]$data,
- quiet = TRUE)
-
-# Results for SFO_lin_a from p. 48
-
-test_that("Fitted parameters are correct for SFO_lin_a", {
parms <- round(fit_SFO_lin_a$bparms.optim, c(1, 4, 4, 4, 4, 4))
expect_equivalent(parms, c(102.1, 0.7393, 0.2992, 0.0202, 0.7687, 0.7229))
-})
-
-test_that("FOCUS chi2 error levels are correct for SFO_lin_a", {
errmin <- round(100 * mkinerrmin(fit_SFO_lin_a)$err.min, 2)
expect_equivalent(errmin, c(8.45, 8.66, 10.58, 3.59))
})
# Results for DFOP_par_c from p. 54
-test_that("Fitted parameters are correct for DFOP_par_c", {
+test_that("Results are correct for DFOP_par_c", {
+ skip_on_cran()
+ m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
+ M1 = mkinsub("SFO"),
+ M2 = mkinsub("SFO"),
+ use_of_ff = "max", quiet = TRUE)
+
+
+ fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par,
+ synthetic_data_for_UBA_2014[[12]]$data,
+ quiet = TRUE)
+
parms <- round(fit_DFOP_par_c$bparms.optim, c(1, 4, 4, 4, 4, 4, 4, 4))
expect_equal(parms, c(parent_0 = 103.0,
k_M1 = 0.0389, k_M2 = 0.0095,
f_parent_to_M1 = 0.5565, f_parent_to_M2 = 0.3784,
k1 = 0.3263, k2 = 0.0202, g = 0.7130))
-})
-
-test_that("FOCUS chi2 error levels are correct for DFOP_par_c", {
errmin <- round(100 * mkinerrmin(fit_DFOP_par_c)$err.min, 2)
expect_equivalent(errmin, c(4.03, 3.05, 5.07, 3.17))
})

Contact - Imprint