aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2018-11-26 11:44:27 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2018-11-26 11:44:27 +0100
commitfbfffc0e47171cac03797340fde697a75a5afd61 (patch)
treeb893e08e0f28673c2407c4bd1354b4bc23099b18 /R
parent282f88f9e28e683f524d5e05d65d8b18ab856a8d (diff)
Add AIC method for mmkin column objects
Static documentation rebuilt by pkgdown
Diffstat (limited to 'R')
-rw-r--r--R/AIC.mmkin.R30
1 files changed, 30 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>
+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)
+}

Contact - Imprint