diff options
-rw-r--r-- | DESCRIPTION | 18 | ||||
-rw-r--r-- | R/mkinfit.R | 6 | ||||
-rw-r--r-- | data/schaefer07_complex_case.RData | bin | 371 -> 828 bytes | |||
-rw-r--r-- | inst/unitTests/runit.mkinfit.R | 35 | ||||
-rw-r--r-- | man/mkinfit.Rd | 7 |
5 files changed, 56 insertions, 10 deletions
diff --git a/DESCRIPTION b/DESCRIPTION index e518d6d..24fbc57 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,20 @@ Package: mkin Type: Package Title: Routines for fitting kinetic models with one or more state - variables to chemical degradation data -Version: 0.7-3 -Date: 2010-05-20 + variables to chemical degradation data +Version: 0.7-4 +Date: 2010-05-22 Author: Johannes Ranke Maintainer: Johannes Ranke <jranke@harlan.com> -Description: Calculation routines based on the FOCUS Kinetics Report - (2006) -Depends: FME +Description: Calculation routines based on the FOCUS Kinetics Report (2006). Includes + a function for conveniently defining differential equation models, choice of + the optimisation methods made available by the FME package (default is a + Levenberg-Marquardt variant). Initial values for parameters of the differential + equations and time zero values of the state values can be defaults, user defined + or a combination of a fit for the parent compound carried out by the kinfit + package and defaults. DT50 and DT90 values are calculated as well as the + chi2 error level as defined by the FOCUS Kinetics Group. +Depends: FME, kinfit License: GPL LazyLoad: yes LazyData: yes diff --git a/R/mkinfit.R b/R/mkinfit.R index 9e872fc..f8285fc 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -188,9 +188,9 @@ mkinfit <- function(mkinmod, observed, # FOCUS kinetics (2006), p. 60 f
k_out_names = grep(paste("k", obs_var, "free", sep="_"), names(parms.all), value=TRUE)
k_out_names = setdiff(k_out_names, paste("k", obs_var, "free", "bound", sep="_"))
- k_1output = sum(parms.all[[k_out_names]])
- k_12 = parms.all[[paste("k", obs_var, "free", "bound", sep="_")]]
- k_21 = parms.all[[paste("k", obs_var, "bound", "free", sep="_")]]
+ k_1output = sum(parms.all[k_out_names])
+ k_12 = parms.all[paste("k", obs_var, "free", "bound", sep="_")]
+ k_21 = parms.all[paste("k", obs_var, "bound", "free", sep="_")]
sqrt_exp = sqrt(1/4 * (k_12 + k_21 + k_1output)^2 + k_12 * k_21 - (k_12 + k_1output) * k_21)
b1 = 0.5 * (k_12 + k_21 + k_1output) + sqrt_exp
diff --git a/data/schaefer07_complex_case.RData b/data/schaefer07_complex_case.RData Binary files differindex 0e3b3af..d58aedd 100644 --- a/data/schaefer07_complex_case.RData +++ b/data/schaefer07_complex_case.RData diff --git a/inst/unitTests/runit.mkinfit.R b/inst/unitTests/runit.mkinfit.R new file mode 100644 index 0000000..6dbd11f --- /dev/null +++ b/inst/unitTests/runit.mkinfit.R @@ -0,0 +1,35 @@ +test.mkinmod.schaefer07_complex_example <- function()
+{
+ schaefer07_complex_model <- mkinmod(
+ parent = list(type = "SFO", to = c("A1", "B1", "C1"), sink = FALSE),
+ A1 = list(type = "SFO", to = "A2"),
+ B1 = list(type = "SFO"),
+ C1 = list(type = "SFO"),
+ A2 = list(type = "SFO"))
+
+ fit <- mkinfit(schaefer07_complex_model,
+ mkin_wide_to_long(schaefer07_complex_case, time = "time"),
+ parms.ini = c(0.1, 0.1, 0.1, 0.01, 0.1, 0.1, 0.1, 0.1))
+ s <- summary(fit)
+ attach(as.list(fit$par))
+ k_parent <- sum(k_parent_A1, k_parent_B1, k_parent_C1)
+ r <- schaefer07_complex_results
+ r$mkin <- c(
+ k_parent,
+ s$distimes["parent", "DT50"],
+ k_parent_A1/k_parent,
+ sum(k_A1_sink, k_A1_A2),
+ s$distimes["A1", "DT50"],
+ k_parent_B1/k_parent,
+ k_B1_sink,
+ s$distimes["B1", "DT50"],
+ k_parent_C1/k_parent,
+ k_C1_sink,
+ s$distimes["C1", "DT50"],
+ k_A1_A2/(k_A1_A2 + k_A1_sink),
+ k_A2_sink,
+ s$distimes["A2", "DT50"])
+ r$means <- (r$KinGUI + r$ModelMaker)/2
+ r$mkin.deviation <- abs(round(100 * ((r$mkin - r$means)/r$means), digits=1))
+ checkTrue(r$mkin.deviation < 10)
+}
diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index 0e381af..0ec2d21 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -10,7 +10,12 @@ values. } \usage{ -mkinfit(mkinmod, observed, parms.ini = rep(0.1, length(mkinmod$parms)), state.ini = c(100, rep(0, length(mkinmod$diffs) - 1)), lower = 0, upper = Inf, fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], plot = FALSE, quiet = FALSE, err = NULL, weight = "none", scaleVar = FALSE, ...) +mkinfit(mkinmod, observed, + parms.ini = rep(0.1, length(mkinmod$parms)), + state.ini = c(100, rep(0, length(mkinmod$diffs) - 1)), + lower = 0, upper = Inf, + fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], + plot = FALSE, quiet = FALSE, err = NULL, weight = "none", scaleVar = FALSE, ...) } \arguments{ \item{mkinmod}{ |