diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-08 09:00:20 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-08 09:00:20 +0200 |
commit | f6f8ca5142020c2c5b0628bdcae1e2d00b80c6d5 (patch) | |
tree | 6cb3d93ed2303aca71403b8c7e7907d5a1e2c9b6 | |
parent | 09104e678154881762199b8ba19d7683fac9155f (diff) |
Roxygenize, adapt tests
-rw-r--r-- | man/create_deg_func.Rd | 11 | ||||
-rw-r--r-- | test.log | 14 | ||||
-rw-r--r-- | tests/testthat/FOCUS_2006_D.csf | 2 | ||||
-rw-r--r-- | tests/testthat/setup_script.R | 3 | ||||
-rw-r--r-- | tests/testthat/summary_DFOP_FOCUS_C.txt | 2 | ||||
-rw-r--r-- | tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt | 67 | ||||
-rw-r--r-- | tests/testthat/summary_DFOP_FOCUS_D_eigen.txt | 133 | ||||
-rw-r--r-- | tests/testthat/test_mkinfit_errors.R | 2 | ||||
-rw-r--r-- | tests/testthat/test_plots_summary_twa.R | 8 |
9 files changed, 128 insertions, 114 deletions
diff --git a/man/create_deg_func.Rd b/man/create_deg_func.Rd index 2eefdb80..178661ff 100644 --- a/man/create_deg_func.Rd +++ b/man/create_deg_func.Rd @@ -22,5 +22,14 @@ Create degradation functions for known analytical solutions SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) -fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) +FOCUS_D <- subset(FOCUS_2006_D, value != 0) # to avoid warnings +fit_1 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE) +fit_2 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE) +\dontrun{ +if (require(rbenchmark)) + benchmark( + analytical = mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE), + deSolve = mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE), + replications = 1) +} } @@ -2,12 +2,12 @@ Loading mkin Testing mkin ✔ | OK F W S | Context ✔ | 2 | Export dataset for reading into CAKE -✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.7 s] +✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.6 s] ✔ | 4 | Calculation of FOCUS chi2 error levels [2.2 s] ✔ | 7 | Fitting the SFORB model [11.7 s] ✔ | 5 | Calculation of Akaike weights -✔ | 10 | Confidence intervals and p-values [9.3 s] -✔ | 14 | Error model fitting [37.6 s] +✔ | 10 | Confidence intervals and p-values [9.4 s] +✔ | 14 | Error model fitting [37.4 s] ✔ | 6 | Test fitting the decline of metabolites from their maximum [0.8 s] ✔ | 1 | Fitting the logistic model [0.8 s] ✔ | 1 | Test dataset class mkinds used in gmkin @@ -18,16 +18,16 @@ Testing mkin ✔ | 9 | Nonlinear mixed-effects models [12.0 s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] ✔ | 3 | Summary -✔ | 14 | Plotting [4.9 s] +✔ | 14 | Plotting [5.1 s] ✔ | 4 | AIC calculation ✔ | 4 | Residuals extracted from mkinfit models ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] ✔ | 1 | Summaries of old mkinfit objects -✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.2 s] -✔ | 9 | Hypothesis tests [37.9 s] +✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.3 s] +✔ | 9 | Hypothesis tests [38.1 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 143.0 s +Duration: 143.4 s OK: 156 Failed: 0 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index 7c29ab46..f27df430 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-05-07 +Date: 2020-05-08 Optimiser: IRLS [Data] diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index e33f4af7..86d5089f 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -40,7 +40,8 @@ fits <- mmkin(models, # One metabolite SFO_SFO <- mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"), quiet = TRUE) + m1 = list(type = "SFO"), + use_of_ff = "min", quiet = TRUE) SFO_SFO.ff <- mkinmod(parent = list(type = "SFO", to = "m1"), m1 = list(type = "SFO"), use_of_ff = "max", quiet = TRUE) diff --git a/tests/testthat/summary_DFOP_FOCUS_C.txt b/tests/testthat/summary_DFOP_FOCUS_C.txt index 4f96c8d3..ab64a588 100644 --- a/tests/testthat/summary_DFOP_FOCUS_C.txt +++ b/tests/testthat/summary_DFOP_FOCUS_C.txt @@ -47,7 +47,7 @@ g_ilr 1.2490 0.05811 1.0870 1.4100 sigma 0.6962 0.16410 0.2406 1.1520 Parameter correlation: -NULL +[1] "Correlation matrix is platform dependent, not tested" Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. diff --git a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt index fe697794..9245c40b 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_deSolve.txt @@ -4,8 +4,8 @@ Date of fit: Dummy date for testing Date of summary: Dummy date for testing Equations: -d_parent/dt = - k_parent * parent -d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 +d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent +d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 Model predictions using solution type deSolve @@ -16,18 +16,18 @@ Error model: Constant variance Error model algorithm: OLS Starting values for parameters to be optimised: - value type -parent_0 100.7500 state -k_parent 0.1000 deparm -k_m1 0.1001 deparm -f_parent_to_m1 0.5000 deparm + value type +parent_0 100.7500 state +k_parent_sink 0.1000 deparm +k_parent_m1 0.1001 deparm +k_m1_sink 0.1002 deparm Starting values for the transformed parameters actually optimised: - value lower upper -parent_0 100.750000 -Inf Inf -log_k_parent -2.302585 -Inf Inf -log_k_m1 -2.301586 -Inf Inf -f_parent_ilr_1 0.000000 -Inf Inf + value lower upper +parent_0 100.750000 -Inf Inf +log_k_parent_sink -2.302585 -Inf Inf +log_k_parent_m1 -2.301586 -Inf Inf +log_k_m1_sink -2.300587 -Inf Inf Fixed parameter values: value type @@ -39,37 +39,38 @@ Results: 204.4486 212.6365 -97.22429 Optimised, transformed parameters with symmetric confidence intervals: - Estimate Std. Error Lower Upper -parent_0 99.60000 1.57000 96.40000 102.8000 -log_k_parent -2.31600 0.04087 -2.39900 -2.2330 -log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 -f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 -sigma 3.12600 0.35850 2.39600 3.8550 + Estimate Std. Error Lower Upper +parent_0 99.600 1.57000 96.400 102.800 +log_k_parent_sink -3.038 0.07626 -3.193 -2.883 +log_k_parent_m1 -2.980 0.04033 -3.062 -2.898 +log_k_m1_sink -5.248 0.13320 -5.518 -4.977 +sigma 3.126 0.35850 2.396 3.855 Parameter correlation: -NULL +[1] "Correlation matrix is platform dependent, not tested" Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. t-test (unrealistically) based on the assumption of normal distribution for estimators of untransformed parameters. - Estimate t value Pr(>t) Lower Upper -parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 -k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 -k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 -f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 -sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 + Estimate t value Pr(>t) Lower Upper +parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +k_parent_sink 0.047920 13.110 6.126e-15 0.041030 5.596e-02 +k_parent_m1 0.050780 24.800 3.269e-23 0.046780 5.512e-02 +k_m1_sink 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 FOCUS Chi2 error levels in percent: err.min n.optim df All data 6.398 4 15 -parent 6.459 2 7 -m1 4.690 2 8 +parent 6.827 3 6 +m1 4.490 1 9 Resulting formation fractions: ff -parent_m1 0.5145 parent_sink 0.4855 +parent_m1 0.5145 +m1_sink 1.0000 Estimated disappearance times: DT50 DT90 @@ -82,10 +83,10 @@ Data: 0 parent 102.04 99.59848 2.442e+00 1 parent 93.50 90.23787 3.262e+00 1 parent 92.50 90.23787 2.262e+00 - 3 parent 63.23 74.07319 -1.084e+01 - 3 parent 68.99 74.07319 -5.083e+00 - 7 parent 52.32 49.91206 2.408e+00 - 7 parent 55.13 49.91206 5.218e+00 + 3 parent 63.23 74.07320 -1.084e+01 + 3 parent 68.99 74.07320 -5.083e+00 + 7 parent 52.32 49.91207 2.408e+00 + 7 parent 55.13 49.91207 5.218e+00 14 parent 27.27 25.01257 2.257e+00 14 parent 26.64 25.01257 1.627e+00 21 parent 11.50 12.53462 -1.035e+00 @@ -95,7 +96,7 @@ Data: 50 parent 0.69 0.71624 -2.624e-02 50 parent 0.63 0.71624 -8.624e-02 75 parent 0.05 0.06074 -1.074e-02 - 75 parent 0.06 0.06074 -7.381e-04 + 75 parent 0.06 0.06074 -7.382e-04 1 m1 4.84 4.80296 3.704e-02 1 m1 5.64 4.80296 8.370e-01 3 m1 12.91 13.02400 -1.140e-01 diff --git a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt index 6ddbc1ab..141f57a1 100644 --- a/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt +++ b/tests/testthat/summary_DFOP_FOCUS_D_eigen.txt @@ -4,8 +4,8 @@ Date of fit: Dummy date for testing Date of summary: Dummy date for testing Equations: -d_parent/dt = - k_parent * parent -d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 +d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent +d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1 Model predictions using solution type eigen @@ -16,18 +16,18 @@ Error model: Constant variance Error model algorithm: OLS Starting values for parameters to be optimised: - value type -parent_0 100.7500 state -k_parent 0.1000 deparm -k_m1 0.1001 deparm -f_parent_to_m1 0.5000 deparm + value type +parent_0 100.7500 state +k_parent_sink 0.1000 deparm +k_parent_m1 0.1001 deparm +k_m1_sink 0.1002 deparm Starting values for the transformed parameters actually optimised: - value lower upper -parent_0 100.750000 -Inf Inf -log_k_parent -2.302585 -Inf Inf -log_k_m1 -2.301586 -Inf Inf -f_parent_ilr_1 0.000000 -Inf Inf + value lower upper +parent_0 100.750000 -Inf Inf +log_k_parent_sink -2.302585 -Inf Inf +log_k_parent_m1 -2.301586 -Inf Inf +log_k_m1_sink -2.300587 -Inf Inf Fixed parameter values: value type @@ -39,37 +39,38 @@ Results: 204.4486 212.6365 -97.22429 Optimised, transformed parameters with symmetric confidence intervals: - Estimate Std. Error Lower Upper -parent_0 99.60000 1.57000 96.40000 102.8000 -log_k_parent -2.31600 0.04087 -2.39900 -2.2330 -log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 -f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 -sigma 3.12600 0.35850 2.39600 3.8550 + Estimate Std. Error Lower Upper +parent_0 99.600 1.57000 96.400 102.800 +log_k_parent_sink -3.038 0.07626 -3.193 -2.883 +log_k_parent_m1 -2.980 0.04033 -3.062 -2.898 +log_k_m1_sink -5.248 0.13320 -5.518 -4.977 +sigma 3.126 0.35850 2.396 3.855 Parameter correlation: -NULL +[1] "Correlation matrix is platform dependent, not tested" Backtransformed parameters: Confidence intervals for internally transformed parameters are asymmetric. t-test (unrealistically) based on the assumption of normal distribution for estimators of untransformed parameters. - Estimate t value Pr(>t) Lower Upper -parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 -k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 -k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 -f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 -sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 + Estimate t value Pr(>t) Lower Upper +parent_0 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +k_parent_sink 0.047920 13.110 6.126e-15 0.041030 5.596e-02 +k_parent_m1 0.050780 24.800 3.269e-23 0.046780 5.512e-02 +k_m1_sink 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 FOCUS Chi2 error levels in percent: err.min n.optim df All data 6.398 4 15 -parent 6.459 2 7 -m1 4.690 2 8 +parent 6.827 3 6 +m1 4.490 1 9 Resulting formation fractions: ff -parent_m1 0.5145 parent_sink 0.4855 +parent_m1 0.5145 +m1_sink 1.0000 Estimated disappearance times: DT50 DT90 @@ -78,41 +79,41 @@ m1 131.761 437.70 Data: time variable observed predicted residual - 0 parent 99.46 99.59848 -1.385e-01 - 0 parent 102.04 99.59848 2.442e+00 - 1 parent 93.50 90.23787 3.262e+00 - 1 parent 92.50 90.23787 2.262e+00 - 3 parent 63.23 74.07320 -1.084e+01 - 3 parent 68.99 74.07320 -5.083e+00 - 7 parent 52.32 49.91207 2.408e+00 - 7 parent 55.13 49.91207 5.218e+00 - 14 parent 27.27 25.01257 2.257e+00 - 14 parent 26.64 25.01257 1.627e+00 - 21 parent 11.50 12.53462 -1.035e+00 - 21 parent 11.64 12.53462 -8.946e-01 - 35 parent 2.85 3.14787 -2.979e-01 - 35 parent 2.91 3.14787 -2.379e-01 - 50 parent 0.69 0.71624 -2.624e-02 - 50 parent 0.63 0.71624 -8.624e-02 - 75 parent 0.05 0.06074 -1.074e-02 - 75 parent 0.06 0.06074 -7.382e-04 - 1 m1 4.84 4.80296 3.704e-02 - 1 m1 5.64 4.80296 8.370e-01 - 3 m1 12.91 13.02400 -1.140e-01 - 3 m1 12.96 13.02400 -6.400e-02 - 7 m1 22.97 25.04476 -2.075e+00 - 7 m1 24.47 25.04476 -5.748e-01 - 14 m1 41.69 36.69002 5.000e+00 - 14 m1 33.21 36.69002 -3.480e+00 - 21 m1 44.37 41.65310 2.717e+00 - 21 m1 46.44 41.65310 4.787e+00 - 35 m1 41.22 43.31312 -2.093e+00 - 35 m1 37.95 43.31312 -5.363e+00 - 50 m1 41.19 41.21831 -2.831e-02 - 50 m1 40.01 41.21831 -1.208e+00 - 75 m1 40.09 36.44703 3.643e+00 - 75 m1 33.85 36.44703 -2.597e+00 - 100 m1 31.04 31.98163 -9.416e-01 - 100 m1 33.13 31.98163 1.148e+00 - 120 m1 25.15 28.78984 -3.640e+00 - 120 m1 33.31 28.78984 4.520e+00 + 0 parent 99.46 99.59848 not tested + 0 parent 102.04 99.59848 not tested + 1 parent 93.50 90.23787 not tested + 1 parent 92.50 90.23787 not tested + 3 parent 63.23 74.07320 not tested + 3 parent 68.99 74.07320 not tested + 7 parent 52.32 49.91207 not tested + 7 parent 55.13 49.91207 not tested + 14 parent 27.27 25.01257 not tested + 14 parent 26.64 25.01257 not tested + 21 parent 11.50 12.53462 not tested + 21 parent 11.64 12.53462 not tested + 35 parent 2.85 3.14787 not tested + 35 parent 2.91 3.14787 not tested + 50 parent 0.69 0.71624 not tested + 50 parent 0.63 0.71624 not tested + 75 parent 0.05 0.06074 not tested + 75 parent 0.06 0.06074 not tested + 1 m1 4.84 4.80296 not tested + 1 m1 5.64 4.80296 not tested + 3 m1 12.91 13.02400 not tested + 3 m1 12.96 13.02400 not tested + 7 m1 22.97 25.04476 not tested + 7 m1 24.47 25.04476 not tested + 14 m1 41.69 36.69002 not tested + 14 m1 33.21 36.69002 not tested + 21 m1 44.37 41.65310 not tested + 21 m1 46.44 41.65310 not tested + 35 m1 41.22 43.31312 not tested + 35 m1 37.95 43.31312 not tested + 50 m1 41.19 41.21831 not tested + 50 m1 40.01 41.21831 not tested + 75 m1 40.09 36.44703 not tested + 75 m1 33.85 36.44703 not tested + 100 m1 31.04 31.98163 not tested + 100 m1 33.13 31.98163 not tested + 120 m1 25.15 28.78984 not tested + 120 m1 33.31 28.78984 not tested diff --git a/tests/testthat/test_mkinfit_errors.R b/tests/testthat/test_mkinfit_errors.R index 940e0b2e..c1e9da1d 100644 --- a/tests/testthat/test_mkinfit_errors.R +++ b/tests/testthat/test_mkinfit_errors.R @@ -25,7 +25,7 @@ test_that("mkinfit stops to prevent and/or explain user errors", { parms.ini = c(f_parent_to_m1 = 1.1), quiet = TRUE), "sum up to more than 1") - expect_error(mkinfit(SFO_SFO.ff, FOCUS_2006_D, solution_type = "analytical"), "not implemented") + expect_error(mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "analytical"), "not implemented") expect_error(mkinfit("FOMC", FOCUS_2006_A, solution_type = "eigen"), "coefficient matrix not present") }) diff --git a/tests/testthat/test_plots_summary_twa.R b/tests/testthat/test_plots_summary_twa.R index 19ae8770..13d1dd0f 100644 --- a/tests/testthat/test_plots_summary_twa.R +++ b/tests/testthat/test_plots_summary_twa.R @@ -39,7 +39,7 @@ test_that("Summaries are reproducible", { # The correlation matrix is quite platform dependent # It differs between i386 and amd64 on Windows # and between Travis and my own Linux system - test_summary$Corr <- NULL + test_summary$Corr <- "Correlation matrix is platform dependent, not tested" expect_known_output(print(test_summary), "summary_DFOP_FOCUS_C.txt") test_summary_2 <- summary(f_sfo_sfo_eigen) @@ -53,7 +53,9 @@ test_that("Summaries are reproducible", { # It differs between i386 and amd64 on Windows # and between Travis and my own Linux system # Even more so when using the Eigen method - test_summary_2$Corr <- NULL + test_summary_2$Corr <- "Correlation matrix is platform dependent, not tested" + # The residuals for this method are also platform sensitive + test_summary_2$data$residual <- "not tested" expect_known_output(print(test_summary_2), "summary_DFOP_FOCUS_D_eigen.txt") test_summary_3 <- summary(f_sfo_sfo_desolve) @@ -66,7 +68,7 @@ test_that("Summaries are reproducible", { # The correlation matrix is quite platform dependent # It differs between i386 and amd64 on Windows # and between Travis and my own Linux system - test_summary_3$Corr <- NULL + test_summary_3$Corr <- "Correlation matrix is platform dependent, not tested" expect_known_output(print(test_summary_3), "summary_DFOP_FOCUS_D_deSolve.txt") }) |