From 4c6f29fe2a3ece5a85160b891c89ce0f55299c11 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 23 Jul 2014 08:34:59 +0200 Subject: Parallel metabolite formation with formation fractions in mkinerrmin --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/mkinerrmin.R | 7 ++++--- TODO | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bad72501..de9ff203 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-32 -Date: 2014-07-21 +Date: 2014-07-23 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de"), person("Katrin", "Lindenberger", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index c10a25b0..9d5129c9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ## NEW FEATURES +- The number of degrees of freedom is difficult to define in the case of ilr transformation of formation fractions. Now for each source compartment the number of ilr parameters (=number of optimised parameters) is divided by the number of pathways to metabolites (=number of affected data series) which leads to fractional degrees of freedom in some cases. + - The default for the initial value for the first state value is now taken from the mean of the observations at time zero, if available. - The kinetic model can alternatively be specified with a shorthand name for parent only degradation models, e.g. `SFO`, or `DFOP`. @@ -14,6 +16,8 @@ ## BUG FIXES +- In the determination of the degrees of freedom in `mkinerrmin`, formation fractions were accounted for multiple times in the case of parallel formation of metabolites. See the new feature described above for the solution. + - `transform_rates=FALSE` in `mkinfit` now also works for FOMC and HS models. - Initial values for formation fractions were not set in all cases. diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R index 9ebac6a4..09724730 100644 --- a/R/mkinerrmin.R +++ b/R/mkinerrmin.R @@ -65,11 +65,12 @@ mkinerrmin <- function(fit, alpha = 0.05) # Formation fractions are attributed to the target variable, so look # for source compartments with formation fractions for (source_var in fit$obs_vars) { + n.ff.source = length(grep(paste("^f", source_var, sep = "_"), + names(parms.optim))) + n.paths.source = length(fit$mkinmod$spec[[source_var]]$to) for (target_var in fit$mkinmod$spec[[source_var]]$to) { if (obs_var == target_var) { - n.ff.optim <- n.ff.optim + - length(grep(paste("^f", source_var, sep = "_"), - names(parms.optim))) + n.ff.optim <- n.ff.optim + n.ff.source/n.paths.source } } } diff --git a/TODO b/TODO index 83524220..a9eb8b70 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,7 @@ TODO for version 1.0 - Complete the main package vignette named mkin to include a method description - Improve formatting of differential equations in the summary - Improve order of parameters in output +- Write unit tests for mkinerrmin Nice to have: - Calculate confidence intervals for DT50 and DT90 values when only one -- cgit v1.2.1