From 7875935fdfc3c55e0ef328b3c3a4512a30011df1 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 23 Mar 2016 17:03:09 +0100 Subject: Added 'from_max_mean' to 'mkinfit'. - Now it is easier to do decline kinetics from the maximum occurrence - Static documentation rebuilt by staticdocs::build_site() - Fixed an URL in the README, thanks to the win-builder check with R-devel --- DESCRIPTION | 4 +-- NEWS.md | 6 +++- R/mkinfit.R | 15 +++++++- README.html | 19 +++++----- README.md | 2 +- build.log | 2 +- inst/web/DFOP.solution.html | 4 +-- inst/web/Extract.mmkin.html | 34 +++++++++--------- inst/web/FOCUS_2006_DFOP_ref_A_to_B.html | 4 +-- inst/web/FOCUS_2006_FOMC_ref_A_to_F.html | 4 +-- inst/web/FOCUS_2006_HS_ref_A_to_F.html | 4 +-- inst/web/FOCUS_2006_SFO_ref_A_to_F.html | 4 +-- inst/web/FOCUS_2006_datasets.html | 4 +-- inst/web/FOMC.solution.html | 4 +-- inst/web/HS.solution.html | 4 +-- inst/web/IORE.solution.html | 4 +-- inst/web/SFO.solution.html | 4 +-- inst/web/SFORB.solution.html | 4 +-- inst/web/endpoints.html | 4 +-- inst/web/geometric_mean.html | 4 +-- inst/web/ilr.html | 4 +-- inst/web/index.html | 4 +-- inst/web/mccall81_245T.html | 14 ++++---- inst/web/mkin_long_to_wide.html | 4 +-- inst/web/mkin_wide_to_long.html | 4 +-- inst/web/mkinds.html | 4 +-- inst/web/mkinerrmin.html | 4 +-- inst/web/mkinfit.html | 26 +++++++++----- inst/web/mkinmod.html | 4 +-- inst/web/mkinparplot.html | 4 +-- inst/web/mkinplot.html | 4 +-- inst/web/mkinpredict.html | 10 +++--- inst/web/mkinresplot.html | 4 +-- inst/web/mkinsub.html | 4 +-- inst/web/mmkin.html | 4 +-- inst/web/plot.mkinfit.html | 4 +-- inst/web/plot.mmkin.html | 4 +-- inst/web/print.mkinds.html | 4 +-- inst/web/print.mkinmod.html | 4 +-- inst/web/schaefer07_complex_case.html | 4 +-- inst/web/summary.mkinfit.html | 14 ++++---- inst/web/synthetic_data_for_UBA.html | 4 +-- inst/web/transform_odeparms.html | 14 ++++---- inst/web/vignettes/FOCUS_D.html | 18 +++++----- inst/web/vignettes/FOCUS_L.html | 20 +++++------ inst/web/vignettes/FOCUS_Z.pdf | Bin 224828 -> 225028 bytes inst/web/vignettes/compiled_models.html | 58 +++++++++++++++---------------- inst/web/vignettes/mkin.pdf | Bin 160263 -> 160263 bytes man/mkinfit.Rd | 8 +++++ vignettes/FOCUS_D.html | 18 +++++----- vignettes/FOCUS_L.html | 20 +++++------ vignettes/FOCUS_Z.pdf | Bin 224828 -> 225028 bytes vignettes/compiled_models.html | 58 +++++++++++++++---------------- vignettes/mkin.pdf | Bin 160263 -> 160263 bytes 54 files changed, 259 insertions(+), 225 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 313015b4..61a930b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Package: mkin Type: Package Title: Routines for Fitting Kinetic Models with One or More State Variables to Chemical Degradation Data -Version: 0.9.41.9000 -Date: 2015-11-13 +Version: 0.9.42 +Date: 2016-03-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 aa6207c3..2bddcd7b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ # NEWS for package 'mkin' -## mkin 0.9.41.9000 +## mkin 0.9.42 + +### Major changes + +- Add the argument `from_max_mean` to `mkinfit`, for fitting only the decline from the maximum observed value for models with a single observed variable ### Minor changes diff --git a/R/mkinfit.R b/R/mkinfit.R index 4a5be20a..929c73f0 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2015 Johannes Ranke +# Copyright (C) 2010-2016 Johannes Ranke # Portions of this code are copyright (C) 2013 Eurofins Regulatory AG # Contact: jranke@uni-bremen.de # The summary function is an adapted and extended version of summary.modFit @@ -26,6 +26,7 @@ mkinfit <- function(mkinmod, observed, state.ini = "auto", fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], + from_max_mean = FALSE, solution_type = c("auto", "analytical", "eigen", "deSolve"), method.ode = "lsoda", use_compiled = "auto", @@ -79,6 +80,18 @@ mkinfit <- function(mkinmod, observed, # Subset observed data with names of observed data in the model observed <- subset(observed, name %in% obs_vars) + # Obtain data for decline from maximum mean value if requested + if (from_max_mean) { + # This is only used for simple decline models + if (length(obs_vars) > 1) + stop("Decline from maximum is only implemented for models with a single observed variable") + + means <- aggregate(value ~ time, data = observed, mean, na.rm=TRUE) + t_of_max <- means[which.max(means$value), "time"] + observed <- subset(observed, time >= t_of_max) + observed$time <- observed$time - t_of_max + } + # Define starting values for parameters where not specified by the user if (parms.ini[[1]] == "auto") parms.ini = vector() diff --git a/README.html b/README.html index 773b47cb..8ee4e838 100644 --- a/README.html +++ b/README.html @@ -12,16 +12,16 @@ - + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +