From e05656d57668688b971c28e32b4cfd4d3eac4662 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 18 Sep 2019 13:03:50 +0200 Subject: Correct and rebuild docs - Reconcile docs and code for max_twa_parent - Correct links to docs in twa vignette - Static documentation rebuilt by pkgdown --- R/max_twa_parent.R | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'R') 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))) + ) +} -- cgit v1.2.1