From 39b6d8b8569801c2957b22d0973b5ad0c9405e7d Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 18 Sep 2018 10:14:40 +0200 Subject: Support maximum twa for HS, test, docs --- R/max_twa_parent.R | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'R/max_twa_parent.R') 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.") } -- cgit v1.2.1