aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--DESCRIPTION2
-rw-r--r--R/mkinerrmin.R15
3 files changed, 20 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index a57894d..422deb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-10-21 Johannes Ranke <jranke@uni-bremen.de> for mkin (0.9-22)
+
+ * Get rid of the optimisation step in mkinerrmin - this was unnecessary
+ Thanks to KinGUII for the inspiration - actually this is equation 6-2
+ in FOCUS kinetics p. 91 that I had overlooked originally
+
2013-10-17 Johannes Ranke <jranke@uni-bremen.de> for mkin (0.9-22)
* Fix plot.mkinfit as it passed graphical arguments like main to the solver
@@ -16,11 +22,13 @@
* Correct the output of the data in the case of manual weighting
* Implement IRLS assuming different variances for observed variables
-
2013-10-09 Johannes Ranke for version (0.9-22)
* Do not use 0 values at time zero for chi2 error level calculations.
- This is the way it is done in KinGUII and it makes sense
+ This is the way it is done in KinGUII and it makes sense. It does
+ impact the chi2 error levels in the output. Generally they seem to be
+ lower for metabolites now, presumably because the mean of the observed
+ values is higher
Changes performed in earlier versions are documented in the subversion log
files on R-Forge http://www.r-forge.r-project.org/scm/?group_id=615
diff --git a/DESCRIPTION b/DESCRIPTION
index f7a293d..9e00357 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -3,7 +3,7 @@ Type: Package
Title: Routines for fitting kinetic models with one or more state
variables to chemical degradation data
Version: 0.9-22
-Date: 2013-10-10
+Date: 2013-10-21
Author: Johannes Ranke, with contributions from Katrin Lindenberger, René Lehmann
Maintainer: Johannes Ranke <jranke@uni-bremen.de>
Description: Calculation routines based on the FOCUS Kinetics Report (2006).
diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R
index 7d9d462..074cc56 100644
--- a/R/mkinerrmin.R
+++ b/R/mkinerrmin.R
@@ -22,16 +22,14 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("name", "value_mean"))
mkinerrmin <- function(fit, alpha = 0.05)
{
parms.optim <- fit$par
+
kinerrmin <- function(errdata, n.parms) {
means.mean <- mean(errdata$value_mean, na.rm = TRUE)
df = length(errdata$value_mean) - n.parms
- f <- function(err)
- {
- (sum((errdata$value_mean - errdata$value_pred)^2/((err * means.mean)^2)) -
- qchisq(1 - alpha,df))^2
- }
- err.min <- optimize(f, c(0.01,0.9))$minimum
+ err.min <- sqrt((1 / qchisq(1 - alpha, df)) *
+ sum((errdata$value_mean - errdata$value_pred)^2)/(means.mean^2))
+
return(list(err.min = err.min, n.optim = n.parms, df = df))
}
@@ -39,7 +37,12 @@ mkinerrmin <- function(fit, alpha = 0.05)
errdata <- merge(means, fit$predicted, by = c("time", "name"),
suffixes = c("_mean", "_pred"))
errdata <- errdata[order(errdata$time, errdata$name), ]
+
+ # Any value that is set to exactly zero is not really an observed value
+ # Remove those at time 0 - those are caused by the FOCUS recommendation
+ # to set metabolites occurring at time 0 to 0
errdata <- subset(errdata, !(time == 0 & value_mean == 0))
+
n.optim.overall <- length(parms.optim)
errmin.overall <- kinerrmin(errdata, n.optim.overall)

Contact - Imprint