diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-07-17 16:27:46 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-07-17 16:27:46 +0200 |
commit | a7e209b553e2e99ffc9aa2b003f9b73b9ac4b985 (patch) | |
tree | 25b9b07d372bab606b07e91f53bd8059d867d767 | |
parent | 9b8ee1c02b04cd45b9cd5231ec2bad36afe6313f (diff) |
mkinfit: Ignore unused components of state.ini
-rw-r--r-- | NEWS.md | 2 | ||||
-rw-r--r-- | R/mkinfit.R | 3 | ||||
-rw-r--r-- | test.log | 9 | ||||
-rw-r--r-- | tests/testthat/FOCUS_2006_D.csf | 2 | ||||
-rw-r--r-- | tests/testthat/test_mkinfit.R | 10 |
5 files changed, 20 insertions, 6 deletions
@@ -16,6 +16,8 @@ - 'mmkin': Do not fail any more if one of the fits fails, but assign the try-error to the respective position in the mmkin object +- 'mkinfit': Ignore components of state.ini that do not correspond to state variables in the model + # mkin 0.9.50.2 (2020-05-12) - Increase tolerance for a platform specific test results on the Solaris test machine on CRAN diff --git a/R/mkinfit.R b/R/mkinfit.R index 12df0325..ee7c0b99 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -424,7 +424,8 @@ mkinfit <- function(mkinmod, observed, state.ini_used <- state.ini_auto } else { state.ini_used <- state.ini_auto - state.ini_used[names(state.ini)] <- state.ini + state.ini_good <- intersect(names(mkinmod$diffs), names(state.ini)) + state.ini_used[state.ini_good] <- state.ini[state.ini_good] } state.ini <- state.ini_used @@ -9,10 +9,11 @@ Testing mkin ✔ | 5 | Analytical solutions for coupled models [3.2 s] ✔ | 5 | Calculation of Akaike weights ✔ | 10 | Confidence intervals and p-values [1.1 s] -✔ | 14 | Error model fitting [3.7 s] +✔ | 14 | Error model fitting [3.8 s] ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3 s] ✔ | 1 | Fitting the logistic model [0.2 s] ✔ | 1 | Test dataset class mkinds used in gmkin +✔ | 1 | mkinfit features [0.2 s] ✔ | 12 | Special cases of mkinfit calls [0.6 s] ✔ | 8 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.4 s] @@ -31,7 +32,7 @@ test_plot.R:24: skip: Plotting mkinfit and mmkin objects is reproducible Reason: getRversion() < "4.1.0" is TRUE ──────────────────────────────────────────────────────────────────────────────── ✔ | 4 | Residuals extracted from mkinfit models -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.4 s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.5 s] ✔ | 4 | Summary [0.1 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.2 s] @@ -39,9 +40,9 @@ Reason: getRversion() < "4.1.0" is TRUE ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 36.8 s +Duration: 37.1 s -OK: 145 +OK: 146 Failed: 0 Warnings: 0 Skipped: 3 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index 232d7dad..a340a0a5 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: 2020-07-15 +Date: 2020-07-17 Optimiser: IRLS [Data] diff --git a/tests/testthat/test_mkinfit.R b/tests/testthat/test_mkinfit.R new file mode 100644 index 00000000..fb81c3d8 --- /dev/null +++ b/tests/testthat/test_mkinfit.R @@ -0,0 +1,10 @@ +context("mkinfit features") + +test_that("Specifying initial values for state variables works correctly", { + f_1 <- mkinfit("SFO", FOCUS_2006_C, state.ini = c(parent = 100), quiet = TRUE) + f_2 <- mkinfit("SFO", FOCUS_2006_C, state.ini = c(parrrent = 100), quiet = TRUE) + + # Before mkin 0.9.50.3, these would give different degrees of freedom, + # also affecting AIC calculations + expect_equal(logLik(f_1), logLik(f_2)) +}) |