From f24a86c1f33e06c8114021c5c3956b5f7c400c18 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 4 Nov 2020 10:06:34 +0100 Subject: Revert to use starting values for random effects in nlme.mmkin --- R/nlme.mmkin.R | 2 +- test.log | 10 +++++----- tests/testthat/FOCUS_2006_D.csf | 2 +- tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt | 4 ---- tests/testthat/summary_DFOP_FOCUS_D_eigen.txt | 4 ---- tests/testthat/test_FOCUS_D_UBA_expertise.R | 2 +- tests/testthat/test_nlme.R | 6 ++---- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/R/nlme.mmkin.R b/R/nlme.mmkin.R index e8418ebd..6d24a044 100644 --- a/R/nlme.mmkin.R +++ b/R/nlme.mmkin.R @@ -150,7 +150,7 @@ nlme.mmkin <- function(model, data = sys.frame(sys.parent()), thisCall[["data"]] <- nlme_data(model) if (missing(start)) { - thisCall[["start"]] <- mean_degparms(model, random = FALSE) + thisCall[["start"]] <- mean_degparms(model, random = TRUE) } thisCall[["fixed"]] <- lapply(as.list(dp_names), function(el) diff --git a/test.log b/test.log index 10c5645e..b356bac5 100644 --- a/test.log +++ b/test.log @@ -5,11 +5,11 @@ Testing mkin ✔ | 2 | Export dataset for reading into CAKE ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.9 s] ✔ | 4 | Calculation of FOCUS chi2 error levels [0.4 s] -✔ | 7 | Fitting the SFORB model [3.4 s] +✔ | 7 | Fitting the SFORB model [3.3 s] ✔ | 5 | Analytical solutions for coupled models [3.2 s] ✔ | 5 | Calculation of Akaike weights ✔ | 10 | Confidence intervals and p-values [1.0 s] -✔ | 14 | Error model fitting [4.2 s] +✔ | 14 | Error model fitting [4.1 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 @@ -17,7 +17,7 @@ Testing mkin ✔ | 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] -✔ | 14 2 | Evaluations according to 2015 NAFTA guidance [1.2 s] +✔ | 14 2 | Evaluations according to 2015 NAFTA guidance [1.1 s] ──────────────────────────────────────────────────────────────────────────────── test_nafta.R:25: skip: Test data from Appendix B are correctly evaluated Reason: getRversion() < "4.1.0" is TRUE @@ -25,7 +25,7 @@ Reason: getRversion() < "4.1.0" is TRUE test_nafta.R:53: skip: Test data from Appendix D are correctly evaluated Reason: getRversion() < "4.1.0" is TRUE ──────────────────────────────────────────────────────────────────────────────── -✔ | 9 | Nonlinear mixed-effects models [7.8 s] +✔ | 9 | Nonlinear mixed-effects models [7.7 s] ✔ | 0 1 | Plotting [0.7 s] ──────────────────────────────────────────────────────────────────────────────── test_plot.R:24: skip: Plotting mkinfit and mmkin objects is reproducible @@ -40,7 +40,7 @@ Reason: getRversion() < "4.1.0" is TRUE ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.5 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 37.8 s +Duration: 37.5 s OK: 146 Failed: 0 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index b8828b57..c7cb6d41 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-10-27 +Date: 2020-11-04 Optimiser: IRLS [Data] diff --git a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt index 0b31a81f..9245c40b 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt @@ -33,10 +33,6 @@ Fixed parameter values: value type m1_0 0 state - -Warning(s): -Shapiro-Wilk test for standardized residuals: p = 0.0165 - Results: AIC BIC logLik diff --git a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt index 8ced5c4d..141f57a1 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt @@ -33,10 +33,6 @@ Fixed parameter values: value type m1_0 0 state - -Warning(s): -Shapiro-Wilk test for standardized residuals: p = 0.0165 - Results: AIC BIC logLik diff --git a/tests/testthat/test_FOCUS_D_UBA_expertise.R b/tests/testthat/test_FOCUS_D_UBA_expertise.R index 0a7e5219..faf473c4 100644 --- a/tests/testthat/test_FOCUS_D_UBA_expertise.R +++ b/tests/testthat/test_FOCUS_D_UBA_expertise.R @@ -4,7 +4,7 @@ context("Results for FOCUS D established in expertise for UBA (Ranke 2014)") test_that("Fits without formation fractions are correct for FOCUS D", { expect_warning( - fit.noff <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE), + fit.noff <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, test_residuals = TRUE), "Shapiro-Wilk") expect_equal(round(as.numeric(endpoints(fit.noff)$distimes["parent", ]), 2), diff --git a/tests/testthat/test_nlme.R b/tests/testthat/test_nlme.R index 5a8db142..4fd8e53f 100644 --- a/tests/testthat/test_nlme.R +++ b/tests/testthat/test_nlme.R @@ -59,12 +59,10 @@ test_that("nlme_function works correctly", { expect_equal(m_nlme_raw_2$coefficients, m_nlme_mmkin$coefficients) - anova_nlme <- anova(m_nlme_mmkin, m_nlme_raw) # mmkin needs to go first as we had - # to adapt the method due to - # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17761 + anova_nlme <- anova(m_nlme_raw, m_nlme_mmkin) # We get a slightly lower AIC with the improved starting values used within - # nlme.mmkin + # nlme.mmkin, specifying also random effects expect_lt(anova_nlme["m_nlme_mmkin", "AIC"], anova_nlme["m_nlme_raw", "AIC"]) -- cgit v1.2.1