diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-06-05 17:03:19 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-06-05 17:03:19 +0200 |
commit | 5243ac0ebe3223e5803b4ebee1cb619008638785 (patch) | |
tree | 6be4e8e47f8735f4bbce23d8abf328a700e028d8 /tests | |
parent | b061a00ba4f9410a4b77e58a96fb7baa1247252b (diff) | |
parent | 4b323789265213bd65165873e7efe5e45a579275 (diff) |
Merge branch 'algorithm'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testthat/AIC_exp_d_3.out | 0 | ||||
-rw-r--r-- | tests/testthat/FOCUS_2006_D.csf | 2 | ||||
-rw-r--r-- | tests/testthat/summary_DFOP_FOCUS_C.txt | 5 | ||||
-rw-r--r-- | tests/testthat/test_error_models.R | 49 |
4 files changed, 52 insertions, 4 deletions
diff --git a/tests/testthat/AIC_exp_d_3.out b/tests/testthat/AIC_exp_d_3.out new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/testthat/AIC_exp_d_3.out diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index da2e2fbe..668b1151 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2019-05-08 +Date: 2019-06-05 Optimiser: IRLS [Data] diff --git a/tests/testthat/summary_DFOP_FOCUS_C.txt b/tests/testthat/summary_DFOP_FOCUS_C.txt index fb8051c5..5c6f4257 100644 --- a/tests/testthat/summary_DFOP_FOCUS_C.txt +++ b/tests/testthat/summary_DFOP_FOCUS_C.txt @@ -12,8 +12,9 @@ Model predictions using solution type analytical Fitted using test 0 model solutions performed in test time 0 s -Error model: -Constant variance +Error model: Constant variance + +Error model algorithm: d_3 Starting values for parameters to be optimised: value type diff --git a/tests/testthat/test_error_models.R b/tests/testthat/test_error_models.R index d7a5cea8..fa1f7131 100644 --- a/tests/testthat/test_error_models.R +++ b/tests/testthat/test_error_models.R @@ -153,7 +153,7 @@ test_that("Reweighting method 'tc' produces reasonable variance estimates", { # For a single fit, we get a relative error of less than 10% in the error # model components f_met_2_tc_e4 <- mkinfit(m_synth_DFOP_lin, d_met_2_15[[1]], quiet = TRUE, - error_model = "tc") + error_model = "tc", error_model_algorithm = "direct") parm_errors_met_2_tc_e4 <- (f_met_2_tc_e4$errparms - c(0.5, 0.07)) / c(0.5, 0.07) expect_true(all(abs(parm_errors_met_2_tc_e4) < 0.1)) @@ -177,3 +177,50 @@ test_that("Reweighting method 'tc' produces reasonable variance estimates", { # from 15 datasets expect_true(all(abs(tcf_met_2_15_tc_error_model_errors) < 0.10)) }) + +test_that("The different error model fitting methods work for parent fits", { + skip_on_cran() + + f_9_OLS <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + quiet = TRUE) + expect_equivalent(round(AIC(f_9_OLS), 2), 137.43) + + f_9_direct <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + error_model = "tc", error_model_algorithm = "direct", quiet = TRUE) + expect_equivalent(round(AIC(f_9_direct), 2), 134.94) + + f_9_twostep <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + error_model = "tc", error_model_algorithm = "twostep", quiet = TRUE) + expect_equivalent(round(AIC(f_9_twostep), 2), 134.94) + + f_9_threestep <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + error_model = "tc", error_model_algorithm = "threestep", quiet = TRUE) + expect_equivalent(round(AIC(f_9_threestep), 2), 139.43) + + f_9_fourstep <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + error_model = "tc", error_model_algorithm = "fourstep", quiet = TRUE) + expect_equivalent(round(AIC(f_9_fourstep), 2), 139.43) + + f_9_IRLS <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + error_model = "tc", error_model_algorithm = "IRLS", quiet = TRUE) + expect_equivalent(round(AIC(f_9_IRLS), 2), 139.43) + + f_9_d_3 <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data, + error_model = "tc", error_model_algorithm = "d_3", quiet = TRUE) + expect_equivalent(round(AIC(f_9_d_3), 2), 134.94) +}) + +test_that("The default error model algorithm finds the best known AIC values for parent fits", { + f_tc_exp_d_3 <- mmkin(c("SFO", "DFOP", "HS"), + lapply(experimental_data_for_UBA_2019, function(x) x$data), + error_model = "tc", + error_model_algorithm = "d_3", + quiet = TRUE) + + AIC_exp_d_3 <- lapply(f_tc_exp_d_3, AIC) + AIC_exp_d_3 <- lapply(AIC_exp_d_3, round, 1) + dim(AIC_exp_d_3) <- dim(f_tc_exp_d_3) + dimnames(AIC_exp_d_3) <- dimnames(f_tc_exp_d_3) + + expect_known_output(AIC_exp_d_3, "AIC_exp_d_3.out") +}) |