aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-12-01 11:20:00 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2022-12-01 11:20:00 +0100
commit74e44dfed5af6e6fd421abe82d3e3f190771f85a (patch)
tree2478c882a28e7f0472baace74218e83307eaa122 /tests/testthat
parentaaa4cab7e0c7212f91147a9789af54b97fe342ca (diff)
Possibility to manually specify no_random_effects in mhmkin
Diffstat (limited to 'tests/testthat')
-rw-r--r--tests/testthat/illparms_hfits_synth.txt10
-rw-r--r--tests/testthat/print_fits_synth_const.txt4
-rw-r--r--tests/testthat/summary_hfit_sfo_tc.txt34
-rw-r--r--tests/testthat/test_mhmkin.R34
4 files changed, 43 insertions, 39 deletions
diff --git a/tests/testthat/illparms_hfits_synth.txt b/tests/testthat/illparms_hfits_synth.txt
index affd1318..7a69645b 100644
--- a/tests/testthat/illparms_hfits_synth.txt
+++ b/tests/testthat/illparms_hfits_synth.txt
@@ -1,8 +1,4 @@
error
-degradation const
- SFO
- FOMC sd(log_alpha), sd(log_beta)
- error
-degradation tc
- SFO sd(parent_0)
- FOMC sd(parent_0), sd(log_alpha), sd(log_beta)
+degradation const tc
+ SFO sd(parent_0) sd(parent_0)
+ FOMC sd(log_beta) sd(parent_0), sd(log_beta)
diff --git a/tests/testthat/print_fits_synth_const.txt b/tests/testthat/print_fits_synth_const.txt
index b4bbe6ca..5d076d3d 100644
--- a/tests/testthat/print_fits_synth_const.txt
+++ b/tests/testthat/print_fits_synth_const.txt
@@ -4,8 +4,6 @@ Status of individual fits:
dataset
model 1 2 3 4 5 6
SFO OK OK OK OK OK OK
- FOMC C OK OK OK OK C
+ FOMC OK OK OK OK OK OK
-C: Optimisation did not converge:
-false convergence (8)
OK: No warnings
diff --git a/tests/testthat/summary_hfit_sfo_tc.txt b/tests/testthat/summary_hfit_sfo_tc.txt
index 0a61f75f..0618c715 100644
--- a/tests/testthat/summary_hfit_sfo_tc.txt
+++ b/tests/testthat/summary_hfit_sfo_tc.txt
@@ -8,7 +8,7 @@ Equations:
d_parent/dt = - k_parent * parent
Data:
-104 observations of 1 variable(s) grouped in 6 datasets
+95 observations of 1 variable(s) grouped in 6 datasets
Model predictions using solution type analytical
@@ -19,7 +19,7 @@ Variance model: Two-component variance function
Starting values for degradation parameters:
parent_0 log_k_parent
- 101 -3
+ 94 -2
Fixed degradation parameter values:
None
@@ -27,7 +27,7 @@ None
Starting values for random effects (square root of initial entries in omega):
parent_0 log_k_parent
parent_0 4 0.0
-log_k_parent 0 0.4
+log_k_parent 0 0.7
Starting values for error model parameters:
a.1 b.1
@@ -37,15 +37,15 @@ Results:
Likelihood computed by importance sampling
AIC BIC logLik
- 524 523 -257
+ 542 541 -266
Optimised parameters:
- est. lower upper
-parent_0 100.68 99.27 102.08
-log_k_parent -3.38 -3.55 -3.21
-a.1 0.87 0.59 1.14
-b.1 0.05 0.04 0.06
-SD.log_k_parent 0.21 0.09 0.33
+ est. lower upper
+parent_0 92.52 89.11 95.9
+log_k_parent -1.66 -2.07 -1.3
+a.1 2.03 1.60 2.5
+b.1 0.09 0.07 0.1
+SD.log_k_parent 0.51 0.22 0.8
Correlation:
pr_0
@@ -53,18 +53,18 @@ log_k_parent 0.1
Random effects:
est. lower upper
-SD.log_k_parent 0.2 0.09 0.3
+SD.log_k_parent 0.5 0.2 0.8
Variance model:
est. lower upper
-a.1 0.87 0.59 1.14
-b.1 0.05 0.04 0.06
+a.1 2.03 1.60 2.5
+b.1 0.09 0.07 0.1
Backtransformed parameters:
- est. lower upper
-parent_0 1e+02 99.27 1e+02
-k_parent 3e-02 0.03 4e-02
+ est. lower upper
+parent_0 92.5 89.1 95.9
+k_parent 0.2 0.1 0.3
Estimated disappearance times:
DT50 DT90
-parent 20 68
+parent 4 12
diff --git a/tests/testthat/test_mhmkin.R b/tests/testthat/test_mhmkin.R
index e2339f28..da063326 100644
--- a/tests/testthat/test_mhmkin.R
+++ b/tests/testthat/test_mhmkin.R
@@ -3,8 +3,11 @@ context("Batch fitting and diagnosing hierarchical kinetic models")
test_that("Multiple hierarchical kinetic models can be fitted and diagnosed", {
skip_on_cran()
- fits_synth_const <- suppressWarnings(
- mmkin(c("SFO", "FOMC"), ds_sfo[1:6], cores = n_cores, quiet = TRUE))
+ fits_synth_const <- mmkin(c("SFO", "FOMC"), ds_fomc[1:6], cores = n_cores, quiet = TRUE)
+
+ expect_known_output(
+ print(fits_synth_const),
+ "print_fits_synth_const.txt")
fits_synth_tc <- suppressWarnings(
update(fits_synth_const, error_model = "tc"))
@@ -19,8 +22,8 @@ test_that("Multiple hierarchical kinetic models can be fitted and diagnosed", {
print(illparms(hfits)),
"illparms_hfits_synth.txt")
- expect_equal(which.min(AIC(hfits)), 3)
- expect_equal(which.min(BIC(hfits)), 3)
+ expect_equal(which.min(AIC(hfits)), 4)
+ expect_equal(which.min(BIC(hfits)), 4)
hfit_sfo_tc <- update(hfits[["SFO", "tc"]],
covariance.model = diag(c(0, 1)))
@@ -38,12 +41,19 @@ test_that("Multiple hierarchical kinetic models can be fitted and diagnosed", {
expect_known_output(print(test_summary, digits = 1),
"summary_hfit_sfo_tc.txt")
- # It depends on the platform exactly which of the datasets fail to converge
- # with FOMC, because they were generated to be SFO
- skip_on_travis()
-
- expect_known_output(
- print(fits_synth_const),
- "print_fits_synth_const.txt")
-
+ hfits_sfo_reduced <- update(hfits,
+ no_random_effect = illparms(hfits))
+ expect_equal(
+ as.character(illparms(hfits_sfo_reduced)),
+ rep("", 4))
+
+ # We can also manually set up an object specifying random effects to be
+ # excluded. Entries in the inital list have to be by column
+ no_ranef <- list("parent_0", "log_beta", "parent_0", c("parent_0", "log_beta"))
+ dim(no_ranef) <- c(2, 2)
+
+ hfits_sfo_reduced_2 <- update(hfits,
+ no_random_effect = no_ranef)
+ expect_equivalent(round(anova(hfits_sfo_reduced), 0),
+ round(anova(hfits_sfo_reduced_2), 0))
})

Contact - Imprint