aboutsummaryrefslogtreecommitdiff
path: root/inst
diff options
context:
space:
mode:
Diffstat (limited to 'inst')
-rw-r--r--inst/unitTests/runit.mkinfit.R63
1 files changed, 16 insertions, 47 deletions
diff --git a/inst/unitTests/runit.mkinfit.R b/inst/unitTests/runit.mkinfit.R
index 61a0b303..fdbc86e0 100644
--- a/inst/unitTests/runit.mkinfit.R
+++ b/inst/unitTests/runit.mkinfit.R
@@ -100,15 +100,9 @@ test.FOCUS_2006_DFOP <- function()
DFOP <- mkinmod(parent = list(type = "DFOP"))
# FOCUS_2006_A
- fit.A.DFOP <- mkinfit(DFOP, FOCUS_2006_A, quiet=TRUE)
-
- median.A.DFOP <- as.numeric(lapply(subset(FOCUS_2006_DFOP_ref_A_to_B, dataset == "A",
- c(M0, k1, k2, f, DT50, DT90)), "median"))
-
- fit.A.DFOP.r <- as.numeric(c(fit.A.DFOP$bparms.optim, endpoints(fit.A.DFOP)$distimes[c("DT50", "DT90")]))
- dev.A.DFOP <- abs(round(100 * ((median.A.DFOP - fit.A.DFOP.r)/median.A.DFOP), digits=1))
- # about 6.7% deviation for parameter f, the others are < 0.1%
- checkIdentical(dev.A.DFOP < c(1, 1, 1, 10, 1, 1), rep(TRUE, length(dev.A.DFOP)))
+ # Results were too much dependent on algorithm, as this dataset
+ # is pretty much SFO. "Port" gave a lower deviance, but deviated from the
+ # median of FOCUS_2006 solutions
# FOCUS_2006_B
fit.B.DFOP <- mkinfit(DFOP, FOCUS_2006_B, quiet=TRUE)
@@ -157,10 +151,10 @@ test.FOCUS_2006_HS <- function()
median.C.HS <- as.numeric(lapply(subset(FOCUS_2006_HS_ref_A_to_F, dataset == "C",
c(M0, k1, k2, tb, DT50, DT90)), "median"))
- fit.A.HS.r <- as.numeric(c(fit.A.HS$bparms.optim, endpoints(fit.A.HS)$distimes[c("DT50", "DT90")]))
- dev.A.HS <- abs(round(100 * ((median.A.HS - fit.A.HS.r)/median.A.HS), digits=1))
+ fit.C.HS.r <- as.numeric(c(fit.C.HS$bparms.optim, endpoints(fit.C.HS)$distimes[c("DT50", "DT90")]))
+ dev.C.HS <- abs(round(100 * ((median.C.HS - fit.C.HS.r)/median.C.HS), digits=1))
# deviation <= 0.1%
- checkIdentical(dev.A.HS < 1, rep(TRUE, length(dev.A.HS)))
+ checkIdentical(dev.C.HS < 1, rep(TRUE, length(dev.C.HS)))
} # }}}
# Test SFORB model against DFOP solutions to a relative tolerance of 1% # {{{
@@ -169,33 +163,7 @@ test.FOCUS_2006_SFORB <- function()
SFORB <- mkinmod(parent = list(type = "SFORB"))
# FOCUS_2006_A
- fit.A.SFORB.1 <- mkinfit(SFORB, FOCUS_2006_A, quiet=TRUE)
- fit.A.SFORB.2 <- mkinfit(SFORB, FOCUS_2006_A, solution_type = "deSolve", quiet=TRUE)
-
- median.A.SFORB <- as.numeric(lapply(subset(FOCUS_2006_DFOP_ref_A_to_B, dataset == "A",
- c(M0, k1, k2, DT50, DT90)), "median"))
-
- fit.A.SFORB.1.r <- as.numeric(c(
- parent_0 = fit.A.SFORB.1$bparms.optim[[1]],
- k1 = endpoints(fit.A.SFORB.1)$SFORB[[1]],
- k2 = endpoints(fit.A.SFORB.1)$SFORB[[2]],
- endpoints(fit.A.SFORB.1)$distimes[c("DT50", "DT90")]))
- dev.A.SFORB.1 <- abs(round(100 * ((median.A.SFORB - fit.A.SFORB.1.r)/median.A.SFORB), digits=1))
- # The first Eigenvalue is a lot different from k1 in the DFOP fit
- # The explanation is that the dataset is simply SFO
- dev.A.SFORB.1 <- dev.A.SFORB.1[c(1, 3, 4, 5)]
- checkIdentical(dev.A.SFORB.1 < 1, rep(TRUE, length(dev.A.SFORB.1)))
-
- fit.A.SFORB.2.r <- as.numeric(c(
- parent_0 = fit.A.SFORB.2$bparms.optim[[1]],
- k1 = endpoints(fit.A.SFORB.2)$SFORB[[1]],
- k2 = endpoints(fit.A.SFORB.2)$SFORB[[2]],
- endpoints(fit.A.SFORB.2)$distimes[c("DT50", "DT90")]))
- dev.A.SFORB.2 <- abs(round(100 * ((median.A.SFORB - fit.A.SFORB.2.r)/median.A.SFORB), digits=1))
- # The first Eigenvalue is a lot different from k1 in the DFOP fit
- # The explanation is that the dataset is simply SFO
- dev.A.SFORB.2 <- dev.A.SFORB.2[c(1, 3, 4, 5)]
- checkIdentical(dev.A.SFORB.2 < 1, rep(TRUE, length(dev.A.SFORB.2)))
+ # Again it does not make a lot of sense to use a SFO dataset for this
# FOCUS_2006_B
fit.B.SFORB.1 <- mkinfit(SFORB, FOCUS_2006_B, quiet=TRUE)
@@ -263,32 +231,33 @@ test.mkinfit.schaefer07_complex_example <- function()
A1 = list(type = "SFO", to = "A2"),
B1 = list(type = "SFO"),
C1 = list(type = "SFO"),
- A2 = list(type = "SFO"))
+ A2 = list(type = "SFO"), use_of_ff = "max")
- fit <- mkinfit(schaefer07_complex_model,
+ # If we use the default algorithm 'Marq' we need to give a good starting
+ # estimate for k_A2 in order to find the solution published by Schaefer et al.
+ fit <- mkinfit(schaefer07_complex_model, method.modFit = "Port",
mkin_wide_to_long(schaefer07_complex_case, time = "time"))
s <- summary(fit)
r <- schaefer07_complex_results
attach(as.list(fit$bparms.optim))
- k_parent <- sum(k_parent_A1, k_parent_B1, k_parent_C1)
r$mkin <- c(
k_parent,
s$distimes["parent", "DT50"],
s$ff["parent_A1"],
- sum(k_A1_sink, k_A1_A2),
+ k_A1,
s$distimes["A1", "DT50"],
s$ff["parent_B1"],
- k_B1_sink,
+ k_B1,
s$distimes["B1", "DT50"],
s$ff["parent_C1"],
- k_C1_sink,
+ k_C1,
s$distimes["C1", "DT50"],
s$ff["A1_A2"],
- k_A2_sink,
+ k_A2,
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))
- checkIdentical(r$mkin.deviation[1:11] < 10, rep(TRUE, 11))
+ checkIdentical(r$mkin.deviation < 10, rep(TRUE, 14))
} # }}}
# vim: set foldmethod=marker ts=2 sw=2 expandtab:

Contact - Imprint