aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--R/twa.R11
-rw-r--r--docs/reference/one_box.html2
-rw-r--r--docs/reference/plot.one_box-8.pngbin13490 -> 13603 bytes
-rw-r--r--docs/reference/plot.one_box.html2
-rw-r--r--docs/reference/sawtooth-6.pngbin13490 -> 13603 bytes
-rw-r--r--docs/reference/sawtooth.html6
-rw-r--r--man/one_box.Rd2
-rw-r--r--man/plot.one_box.Rd2
-rw-r--r--man/sawtooth.Rd2
10 files changed, 26 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index f7a68ea..bcb7553 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+commit dd30f0d0ff1d8d0cc46aaef6e0917c51fe798f52
+Author: Johannes Ranke <jranke@uni-bremen.de>
+Date: 2017-01-19 10:36:19 +0100
+
+ Move mkin::twa to pfm::max_twa.mkinfit
+
+ - Add max_twa.mkinfit() recently introduced to mkin as mkin::twa() but
+ never released with it
+ - Add a test to check max_twa.one_box() against analytical solutions in
+ max_twa.mkinfit().
+ - Clean up R CMD check
+ - Update docs
+
commit 3ead7acba845b4f2552f555dfb29da889ed0cda8
Author: Johannes Ranke <jranke@uni-bremen.de>
Date: 2017-01-19 09:42:21 +0100
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")
#'
diff --git a/docs/reference/one_box.html b/docs/reference/one_box.html
index cb49c02..853f892 100644
--- a/docs/reference/one_box.html
+++ b/docs/reference/one_box.html
@@ -116,7 +116,7 @@ decline. If x is an mkinfit object, the decline is calculated from this object</
<span class='fu'>plot</span>(<span class='no'>pred_1</span>)</div><img src='one_box-4.png' alt='' width='540' height='400' /><div class='input'>
<span class='co'># Use a model with more than one observed variable</span>
<span class='no'>m_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinmod</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>), <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinfit</span>(<span class='no'>m_2</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
-<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'>one_box</span>(<span class='no'>fit_2</span>)
+<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'>one_box</span>(<span class='no'>fit_2</span>, <span class='kw'>ini</span> <span class='kw'>=</span> <span class='st'>"model"</span>)
<span class='fu'>plot</span>(<span class='no'>pred_2</span>)</div><img src='one_box-8.png' alt='' width='540' height='400' /></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
diff --git a/docs/reference/plot.one_box-8.png b/docs/reference/plot.one_box-8.png
index f534444..161ecb4 100644
--- a/docs/reference/plot.one_box-8.png
+++ b/docs/reference/plot.one_box-8.png
Binary files differ
diff --git a/docs/reference/plot.one_box.html b/docs/reference/plot.one_box.html
index d43c415..d75b465 100644
--- a/docs/reference/plot.one_box.html
+++ b/docs/reference/plot.one_box.html
@@ -110,7 +110,7 @@ be shown if max_twa is not NULL.</dd>
<span class='fu'>plot</span>(<span class='no'>dfop_pred</span>)</div><img src='plot.one_box-2.png' alt='' width='540' height='400' /><div class='input'><span class='fu'>plot</span>(<span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='no'>dfop_pred</span>, <span class='fl'>3</span>, <span class='fl'>7</span>), <span class='kw'>max_twa</span> <span class='kw'>=</span> <span class='fl'>21</span>)</div><img src='plot.one_box-4.png' alt='' width='540' height='400' /><div class='input'>
<span class='co'># Use a fitted mkinfit model</span>
<span class='no'>m_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinmod</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>), <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinfit</span>(<span class='no'>m_2</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
-<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='no'>fit_2</span>)
+<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='no'>fit_2</span>, <span class='kw'>ini</span> <span class='kw'>=</span> <span class='fl'>1</span>)
<span class='no'>pred_2_saw</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='no'>pred_2</span>, <span class='fl'>2</span>, <span class='fl'>7</span>)
<span class='fu'>plot</span>(<span class='no'>pred_2_saw</span>, <span class='kw'>max_twa</span> <span class='kw'>=</span> <span class='fl'>21</span>, <span class='kw'>max_twa_var</span> <span class='kw'>=</span> <span class='st'>"m1"</span>)</div><img src='plot.one_box-8.png' alt='' width='540' height='400' /></pre>
</div>
diff --git a/docs/reference/sawtooth-6.png b/docs/reference/sawtooth-6.png
index f534444..161ecb4 100644
--- a/docs/reference/sawtooth-6.png
+++ b/docs/reference/sawtooth-6.png
Binary files differ
diff --git a/docs/reference/sawtooth.html b/docs/reference/sawtooth.html
index 216f64a..be43745 100644
--- a/docs/reference/sawtooth.html
+++ b/docs/reference/sawtooth.html
@@ -98,12 +98,12 @@ the corresponding amounts applied in the second column.</dd>
<span class='no'>pred</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='fl'>10</span>)
<span class='fu'>plot</span>(<span class='fu'>sawtooth</span>(<span class='no'>pred</span>, <span class='kw'>applications</span> <span class='kw'>=</span> <span class='no'>applications</span>))</div><img src='sawtooth-2.png' alt='' width='540' height='400' /><div class='input'>
<span class='no'>m_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinmod</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>), <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinfit</span>(<span class='no'>m_2</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
-<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='no'>fit_2</span>)
+<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='no'>fit_2</span>, <span class='kw'>ini</span> <span class='kw'>=</span> <span class='fl'>1</span>)
<span class='no'>pred_2_saw</span> <span class='kw'>&lt;-</span> <span class='fu'>sawtooth</span>(<span class='no'>pred_2</span>, <span class='fl'>2</span>, <span class='fl'>7</span>)
<span class='fu'>plot</span>(<span class='no'>pred_2_saw</span>, <span class='kw'>max_twa</span> <span class='kw'>=</span> <span class='fl'>21</span>, <span class='kw'>max_twa_var</span> <span class='kw'>=</span> <span class='st'>"m1"</span>)</div><img src='sawtooth-6.png' alt='' width='540' height='400' /><div class='input'>
<span class='fu'><a href='max_twa.html'>max_twa</a></span>(<span class='no'>pred_2_saw</span>)</div><div class='output co'>#&gt; $max
-#&gt; parent m1
-#&gt; 66.01096 85.08484
+#&gt; parent m1
+#&gt; 0.6627707 0.8542785
#&gt;
#&gt; $window_start
#&gt; parent m1
diff --git a/man/one_box.Rd b/man/one_box.Rd
index 8132a70..1bdc791 100644
--- a/man/one_box.Rd
+++ b/man/one_box.Rd
@@ -49,6 +49,6 @@ plot(pred_1)
# 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)
}
diff --git a/man/plot.one_box.Rd b/man/plot.one_box.Rd
index 69ee908..8c8a301 100644
--- a/man/plot.one_box.Rd
+++ b/man/plot.one_box.Rd
@@ -38,7 +38,7 @@ plot(sawtooth(dfop_pred, 3, 7), max_twa = 21)
# 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")
}
diff --git a/man/sawtooth.Rd b/man/sawtooth.Rd
index 8eb8bea..3b1bd3e 100644
--- a/man/sawtooth.Rd
+++ b/man/sawtooth.Rd
@@ -30,7 +30,7 @@ plot(sawtooth(pred, applications = applications))
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