From fbfffc0e47171cac03797340fde697a75a5afd61 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 26 Nov 2018 11:44:27 +0100 Subject: Add AIC method for mmkin column objects Static documentation rebuilt by pkgdown --- NAMESPACE | 1 + NEWS.md | 4 +- R/AIC.mmkin.R | 30 ++++ docs/articles/FOCUS_L.html | 40 +++--- docs/articles/web_only/compiled_models.html | 10 +- docs/news/index.html | 3 +- docs/reference/AIC.mmkin.html | 211 ++++++++++++++++++++++++++++ docs/reference/Extract.mmkin.html | 12 +- docs/reference/logLik.mkinfit.html | 19 ++- docs/reference/mccall81_245T.html | 12 +- docs/reference/mkinfit.html | 46 +++--- docs/reference/mkinmod.html | 2 +- docs/reference/mkinpredict.html | 4 +- docs/reference/mmkin.html | 4 +- docs/reference/summary.mkinfit.html | 4 +- docs/reference/transform_odeparms.html | 24 ++-- man/AIC.mmkin.Rd | 44 ++++++ man/logLik.mkinfit.Rd | 12 +- 18 files changed, 391 insertions(+), 91 deletions(-) create mode 100644 R/AIC.mmkin.R create mode 100644 docs/reference/AIC.mmkin.html create mode 100644 man/AIC.mmkin.Rd diff --git a/NAMESPACE b/NAMESPACE index 350c7f45..cc6b24e9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ S3method(print, summary.mkinfit) S3method(logLik, mkinfit) S3method(plot, mmkin) S3method("[", mmkin) +S3method(AIC, mmkin) S3method(mkinpredict, mkinmod) S3method(mkinpredict, mkinfit) diff --git a/NEWS.md b/NEWS.md index 10211f96..f799a749 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ # mkin 0.9.47.6 (2018-11-26) -- Add the function 'logLik.mkinfit.R' which makes it possible to calculate an AIC for mkinfit objects +- Add the function 'logLik.mkinfit' which makes it possible to calculate an AIC for mkinfit objects + +- Add the function 'AIC.mmkin' to makeqit easy to compare columns of mmkin objects - 'add_err': Respect the argument giving the number of replicates in the synthetic dataset diff --git a/R/AIC.mmkin.R b/R/AIC.mmkin.R new file mode 100644 index 00000000..1d306ff9 --- /dev/null +++ b/R/AIC.mmkin.R @@ -0,0 +1,30 @@ +# Copyright (C) 2018 Johannes Ranke +# Contact: jranke@uni-bremen.de + +# This file is part of the R package mkin + +# mkin is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program. If not, see +AIC.mmkin <- function(object, ..., k = 2) { + # We can only handle a single column + if (ncol(object) != 1) stop("Please provide a single column object") + n.fits <- length(object) + model_names <- rownames(object) + + code <- paste0("AIC(", + paste0("object[[", 1:n.fits, "]]", collapse = ", "), + ", k = k)") + res <- eval(parse(text = code)) + if (n.fits > 1) rownames(res) <- model_names + return(res) +} diff --git a/docs/articles/FOCUS_L.html b/docs/articles/FOCUS_L.html index 4d337e72..448a03bb 100644 --- a/docs/articles/FOCUS_L.html +++ b/docs/articles/FOCUS_L.html @@ -110,15 +110,15 @@ summary(m.L1.SFO)
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:23 2018 
-## Date of summary: Mon Nov 26 09:47:23 2018 
+## Date of fit:     Mon Nov 26 11:41:50 2018 
+## Date of summary: Mon Nov 26 11:41:50 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 37 model solutions performed in 0.093 s
+## Fitted with method Port using 37 model solutions performed in 0.094 s
 ## 
 ## Weighting: none
 ## 
@@ -201,8 +201,8 @@
 
 
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:25 2018 
-## Date of summary: Mon Nov 26 09:47:25 2018 
+## Date of fit:     Mon Nov 26 11:41:52 2018 
+## Date of summary: Mon Nov 26 11:41:52 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
@@ -296,15 +296,15 @@
 
 
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:26 2018 
-## Date of summary: Mon Nov 26 09:47:26 2018 
+## Date of fit:     Mon Nov 26 11:41:53 2018 
+## Date of summary: Mon Nov 26 11:41:53 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 81 model solutions performed in 0.192 s
+## Fitted with method Port using 81 model solutions performed in 0.193 s
 ## 
 ## Weighting: none
 ## 
