aboutsummaryrefslogtreecommitdiff
path: root/R/max_twa_parent.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-09-18 13:03:50 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2019-09-18 13:03:50 +0200
commite05656d57668688b971c28e32b4cfd4d3eac4662 (patch)
tree597df9a638c0ce68ae9efcb5b45d42b2f2927a15 /R/max_twa_parent.R
parent0818986e2d9a0e68d3d1de26ac381836e0cf5a6f (diff)
Correct and rebuild docs
- Reconcile docs and code for max_twa_parent - Correct links to docs in twa vignette - Static documentation rebuilt by pkgdown
Diffstat (limited to 'R/max_twa_parent.R')
-rw-r--r--R/max_twa_parent.R30
1 files changed, 21 insertions, 9 deletions
diff --git a/R/max_twa_parent.R b/R/max_twa_parent.R
index 946a9b3d..5129e369 100644
--- a/R/max_twa_parent.R
+++ b/R/max_twa_parent.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2016,2017,2018 Johannes Ranke
+# Copyright (C) 2016-2019 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -37,14 +37,14 @@ max_twa_parent <- function(fit, windows) {
}
k <- parms.all[k_name]
twafunc <- function(t) {
- M0 * (1 - exp(- k * t)) / (k * t)
+ max_twa_sfo(M0, k, t)
}
}
if (type == "FOMC") {
alpha <- parms.all["alpha"]
beta <- parms.all["beta"]
twafunc <- function(t) {
- M0 * (beta)/(t * (1 - alpha)) * ((t/beta + 1)^(1 - alpha) - 1)
+ max_twa_fomc(M0, alpha, beta, t)
}
}
if (type == "DFOP") {
@@ -52,7 +52,7 @@ max_twa_parent <- function(fit, windows) {
k2 <- parms.all["k2"]
g <- parms.all["g"]
twafunc <- function(t) {
- M0/t * ((g/k1) * (1 - exp(- k1 * t)) + ((1 - g)/k2) * (1 - exp(- k2 * t)))
+ max_twa_dfop(M0, k1, k2, g, t)
}
}
if (type == "HS") {
@@ -61,11 +61,8 @@ max_twa_parent <- function(fit, windows) {
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)))
- )
+ max_twa_sfo(M0, k1, t),
+ max_twa_hs(M0, k1, k2, tb, t)
)
}
}
@@ -77,3 +74,18 @@ max_twa_parent <- function(fit, windows) {
names(res) <- windows
return(res)
}
+max_twa_sfo <- function(M0 = 1, k, t) {
+ M0 * (1 - exp(- k * t)) / (k * t)
+}
+max_twa_fomc <- function(M0 = 1, alpha, beta, t) {
+ M0 * (beta)/(t * (1 - alpha)) * ((t/beta + 1)^(1 - alpha) - 1)
+}
+max_twa_dfop <- function(M0 = 1, k1, k2, g, t) {
+ M0/t * ((g/k1) * (1 - exp(- k1 * t)) + ((1 - g)/k2) * (1 - exp(- k2 * t)))
+}
+max_twa_hs <- function(M0 = 1, k1, k2, tb, t) {
+ (M0 / t) * (
+ (1/k1) * (1 - exp(- k1 * tb)) +
+ (exp(- k1 * tb) / k2) * (1 - exp(- k2 * (t - tb)))
+ )
+}

Contact - Imprint