aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/mkinfit.R2
-rw-r--r--README.md9
-rw-r--r--TODO4
-rw-r--r--inst/GUI/mkinGUI.R52
4 files changed, 56 insertions, 11 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index d04d1ea6..3e47479f 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -281,6 +281,8 @@ mkinfit <- function(mkinmod, observed,
fit$rtol <- rtol
fit$weight.ini <- weight.ini
fit$reweight.method <- reweight.method
+ fit$reweight.tol <- reweight.tol
+ fit$reweight.max.iter <- reweight.max.iter
# Return all backtransformed parameters for summary
fit$bparms.optim <- bparms.optim
diff --git a/README.md b/README.md
index 5e884870..4c0e745a 100644
--- a/README.md
+++ b/README.md
@@ -113,11 +113,10 @@ website](http://projects.tessella.com/cake), where you can also
find a zip archive of the R scripts derived from `mkin`, published under the GPL
license.
-Finally, I just (2013-11-11) noticed the github repositories
-[StudyKin](http://github.com/zhenglei-gao/StudyKin) and
-[KineticEval](http://github.com/zhenglei-gao/KineticEval), the latter of which appears to be
-actively developed, so the different tools will hopefully be able to learn
-from each other in the future as well.
+Finally, there is
+[KineticEval](http://github.com/zhenglei-gao/KineticEval), which contains
+a further development of the scripts used for KinGUII, so the different tools
+will hopefully be able to learn from each other in the future as well.
## Contribute
diff --git a/TODO b/TODO
index a56ca55f..54d135a5 100644
--- a/TODO
+++ b/TODO
@@ -2,13 +2,13 @@ TODO for version 1.0
- Transfer (some?) unit tests to examples to make them more easily accessible
for the user - they will be tested during R CMD check anyway
- Let mkin call mkin_wide_to_long automatically, if observed data are suitably defined
+- Convert package vignettes to knitr and Rmd
- Think about what a user would expect from version 1.0
-- Check the chi2 error calculation in mkinerrmin.R. KinGUII does this without iteration
+- Move the GUI to a separate package as it has special dependencies and should have it own versioning
Nice to have:
- Improve choice of starting parameters, in order to avoid failure of eigenvalue based solutions
due to singular matrix
-- Consider reverting to deSolve in case eigenvalue based solution fails due to singular matrix
- Calculate confidence intervals for DT50 and DT90 values when only one parameter is involved
- Calculate transformation only DT50 values (exclude pathways to sink) as additional information
- Calculate DT50 values from smaller rate constant/eigenvalue of DFOP, HS and SFORB models
diff --git a/inst/GUI/mkinGUI.R b/inst/GUI/mkinGUI.R
index fb8f22ab..07f892e0 100644
--- a/inst/GUI/mkinGUI.R
+++ b/inst/GUI/mkinGUI.R
@@ -235,7 +235,15 @@ gbutton("Configure fit for selected model and dataset", cont = dsm,
stmp <<- summary(ftmp)
svalue(pf) <- paste0("Dataset ", ds.i, ", Model ", m[[m.i]]$name)
show_plot("Initial", default = TRUE)
- svalue(f.gg.opts.st) <<- "auto"
+ svalue(f.gg.opts.st) <<- ftmp$solution_type
+ svalue(f.gg.opts.weight) <<- ftmp$weight
+ svalue(f.gg.opts.atol) <<- ftmp$atol
+ svalue(f.gg.opts.rtol) <<- ftmp$rtol
+ svalue(f.gg.opts.reweight.method) <<- ifelse(
+ is.null(ftmp$reweight.method),
+ "none", ftmp$reweight.method)
+ svalue(f.gg.opts.reweight.tol) <<- ftmp$reweight.tol
+ svalue(f.gg.opts.reweight.max.iter) <<- ftmp$reweight.max.iter
f.gg.parms[,] <- get_Parameters(stmp, FALSE)
svalue(f.gg.summary) <- capture.output(stmp)
svalue(center) <- 3
@@ -568,7 +576,6 @@ show_plot <- function(type, default = FALSE) {
ftmp$ds <<- ds[[ds.i]]
}
- #tmp <- get_tempfile(ext=".svg")
svg(tf, width = 7, height = 5)
plot(ftmp, main = ftmp$ds$title,
xlab = ifelse(ftmp$ds$time_unit == "", "Time",
@@ -608,18 +615,34 @@ run_fit <- function() {
iniparms <- Parameters.ini$Initial
names(iniparms) <- sub("_0", "", Parameters.ini$Name)
inifixed <- names(iniparms[Parameters.ini$Fixed])
+ weight <- svalue(f.gg.opts.weight)
+ if (weight == "manual") {
+ err = "err"
+ } else {
+ err = NULL
+ }
+ reweight.method <- svalue(f.gg.opts.reweight.method)
+ if (reweight.method == "none") reweight.method = NULL
ftmp <<- mkinfit(ftmp$mkinmod, override(ds[[ds.i]]$data),
state.ini = iniparms,
fixed_initials = inifixed,
parms.ini = deparms,
fixed_parms = defixed,
solution_type = svalue(f.gg.opts.st),
- err = "err")
+ atol = as.numeric(svalue(f.gg.opts.atol)),
+ rtol = as.numeric(svalue(f.gg.opts.rtol)),
+ weight = weight,
+ err = err,
+ reweight.method = reweight.method,
+ reweight.tol = as.numeric(svalue(f.gg.opts.reweight.tol)),
+ reweight.max.iter = as.numeric(svalue(f.gg.opts.reweight.max.iter))
+ )
ftmp$ds.index <<- ds.i
ftmp$ds <<- ds[[ds.i]]
stmp <<- summary(ftmp)
show_plot("Optimised")
svalue(f.gg.opts.st) <- ftmp$solution_type
+ svalue(f.gg.opts.weight) <- ftmp$weight.ini
f.gg.parms[,] <- get_Parameters(stmp, TRUE)
svalue(f.gg.summary) <- capture.output(stmp)
}
@@ -643,12 +666,27 @@ tf <- get_tempfile(ext=".svg")
svg(tf, width = 7, height = 5)
plot(ftmp)
dev.off()
-plot.gs <- gsvg(tf, container = f.gg.mid, width = 490, height = 350)
+plot.gs <- gsvg(tf, container = f.gg.mid, width = 420, height = 300)
f.gg.opts <- gformlayout(cont = f.gg.mid)
solution_types <- c("auto", "analytical", "eigen", "deSolve")
f.gg.opts.st <- gcombobox(solution_types, selected = 1,
label = "solution_type", width = 200,
cont = f.gg.opts)
+f.gg.opts.atol <- gedit(ftmp$atol, label = "atol", width = 20,
+ cont = f.gg.opts)
+f.gg.opts.rtol <- gedit(ftmp$rtol, label = "rtol", width = 20,
+ cont = f.gg.opts)
+weights <- c("manual", "none", "std", "mean")
+f.gg.opts.weight <- gcombobox(weights, selected = 1, label = "weight",
+ width = 200, cont = f.gg.opts)
+f.gg.opts.reweight.method <- gcombobox(c("none", "obs"), selected = 1,
+ label = "reweight.method",
+ width = 200,
+ cont = f.gg.opts)
+f.gg.opts.reweight.tol <- gedit(1e-8, label = "reweight.tol",
+ width = 20, cont = f.gg.opts)
+f.gg.opts.reweight.max.iter <- gedit(10, label = "reweight.max.iter",
+ width = 20, cont = f.gg.opts)
# Dataframe with initial and optimised parameters {{{3
f.gg.parms <- gdf(Parameters, width = 420, height = 300, cont = pf,
@@ -717,6 +755,12 @@ update_plotting_and_fitting <- function() {
", Model ", ftmp$mkinmod$name)
show_plot("Optimised")
svalue(f.gg.opts.st) <- ftmp$solution_type
+ svalue(f.gg.opts.weight) <- ftmp$weight.ini
+ svalue(f.gg.opts.reweight.method) <- ifelse(is.null(ftmp$reweight.method),
+ "none",
+ ftmp$reweight.method)
+ svalue(f.gg.opts.reweight.tol) <- ftmp$reweight.tol
+ svalue(f.gg.opts.reweight.max.iter) <- ftmp$reweight.max.iter
f.gg.parms[,] <- get_Parameters(stmp, TRUE)
svalue(f.gg.summary) <- capture.output(stmp)
}

Contact - Imprint