aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/reference
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-11-09 07:31:00 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-11-09 07:31:00 +0100
commite2cb0d4668f17f57c65f3ff94a7e17c784eaf4ba (patch)
tree61b2c6d08c12bfa3ecc8082ad05bb37088e024a3 /docs/dev/reference
parentd452a367d517938a6cd350383e890ed1138d2170 (diff)
Custom analytical solutions for saemix
Currently SFO-SFO and DFOP-SFO. Speed increase factor about 60
Diffstat (limited to 'docs/dev/reference')
-rw-r--r--docs/dev/reference/Rplot001.pngbin27839 -> 1011 bytes
-rw-r--r--docs/dev/reference/saem.html80
2 files changed, 58 insertions, 22 deletions
diff --git a/docs/dev/reference/Rplot001.png b/docs/dev/reference/Rplot001.png
index cfc5bc2b..17a35806 100644
--- a/docs/dev/reference/Rplot001.png
+++ b/docs/dev/reference/Rplot001.png
Binary files differ
diff --git a/docs/dev/reference/saem.html b/docs/dev/reference/saem.html
index 06fcfaa7..25608fc8 100644
--- a/docs/dev/reference/saem.html
+++ b/docs/dev/reference/saem.html
@@ -229,28 +229,28 @@ using <a href='mmkin.html'>mmkin</a>.</p>
state.ini <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fl'>100</span><span class='op'>)</span>, fixed_initials <span class='op'>=</span> <span class='st'>"parent"</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
<span class='va'>f_saem_p0_fixed</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent_p0_fixed</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:44:42 2020"
+#&gt; [1] "Mon Nov 9 07:04:09 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:44:43 2020"</div><div class='input'>
+#&gt; [1] "Mon Nov 9 07:04:11 2020"</div><div class='input'>
<span class='va'>f_mmkin_parent</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"FOMC"</span>, <span class='st'>"DFOP"</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
<span class='va'>f_saem_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:44:45 2020"
+#&gt; [1] "Mon Nov 9 07:04:12 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:44:46 2020"</div><div class='input'><span class='va'>f_saem_fomc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span>
+#&gt; [1] "Mon Nov 9 07:04:13 2020"</div><div class='input'><span class='va'>f_saem_fomc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:44:47 2020"
+#&gt; [1] "Mon Nov 9 07:04:14 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:44:49 2020"</div><div class='input'><span class='va'>f_saem_dfop</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span><span class='op'>)</span>
+#&gt; [1] "Mon Nov 9 07:04:16 2020"</div><div class='input'><span class='va'>f_saem_dfop</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:44:49 2020"
+#&gt; [1] "Mon Nov 9 07:04:16 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:44:52 2020"</div><div class='input'>
-<span class='co'># The returned saem.mmkin object contains an SaemixObject, we can use</span>
+#&gt; [1] "Mon Nov 9 07:04:19 2020"</div><div class='input'>
+<span class='co'># The returned saem.mmkin object contains an SaemixObject, therefore we can use</span>
<span class='co'># functions from saemix</span>
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'>saemix</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>Package saemix, version 3.1.9000</span>
@@ -262,33 +262,69 @@ using <a href='mmkin.html'>mmkin</a>.</p>
<span class='va'>f_mmkin_parent_tc</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/update.html'>update</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span>, error_model <span class='op'>=</span> <span class='st'>"tc"</span><span class='op'>)</span>
<span class='va'>f_saem_fomc_tc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent_tc</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:44:54 2020"
+#&gt; [1] "Mon Nov 9 07:04:21 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:44:59 2020"</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/compare.saemix.html'>compare.saemix</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_fomc_tc</span><span class='op'>$</span><span class='va'>so</span><span class='op'>)</span><span class='op'>)</span>
+#&gt; [1] "Mon Nov 9 07:04:26 2020"</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/compare.saemix.html'>compare.saemix</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_fomc_tc</span><span class='op'>$</span><span class='va'>so</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Likelihoods computed by importance sampling </div><div class='output co'>#&gt; AIC BIC
#&gt; 1 467.7644 465.0305
#&gt; 2 469.4862 466.3617</div><div class='input'>
-<span class='va'>dfop_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"DFOP"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
+<span class='va'>sfo_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
A1 <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</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='va'>f_mmkin</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>dfop_sfo</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, solution_type <span class='op'>=</span> <span class='st'>"analytical"</span><span class='op'>)</span>
-<span class='co'># This takes about 4 minutes on my system</span>
-<span class='va'>f_saem</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>)</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='va'>fomc_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"FOMC"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
+ A1 <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</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='va'>dfop_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"DFOP"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
+ A1 <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</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='co'># The following fit uses analytical solutions for SFO-SFO and DFOP-SFO,</span>
+<span class='co'># and compiled ODEs for FOMC, both are fast</span>
+<span class='va'>f_mmkin</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>
+ <span class='st'>"SFO-SFO"</span> <span class='op'>=</span> <span class='va'>sfo_sfo</span>, <span class='st'>"FOMC-SFO"</span> <span class='op'>=</span> <span class='va'>fomc_sfo</span>, <span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>dfop_sfo</span><span class='op'>)</span>,
+ <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
+<span class='co'># These take about five seconds each on this system, as we use</span>
+<span class='co'># analytical solutions written for saemix. When using the analytical</span>
+<span class='co'># solutions written for mkin this took around four minutes</span>
+<span class='va'>f_saem_sfo_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>[</span><span class='st'>"SFO-SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
+</div><div class='output co'>#&gt; Running main SAEM algorithm
+#&gt; [1] "Mon Nov 9 07:04:28 2020"
+#&gt; ....
+#&gt; Minimisation finished
+#&gt; [1] "Mon Nov 9 07:04:33 2020"</div><div class='input'><span class='va'>f_saem_dfop_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>[</span><span class='st'>"SFO-SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:45:00 2020"
+#&gt; [1] "Mon Nov 9 07:04:33 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:49:01 2020"</div><div class='output co'>#&gt; <span class='error'>Error in exp(trans_k): non-numeric argument to mathematical function</span></div><div class='output co'>#&gt; <span class='message'>Timing stopped at: 317.7 169.9 258.9</span></div><div class='input'>
-<span class='va'>f_mmkin_des</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>dfop_sfo</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, solution_type <span class='op'>=</span> <span class='st'>"deSolve"</span><span class='op'>)</span>
+#&gt; [1] "Mon Nov 9 07:04:39 2020"</div><div class='input'>
<span class='co'># Using a single core, the following takes about 6 minutes, using 10 cores</span>
<span class='co'># it is slower instead of faster</span>
-<span class='va'>f_saem_des</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_des</span>, cores <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span>
+<span class='va'>f_saem_fomc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>[</span><span class='st'>"FOMC-SFO"</span>, <span class='op'>]</span>, cores <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Sun Nov 8 02:49:20 2020"
+#&gt; [1] "Mon Nov 9 07:04:39 2020"
+#&gt; DLSODA- At current T (=R1), MXSTEP (=I1) steps
+#&gt; taken on this call before reaching TOUT
+#&gt; In above message, I1 = 5000
+#&gt;
+#&gt; In above message, R1 = 0.00156238
+#&gt;
+#&gt; DLSODA- At T (=R1) and step size H (=R2), the
+#&gt; corrector convergence failed repeatedly
+#&gt; or with ABS(H) = HMIN
+#&gt; In above message, R1 = 0, R2 = 1.1373e-10
+#&gt;
+#&gt; DLSODA- At current T (=R1), MXSTEP (=I1) steps
+#&gt; taken on this call before reaching TOUT
+#&gt; In above message, I1 = 5000
+#&gt;
+#&gt; In above message, R1 = 2.24752e-06
+#&gt;
+#&gt; DLSODA- At current T (=R1), MXSTEP (=I1) steps
+#&gt; taken on this call before reaching TOUT
+#&gt; In above message, I1 = 5000
+#&gt;
+#&gt; In above message, R1 = 0.000585935
+#&gt;
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Sun Nov 8 02:57:30 2020"</div><div class='output co'>#&gt; <span class='error'>Error in exp(trans_k): non-numeric argument to mathematical function</span></div><div class='output co'>#&gt; <span class='message'>Timing stopped at: 591.7 205.6 521.4</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/compare.saemix.html'>compare.saemix</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='va'>f_saem</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_des</span><span class='op'>$</span><span class='va'>so</span><span class='op'>)</span><span class='op'>)</span>
-</div><div class='output co'>#&gt; <span class='error'>Error in compare.saemix(list(f_saem$so, f_saem_des$so)): object 'f_saem' not found</span></div><div class='input'><span class='co'># }</span>
+#&gt; [1] "Mon Nov 9 07:11:24 2020"</div><div class='output co'>#&gt; <span class='warning'>Warning: Creating predictions from the saemix model failed</span></div><div class='input'><span class='co'># }</span>
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

Contact - Imprint