aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2017-01-19 10:47:09 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2017-01-19 10:47:09 +0100
commit3947731a5a8c3598271b26f5201dea4bcb13ef6d (patch)
treec8139c938f970b647421704b7a2b0780557a38d1 /R
parentdd30f0d0ff1d8d0cc46aaef6e0917c51fe798f52 (diff)
Fix one_box for ini = 1, use in sawtooth examples
Diffstat (limited to 'R')
-rw-r--r--R/twa.R11
1 files changed, 5 insertions, 6 deletions
diff --git a/R/twa.R b/R/twa.R
index 88cfec3..0e03baf 100644
--- a/R/twa.R
+++ b/R/twa.R
@@ -43,7 +43,7 @@
#' # Use a model with more than one observed variable
#' m_2 <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#' fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE)
-#' pred_2 <- one_box(fit_2)
+#' pred_2 <- one_box(fit_2, ini = "model")
#' plot(pred_2)
one_box <- function(x, ini, ...,
t_end = 100, res = 0.01)
@@ -99,11 +99,10 @@ one_box.character <- function(x, ini = 1, parms, ...,
#' @export
one_box.mkinfit <- function(x, ini = c("model", 1), ..., t_end = 100, res = 0.01) {
fit <- x
-
- ini = match.arg(ini)
- if (ini == "model") {
+ if (ini[1] == "model") {
odeini = x$bparms.state
} else {
+ if (ini[1] != 1) stop ("Argument ini can only be 'model' or 1")
odeini <- c(1, rep(0, length(fit$mkinmod$spec) - 1))
names(odeini) <- names(fit$mkinmod$spec)
}
@@ -142,7 +141,7 @@ one_box.mkinfit <- function(x, ini = c("model", 1), ..., t_end = 100, res = 0.01
#' # Use a fitted mkinfit model
#' m_2 <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#' fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE)
-#' pred_2 <- one_box(fit_2)
+#' pred_2 <- one_box(fit_2, ini = 1)
#' pred_2_saw <- sawtooth(pred_2, 2, 7)
#' plot(pred_2_saw, max_twa = 21, max_twa_var = "m1")
plot.one_box <- function(x,
@@ -184,7 +183,7 @@ plot.one_box <- function(x,
#'
#' m_2 <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#' fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE)
-#' pred_2 <- one_box(fit_2)
+#' pred_2 <- one_box(fit_2, ini = 1)
#' pred_2_saw <- sawtooth(pred_2, 2, 7)
#' plot(pred_2_saw, max_twa = 21, max_twa_var = "m1")
#'

Contact - Imprint