aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2018-09-18 10:14:40 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2018-09-18 10:14:40 +0200
commit39b6d8b8569801c2957b22d0973b5ad0c9405e7d (patch)
tree97d0580eec85d9ab4196338ec742ba407ccfa7f8 /R
parent9a793d0d39c8239ebcc76390f227596cef9b9be1 (diff)
Support maximum twa for HS, test, docs
Diffstat (limited to 'R')
-rw-r--r--R/max_twa_parent.R18
1 files changed, 16 insertions, 2 deletions
diff --git a/R/max_twa_parent.R b/R/max_twa_parent.R
index 8d8b77f8..946a9b3d 100644
--- a/R/max_twa_parent.R
+++ b/R/max_twa_parent.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2016,2017 Johannes Ranke
+# Copyright (C) 2016,2017,2018 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -55,7 +55,21 @@ max_twa_parent <- function(fit, windows) {
M0/t * ((g/k1) * (1 - exp(- k1 * t)) + ((1 - g)/k2) * (1 - exp(- k2 * t)))
}
}
- if (type %in% c("HS", "IORE", "SFORB")) {
+ if (type == "HS") {
+ k1 <- parms.all["k1"]
+ k2 <- parms.all["k2"]
+ tb <- parms.all["tb"]
+ twafunc <- function(t) {
+ ifelse(t <= tb,
+ M0 * (1 - exp(- k1 * t)) / (k1 * t),
+ (M0 / t) * (
+ (1/k1) * (1 - exp(- k1 * tb)) +
+ (exp(- k1 * tb) / k2) * (1 - exp(- k2 * (t - tb)))
+ )
+ )
+ }
+ }
+ if (type %in% c("IORE", "SFORB")) {
stop("Calculation of maximum time weighted average concentrations is currently ",
"not implemented for the ", type, " model.")
}

Contact - Imprint