@@ -367,8 +367,8 @@
 
 
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:27 2018 
-## Date of summary: Mon Nov 26 09:47:27 2018 
+## Date of fit:     Mon Nov 26 11:41:54 2018 
+## Date of summary: Mon Nov 26 11:41:54 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
@@ -377,7 +377,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 336 model solutions performed in 0.831 s
+## Fitted with method Port using 336 model solutions performed in 0.826 s
 ## 
 ## Weighting: none
 ## 
@@ -459,8 +459,8 @@
 
 
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:28 2018 
-## Date of summary: Mon Nov 26 09:47:28 2018 
+## Date of fit:     Mon Nov 26 11:41:55 2018 
+## Date of summary: Mon Nov 26 11:41:55 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
@@ -469,7 +469,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 137 model solutions performed in 0.336 s
+## Fitted with method Port using 137 model solutions performed in 0.337 s
 ## 
 ## Weighting: none
 ## 
@@ -560,15 +560,15 @@
 
 
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:28 2018 
-## Date of summary: Mon Nov 26 09:47:29 2018 
+## Date of fit:     Mon Nov 26 11:41:55 2018 
+## Date of summary: Mon Nov 26 11:41:56 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 46 model solutions performed in 0.107 s
+## Fitted with method Port using 46 model solutions performed in 0.108 s
 ## 
 ## Weighting: none
 ## 
@@ -620,15 +620,15 @@
 
 
## mkin version used for fitting:    0.9.47.6 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Mon Nov 26 09:47:28 2018 
-## Date of summary: Mon Nov 26 09:47:29 2018 
+## Date of fit:     Mon Nov 26 11:41:56 2018 
+## Date of summary: Mon Nov 26 11:41:56 2018 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 66 model solutions performed in 0.168 s
+## Fitted with method Port using 66 model solutions performed in 0.16 s
 ## 
 ## Weighting: none
 ## 
diff --git a/docs/articles/web_only/compiled_models.html b/docs/articles/web_only/compiled_models.html
index 083cdb79..8da95e4d 100644
--- a/docs/articles/web_only/compiled_models.html
+++ b/docs/articles/web_only/compiled_models.html
@@ -125,9 +125,9 @@
 }
## Lade nötiges Paket: rbenchmark
##                    test replications elapsed relative user.self sys.self
-## 3     deSolve, compiled            3   2.264    1.000     2.263        0
-## 1 deSolve, not compiled            3  17.642    7.792    17.634        0
-## 2      Eigenvalue based            3   2.801    1.237     2.799        0
+## 3     deSolve, compiled            3   2.302    1.000     2.301        0
+## 1 deSolve, not compiled            3  17.754    7.712    17.743        0
+## 2      Eigenvalue based            3   2.840    1.234     2.838        0
 ##   user.child sys.child
 ## 3          0         0
 ## 1          0         0
@@ -156,8 +156,8 @@
 }
## Successfully compiled differential equation model from auto-generated C code.
##                    test replications elapsed relative user.self sys.self
-## 2     deSolve, compiled            3   4.012    1.000     4.010        0
-## 1 deSolve, not compiled            3  37.606    9.373    37.589        0
+## 2     deSolve, compiled            3   4.116    1.000     4.114        0
+## 1 deSolve, not compiled            3  37.902    9.208    37.884        0
 ##   user.child sys.child
 ## 2          0         0
 ## 1          0         0
diff --git a/docs/news/index.html b/docs/news/index.html index 9f658dad..1b2455a8 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -122,7 +122,8 @@ mkin 0.9.47.6 (2018-11-26) Unreleased
    -
  • Add the function ‘logLik.mkinfit.R’ which makes it possible to calculate an AIC for mkinfit objects

  • +
  • Add the function ‘logLik.mkinfit’ which makes it possible to calculate an AIC for mkinfit objects

  • +
  • Add the function ‘AIC.mmkin’ to makeqit easy to compare columns of mmkin objects

  • ‘add_err’: Respect the argument giving the number of replicates in the synthetic dataset

  • ‘max_twa_parent’: Support maximum time weighted average concentration calculations for the hockey stick (HS) model

  • ‘mkinpredict’: Make the function generic and create a method for mkinfit objects

  • diff --git a/docs/reference/AIC.mmkin.html b/docs/reference/AIC.mmkin.html new file mode 100644 index 00000000..a2ce9885 --- /dev/null +++ b/docs/reference/AIC.mmkin.html @@ -0,0 +1,211 @@ + + + + + + + + +Calculated the AIC for a column of an mmkin object — AIC.mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Provides a convenient way to compare different kineti models fitted to the + same dataset.

    + +
    + +
    # S3 method for mmkin
    +AIC(object, ..., k = 2)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    object

    An object of class mmkin, containing only one column.

    For compatibility with the generic method

    k

    As in the generic method

    + +

    Value

    + +

    As in the generic method (a numeric value for single fits, or a dataframe if + there are several fits in the column).

    + + +

    Examples

    +
    f <- mmkin(c("SFO", "FOMC", "DFOP"), + list("FOCUS A" = FOCUS_2006_A, + "FOCUS C" = FOCUS_2006_C)) + AIC(f[1, "FOCUS A"]) # We get a single number for a single fit
    #> [1] 55.32452
    + # For FOCUS A, the models fit almost equally well, so the higher the number + # of parameters, the higher (worse) the AIC + AIC(f[, "FOCUS A"])
    #> df AIC +#> SFO 3 55.32452 +#> FOMC 4 57.32477 +#> DFOP 5 59.32452
    AIC(f[, "FOCUS A"], k = 0) # If we do not penalize additional parameters, we get nearly the same
    #> df AIC +#> SFO 3 49.32452 +#> FOMC 4 49.32477 +#> DFOP 5 49.32452
    + # For FOCUS C, the more complex models fit better + AIC(f[, "FOCUS C"])
    #> df AIC +#> SFO 3 59.84675 +#> FOMC 4 44.70584 +#> DFOP 5 29.08369
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/Extract.mmkin.html b/docs/reference/Extract.mmkin.html index 51da42fc..b304c2fb 100644 --- a/docs/reference/Extract.mmkin.html +++ b/docs/reference/Extract.mmkin.html @@ -278,7 +278,7 @@ #> #> $time #> User System verstrichen -#> 0.183 0.000 0.183 +#> 0.188 0.000 0.188 #> #> $mkinmod #> <mkinmod> model generated with @@ -467,8 +467,8 @@ #> } #> return(mC) #> } -#> <bytecode: 0x55555be28e50> -#> <environment: 0x55555bc4d2b0> +#> <bytecode: 0x55555bd98970> +#> <environment: 0x55555d417aa8> #> #> $cost_notrans #> function (P) @@ -490,8 +490,8 @@ #> scaleVar = scaleVar) #> return(mC) #> } -#> <bytecode: 0x55555cd2fbb8> -#> <environment: 0x55555bc4d2b0> +#> <bytecode: 0x55555cd14308> +#> <environment: 0x55555d417aa8> #> #> $hessian_notrans #> parent_0 k_parent_sink @@ -558,7 +558,7 @@ #> 99.17407 #> #> $date -#> [1] "Mon Nov 26 09:45:35 2018" +#> [1] "Mon Nov 26 11:40:00 2018" #> #> $version #> [1] "0.9.47.6" diff --git a/docs/reference/logLik.mkinfit.html b/docs/reference/logLik.mkinfit.html index b1901703..33d9eb36 100644 --- a/docs/reference/logLik.mkinfit.html +++ b/docs/reference/logLik.mkinfit.html @@ -34,15 +34,15 @@ See also + +

    Compare the AIC of columns of mmkin objects using + AIC.mmkin.

    +

    Examples

    sfo_sfo <- mkinmod( @@ -207,6 +212,8 @@ In the case of iterative reweighting, the variances obtained by this
  • Arguments
  • Value
  • + +
  • See also
  • Examples
diff --git a/docs/reference/mccall81_245T.html b/docs/reference/mccall81_245T.html index 981c633a..96082932 100644 --- a/docs/reference/mccall81_245T.html +++ b/docs/reference/mccall81_245T.html @@ -158,8 +158,8 @@ anisole = list(type = "SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
fit.1 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE) summary(fit.1, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:45:54 2018 -#> Date of summary: Mon Nov 26 09:45:54 2018 +#> Date of fit: Mon Nov 26 11:40:20 2018 +#> Date of summary: Mon Nov 26 11:40:20 2018 #> #> Equations: #> d_T245/dt = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -169,7 +169,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 574 model solutions performed in 3.641 s +#> Fitted with method Port using 574 model solutions performed in 3.702 s #> #> Weighting: none #> @@ -247,8 +247,8 @@ fixed_parms = "k_phenol_sink", quiet = TRUE) summary(fit.2, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:45:56 2018 -#> Date of summary: Mon Nov 26 09:45:56 2018 +#> Date of fit: Mon Nov 26 11:40:22 2018 +#> Date of summary: Mon Nov 26 11:40:22 2018 #> #> Equations: #> d_T245/dt = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -258,7 +258,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 246 model solutions performed in 1.627 s +#> Fitted with method Port using 246 model solutions performed in 1.646 s #> #> Weighting: none #> diff --git a/docs/reference/mkinfit.html b/docs/reference/mkinfit.html index 883dda22..77c69f4e 100644 --- a/docs/reference/mkinfit.html +++ b/docs/reference/mkinfit.html @@ -436,15 +436,15 @@ fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) summary(fit)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:45:59 2018 -#> Date of summary: Mon Nov 26 09:45:59 2018 +#> Date of fit: Mon Nov 26 11:40:24 2018 +#> Date of summary: Mon Nov 26 11:40:24 2018 #> #> Equations: #> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent #> #> Model predictions using solution type analytical #> -#> Fitted with method Port using 64 model solutions performed in 0.155 s +#> Fitted with method Port using 64 model solutions performed in 0.156 s #> #> Weighting: none #> @@ -513,7 +513,7 @@ m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# Fit the model to the FOCUS example dataset D using defaults print(system.time(fit <- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE)))
#> User System verstrichen -#> 0.974 0.000 0.975
coef(fit)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.989 0.000 0.990
coef(fit)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink #> 99.59848 -3.03822 -2.98030 -5.24750
#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 @@ -588,7 +588,7 @@ #> Model cost at call 146 : 371.2134 #> Optimisation by method Port successfully terminated. #> User System verstrichen -#> 0.79 0.00 0.79
coef(fit.deSolve)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.799 0.000 0.800
coef(fit.deSolve)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink #> 99.59848 -3.03822 -2.98030 -5.24750
endpoints(fit.deSolve)
#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 @@ -626,8 +626,8 @@ m1 = mkinsub("SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
f.noweight <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) summary(f.noweight)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:46:10 2018 -#> Date of summary: Mon Nov 26 09:46:10 2018 +#> Date of fit: Mon Nov 26 11:40:36 2018 +#> Date of summary: Mon Nov 26 11:40:36 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -635,7 +635,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 186 model solutions performed in 0.889 s +#> Fitted with method Port using 186 model solutions performed in 0.839 s #> #> Weighting: none #> @@ -743,8 +743,8 @@ #> 120 m1 33.31 28.78984 4.520e+00
f.irls <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, reweight.method = "obs", quiet = TRUE) summary(f.irls)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:46:13 2018 -#> Date of summary: Mon Nov 26 09:46:13 2018 +#> Date of fit: Mon Nov 26 11:40:39 2018 +#> Date of summary: Mon Nov 26 11:40:39 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -752,7 +752,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 551 model solutions performed in 2.441 s +#> Fitted with method Port using 551 model solutions performed in 2.48 s #> #> Weighting: none #> @@ -865,8 +865,8 @@ #> 120 m1 33.31 28.80898 4.501e+00 2.722
f.w.mean <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, weight = "mean", quiet = TRUE) summary(f.w.mean)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:46:14 2018 -#> Date of summary: Mon Nov 26 09:46:14 2018 +#> Date of fit: Mon Nov 26 11:40:40 2018 +#> Date of summary: Mon Nov 26 11:40:40 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -874,7 +874,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 155 model solutions performed in 0.679 s +#> Fitted with method Port using 155 model solutions performed in 0.694 s #> #> Weighting: mean #> @@ -983,8 +983,8 @@ quiet = TRUE) summary(f.w.value)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:46:15 2018 -#> Date of summary: Mon Nov 26 09:46:15 2018 +#> Date of fit: Mon Nov 26 11:40:41 2018 +#> Date of summary: Mon Nov 26 11:40:41 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -992,7 +992,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 174 model solutions performed in 0.771 s +#> Fitted with method Port using 174 model solutions performed in 0.778 s #> #> Weighting: manual #> @@ -1103,8 +1103,8 @@ f.w.man <- mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE) summary(f.w.man)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:46:16 2018 -#> Date of summary: Mon Nov 26 09:46:16 2018 +#> Date of fit: Mon Nov 26 11:40:42 2018 +#> Date of summary: Mon Nov 26 11:40:42 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -1112,7 +1112,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 270 model solutions performed in 1.2 s +#> Fitted with method Port using 270 model solutions performed in 1.225 s #> #> Weighting: manual #> @@ -1221,8 +1221,8 @@ reweight.method = "obs") summary(f.w.man.irls)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:46:19 2018 -#> Date of summary: Mon Nov 26 09:46:19 2018 +#> Date of fit: Mon Nov 26 11:40:45 2018 +#> Date of summary: Mon Nov 26 11:40:45 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -1230,7 +1230,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 692 model solutions performed in 3.079 s +#> Fitted with method Port using 692 model solutions performed in 3.119 s #> #> Weighting: manual #> diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index d947aff5..0d644bc4 100644 --- a/docs/reference/mkinmod.html +++ b/docs/reference/mkinmod.html @@ -229,7 +229,7 @@ For the definition of model types and their parameters, the equations given SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), verbose = TRUE)
#> Compilation argument: -#> /usr/lib/R/bin/R CMD SHLIB file74b35b9de5b.c 2> file74b35b9de5b.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB file4252799a8f5a.c 2> file4252799a8f5a.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index 88858539..bfe71be5 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -323,7 +323,7 @@ c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "eigen")[201,]))
#> time parent m1 #> 201 20 4.978707 27.46227
#> User System verstrichen -#> 0.005 0.000 0.005
system.time( +#> 0.003 0.000 0.004
system.time( print(mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve")[201,]))
#> time parent m1 @@ -333,7 +333,7 @@ c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve", use_compiled = FALSE)[201,]))
#> time parent m1 #> 201 20 4.978707 27.46227
#> User System verstrichen -#> 0.039 0.000 0.039
+#> 0.039 0.000 0.040
# Predict from a fitted model f <- mkinfit(SFO_SFO, FOCUS_2006_C)
#> Model cost at call 1 : 552.5739 #> Model cost at call 3 : 552.5739 diff --git a/docs/reference/mmkin.html b/docs/reference/mmkin.html index 49117199..92f12c2a 100644 --- a/docs/reference/mmkin.html +++ b/docs/reference/mmkin.html @@ -189,8 +189,8 @@ time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE)) time_default
#> User System verstrichen -#> 0.037 0.036 7.001
time_1
#> User System verstrichen -#> 21.838 0.000 21.852
+#> 0.050 0.037 6.958
time_1
#> User System verstrichen +#> 22.101 0.000 22.114
endpoints(fits.0[["SFO_lin", 2]])
#> $ff #> parent_M1 parent_sink M1_M2 M1_sink #> 0.7340480 0.2659520 0.7505686 0.2494314 diff --git a/docs/reference/summary.mkinfit.html b/docs/reference/summary.mkinfit.html index e63ab87e..554a28e3 100644 --- a/docs/reference/summary.mkinfit.html +++ b/docs/reference/summary.mkinfit.html @@ -206,8 +206,8 @@

Examples

summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:47:09 2018 -#> Date of summary: Mon Nov 26 09:47:09 2018 +#> Date of fit: Mon Nov 26 11:41:36 2018 +#> Date of summary: Mon Nov 26 11:41:36 2018 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index c0ff16fd..e6a42993 100644 --- a/docs/reference/transform_odeparms.html +++ b/docs/reference/transform_odeparms.html @@ -200,8 +200,8 @@ The transformation of sets of formation fractions is fragile, as it supposes fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) summary(fit, data=FALSE) # See transformed and backtransformed parameters
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:47:17 2018 -#> Date of summary: Mon Nov 26 09:47:17 2018 +#> Date of fit: Mon Nov 26 11:41:44 2018 +#> Date of summary: Mon Nov 26 11:41:44 2018 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent @@ -209,7 +209,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 153 model solutions performed in 0.673 s +#> Fitted with method Port using 153 model solutions performed in 0.686 s #> #> Weighting: none #> @@ -276,8 +276,8 @@ The transformation of sets of formation fractions is fragile, as it supposes
fit.2 <- mkinfit(SFO_SFO, FOCUS_2006_D, transform_rates = FALSE, quiet = TRUE) summary(fit.2, data=FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:47:18 2018 -#> Date of summary: Mon Nov 26 09:47:18 2018 +#> Date of fit: Mon Nov 26 11:41:45 2018 +#> Date of summary: Mon Nov 26 11:41:45 2018 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent @@ -285,7 +285,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 350 model solutions performed in 1.529 s +#> Fitted with method Port using 350 model solutions performed in 1.558 s #> #> Weighting: none #> @@ -364,8 +364,8 @@ The transformation of sets of formation fractions is fragile, as it supposes fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) summary(fit.ff, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:47:20 2018 -#> Date of summary: Mon Nov 26 09:47:20 2018 +#> Date of fit: Mon Nov 26 11:41:46 2018 +#> Date of summary: Mon Nov 26 11:41:46 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -373,7 +373,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 186 model solutions performed in 0.847 s +#> Fitted with method Port using 186 model solutions performed in 0.828 s #> #> Weighting: none #> @@ -448,8 +448,8 @@ The transformation of sets of formation fractions is fragile, as it supposes fit.ff.2 <- mkinfit(SFO_SFO.ff.2, FOCUS_2006_D, quiet = TRUE) summary(fit.ff.2, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Mon Nov 26 09:47:20 2018 -#> Date of summary: Mon Nov 26 09:47:20 2018 +#> Date of fit: Mon Nov 26 11:41:47 2018 +#> Date of summary: Mon Nov 26 11:41:47 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -457,7 +457,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 104 model solutions performed in 0.457 s +#> Fitted with method Port using 104 model solutions performed in 0.464 s #> #> Weighting: none #> diff --git a/man/AIC.mmkin.Rd b/man/AIC.mmkin.Rd new file mode 100644 index 00000000..e7f5c228 --- /dev/null +++ b/man/AIC.mmkin.Rd @@ -0,0 +1,44 @@ +\name{AIC.mmkin} +\alias{AIC.mmkin} +\title{ + Calculated the AIC for a column of an mmkin object +} +\description{ + Provides a convenient way to compare different kineti models fitted to the + same dataset. +} +\usage{ + \method{AIC}{mmkin}(object, ..., k = 2) +} +\arguments{ + \item{object}{ + An object of class \code{\link{mmkin}}, containing only one column. + } + \item{\dots}{ + For compatibility with the generic method + } + \item{k}{ + As in the generic method + } +} +\value{ + As in the generic method (a numeric value for single fits, or a dataframe if + there are several fits in the column). +} +\examples{ + f <- mmkin(c("SFO", "FOMC", "DFOP"), + list("FOCUS A" = FOCUS_2006_A, + "FOCUS C" = FOCUS_2006_C)) + AIC(f[1, "FOCUS A"]) # We get a single number for a single fit + + # For FOCUS A, the models fit almost equally well, so the higher the number + # of parameters, the higher (worse) the AIC + AIC(f[, "FOCUS A"]) + AIC(f[, "FOCUS A"], k = 0) # If we do not penalize additional parameters, we get nearly the same + + # For FOCUS C, the more complex models fit better + AIC(f[, "FOCUS C"]) +} +\author{ + Johannes Ranke +} diff --git a/man/logLik.mkinfit.Rd b/man/logLik.mkinfit.Rd index 8080f3db..fe517955 100644 --- a/man/logLik.mkinfit.Rd +++ b/man/logLik.mkinfit.Rd @@ -7,8 +7,8 @@ This function simply calculates the product of the likelihood densities calculated using \code{\link{dnorm}}, i.e. assuming normal distribution. - The total number of estimated parameters returned with the value - of the likelihood is calculated as the sum of fitted degradation + The total number of estimated parameters returned with the value + of the likelihood is calculated as the sum of fitted degradation model parameters and the fitted error model parameters. For the case of unweighted least squares fitting, we calculate one @@ -17,7 +17,7 @@ For the case of manual weighting, we use the weight given for each observation as standard deviation in calculating its likelihood - and the total number of estimated parameters is equal to the + and the total number of estimated parameters is equal to the number of fitted degradation model parameters. In the case of iterative reweighting, the variances obtained by this @@ -28,7 +28,7 @@ reweighting method is "tc". } \usage{ -\method{logLik}{mkinfit}(object, ...) + \method{logLik}{mkinfit}(object, ...) } \arguments{ \item{object}{ @@ -43,6 +43,10 @@ estimated parameters (degradation model parameters plus variance model parameters) as attribute. } +\seealso{ + Compare the AIC of columns of \code{\link{mmkin}} objects using + \code{\link{AIC.mmkin}}. +} \examples{ sfo_sfo <- mkinmod( parent = mkinsub("SFO", to = "m1"), -- cgit v1.2.1