aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-10-15 14:55:55 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2020-10-15 14:55:55 +0200
commita9c7a1a8322567e9406a59ba0a4f910b89bd05e6 (patch)
tree27803cef655ecbd4c1d40fe8f9fb256c5896f5e6
parentf4f6cc84d32e135b03300bf78578f1981c489bfe (diff)
More gentle example for saemix with combined error model
-rw-r--r--R/saemix.R3
-rw-r--r--docs/dev/pkgdown.yml2
-rw-r--r--docs/dev/reference/Rplot001.pngbin0 -> 19062 bytes
-rw-r--r--docs/dev/reference/Rplot002.pngbin0 -> 24396 bytes
-rw-r--r--docs/dev/reference/Rplot003.pngbin0 -> 6583 bytes
-rw-r--r--docs/dev/reference/Rplot004.pngbin0 -> 28700 bytes
-rw-r--r--docs/dev/reference/Rplot005.pngbin0 -> 28700 bytes
-rw-r--r--docs/dev/reference/saemix-3.pngbin16942 -> 18094 bytes
-rw-r--r--docs/dev/reference/saemix-4.pngbin65995 -> 82011 bytes
-rw-r--r--docs/dev/reference/saemix.html88
-rw-r--r--man/saemix.Rd3
11 files changed, 47 insertions, 49 deletions
diff --git a/R/saemix.R b/R/saemix.R
index be8baf2a..85338ebd 100644
--- a/R/saemix.R
+++ b/R/saemix.R
@@ -35,7 +35,7 @@
#' }
#' # Synthetic data with two-component error
#' sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
-#' dt50_sfo_in <- c(800, 900, 1000, 1111.11, 1250)
+#' dt50_sfo_in <- c(80, 90, 100, 111.111, 125)
#' k_in <- log(2) / dt50_sfo_in
#'
#' SFO <- mkinmod(parent = mkinsub("SFO"))
@@ -53,6 +53,7 @@
#' })
#' \dontrun{
#' f_mmkin_syn <- mmkin("SFO", ds_sfo_syn, error_model = "tc", quiet = TRUE)
+#' # plot(f_mmkin_syn)
#' m_saemix_tc <- saemix_model(f_mmkin_syn, cores = 1)
#' d_saemix_tc <- saemix_data(f_mmkin_syn)
#' f_saemix_tc <- saemix(m_saemix_tc, d_saemix_tc, saemix_options)
diff --git a/docs/dev/pkgdown.yml b/docs/dev/pkgdown.yml
index 58255596..b0bf033b 100644
--- a/docs/dev/pkgdown.yml
+++ b/docs/dev/pkgdown.yml
@@ -10,7 +10,7 @@ articles:
web_only/NAFTA_examples: NAFTA_examples.html
web_only/benchmarks: benchmarks.html
web_only/compiled_models: compiled_models.html
-last_built: 2020-10-15T09:55Z
+last_built: 2020-10-15T12:51Z
urls:
reference: https://pkgdown.jrwb.de/mkin/reference
article: https://pkgdown.jrwb.de/mkin/articles
diff --git a/docs/dev/reference/Rplot001.png b/docs/dev/reference/Rplot001.png
new file mode 100644
index 00000000..36b20f09
--- /dev/null
+++ b/docs/dev/reference/Rplot001.png
Binary files differ
diff --git a/docs/dev/reference/Rplot002.png b/docs/dev/reference/Rplot002.png
new file mode 100644
index 00000000..b568eb1c
--- /dev/null
+++ b/docs/dev/reference/Rplot002.png
Binary files differ
diff --git a/docs/dev/reference/Rplot003.png b/docs/dev/reference/Rplot003.png
new file mode 100644
index 00000000..53415e5d
--- /dev/null
+++ b/docs/dev/reference/Rplot003.png
Binary files differ
diff --git a/docs/dev/reference/Rplot004.png b/docs/dev/reference/Rplot004.png
new file mode 100644
index 00000000..ea685493
--- /dev/null
+++ b/docs/dev/reference/Rplot004.png
Binary files differ
diff --git a/docs/dev/reference/Rplot005.png b/docs/dev/reference/Rplot005.png
new file mode 100644
index 00000000..ea685493
--- /dev/null
+++ b/docs/dev/reference/Rplot005.png
Binary files differ
diff --git a/docs/dev/reference/saemix-3.png b/docs/dev/reference/saemix-3.png
index 13157f91..86ae1f19 100644
--- a/docs/dev/reference/saemix-3.png
+++ b/docs/dev/reference/saemix-3.png
Binary files differ
diff --git a/docs/dev/reference/saemix-4.png b/docs/dev/reference/saemix-4.png
index 1e717cb2..e0c5ce4a 100644
--- a/docs/dev/reference/saemix-4.png
+++ b/docs/dev/reference/saemix-4.png
Binary files differ
diff --git a/docs/dev/reference/saemix.html b/docs/dev/reference/saemix.html
index 5b160959..2c4fd2d7 100644
--- a/docs/dev/reference/saemix.html
+++ b/docs/dev/reference/saemix.html
@@ -237,8 +237,8 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; res &lt;- unlist(res_list)
#&gt; return(res)
#&gt; }
-#&gt; &lt;bytecode: 0x55555c1e7720&gt;
-#&gt; &lt;environment: 0x55555c1eff38&gt;
+#&gt; &lt;bytecode: 0x555555c89340&gt;
+#&gt; &lt;environment: 0x555555c82680&gt;
#&gt; Nb of parameters: 4
#&gt; parameter names: parent_0 log_k_parent log_k_A1 f_parent_ilr_1
#&gt; distribution:
@@ -271,10 +271,10 @@ variances of the deviations of the parameters from these mean values.</p>
nbiter.saemix <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='fl'>200</span>, <span class='fl'>80</span><span class='op'>)</span><span class='op'>)</span>
<span class='va'>f_saemix</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/saemix/man/saemix.html'>saemix</a></span><span class='op'>(</span><span class='va'>m_saemix</span>, <span class='va'>d_saemix</span>, <span class='va'>saemix_options</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Thu Oct 15 11:55:14 2020"
+#&gt; [1] "Thu Oct 15 14:51:26 2020"
#&gt; ..
#&gt; Minimisation finished
-#&gt; [1] "Thu Oct 15 11:57:07 2020"</div><div class='img'><img src='saemix-1.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; Nonlinear mixed-effects model fit by the SAEM algorithm
+#&gt; [1] "Thu Oct 15 14:53:18 2020"</div><div class='img'><img src='saemix-1.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; Nonlinear mixed-effects model fit by the SAEM algorithm
#&gt; -----------------------------------
#&gt; ---- Data ----
#&gt; -----------------------------------
@@ -338,8 +338,8 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; res &lt;- unlist(res_list)
#&gt; return(res)
#&gt; }
-#&gt; &lt;bytecode: 0x55555c1e7720&gt;
-#&gt; &lt;environment: 0x55555c1eff38&gt;
+#&gt; &lt;bytecode: 0x555555c89340&gt;
+#&gt; &lt;environment: 0x555555c82680&gt;
#&gt; Nb of parameters: 4
#&gt; parameter names: parent_0 log_k_parent log_k_A1 f_parent_ilr_1
#&gt; distribution:
@@ -423,7 +423,7 @@ variances of the deviations of the parameters from these mean values.</p>
</div><div class='output co'>#&gt; Plotting convergence plots</div><div class='img'><img src='saemix-2.png' alt='' width='700' height='433' /></div><div class='input'><span class='co'># }</span>
<span class='co'># Synthetic data with two-component error</span>
<span class='va'>sampling_times</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='fl'>0</span>, <span class='fl'>1</span>, <span class='fl'>3</span>, <span class='fl'>7</span>, <span class='fl'>14</span>, <span class='fl'>28</span>, <span class='fl'>60</span>, <span class='fl'>90</span>, <span class='fl'>120</span><span class='op'>)</span>
-<span class='va'>dt50_sfo_in</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>800</span>, <span class='fl'>900</span>, <span class='fl'>1000</span>, <span class='fl'>1111.11</span>, <span class='fl'>1250</span><span class='op'>)</span>
+<span class='va'>dt50_sfo_in</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>80</span>, <span class='fl'>90</span>, <span class='fl'>100</span>, <span class='fl'>111.111</span>, <span class='fl'>125</span><span class='op'>)</span>
<span class='va'>k_in</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/Log.html'>log</a></span><span class='op'>(</span><span class='fl'>2</span><span class='op'>)</span> <span class='op'>/</span> <span class='va'>dt50_sfo_in</span>
<span class='va'>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='op'>)</span><span class='op'>)</span>
@@ -439,7 +439,9 @@ variances of the deviations of the parameters from these mean values.</p>
<span class='fu'><a href='add_err.html'>add_err</a></span><span class='op'>(</span><span class='va'>ds</span>, sdfunc <span class='op'>=</span> <span class='kw'>function</span><span class='op'>(</span><span class='va'>value</span><span class='op'>)</span> <span class='fu'><a href='https://rdrr.io/r/base/MathFun.html'>sqrt</a></span><span class='op'>(</span><span class='fl'>1</span><span class='op'>^</span><span class='fl'>2</span> <span class='op'>+</span> <span class='va'>value</span><span class='op'>^</span><span class='fl'>2</span> <span class='op'>*</span> <span class='fl'>0.07</span><span class='op'>^</span><span class='fl'>2</span><span class='op'>)</span>,
n <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span><span class='op'>[[</span><span class='fl'>1</span><span class='op'>]</span><span class='op'>]</span>
<span class='op'>}</span><span class='op'>)</span>
+<span class='co'># \dontrun{</span>
<span class='va'>f_mmkin_syn</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='va'>ds_sfo_syn</span>, error_model <span class='op'>=</span> <span class='st'>"tc"</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
+<span class='co'># plot(f_mmkin_syn)</span>
<span class='va'>m_saemix_tc</span> <span class='op'>&lt;-</span> <span class='fu'>saemix_model</span><span class='op'>(</span><span class='va'>f_mmkin_syn</span>, cores <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span>
</div><div class='output co'>#&gt;
#&gt;
@@ -481,8 +483,8 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; res &lt;- unlist(res_list)
#&gt; return(res)
#&gt; }
-#&gt; &lt;bytecode: 0x55555c1e7720&gt;
-#&gt; &lt;environment: 0x55555be5b848&gt;
+#&gt; &lt;bytecode: 0x555555c89340&gt;
+#&gt; &lt;environment: 0x55555df58cf8&gt;
#&gt; Nb of parameters: 2
#&gt; parameter names: parent_0 log_k_parent
#&gt; distribution:
@@ -493,11 +495,11 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; parent_0 log_k_parent
#&gt; parent_0 1 0
#&gt; log_k_parent 0 1
-#&gt; Error model: combined , initial values: a.1=2.4206146215511 b.1=0.03831266409084
+#&gt; Error model: combined , initial values: a.1=1.05209877924905 b.1=0.0586479225303944
#&gt; No covariate in the model.
#&gt; Initial values
#&gt; parent_0 log_k_parent
-#&gt; Pop.CondInit 100.2498 -9.33922</div><div class='input'><span class='va'>d_saemix_tc</span> <span class='op'>&lt;-</span> <span class='fu'>saemix_data</span><span class='op'>(</span><span class='va'>f_mmkin_syn</span><span class='op'>)</span>
+#&gt; Pop.CondInit 100.315 -4.962075</div><div class='input'><span class='va'>d_saemix_tc</span> <span class='op'>&lt;-</span> <span class='fu'>saemix_data</span><span class='op'>(</span><span class='va'>f_mmkin_syn</span><span class='op'>)</span>
</div><div class='output co'>#&gt;
#&gt;
#&gt; The following SaemixData object was successfully created:
@@ -508,16 +510,10 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; Structured data: value ~ time + name | ds
#&gt; X variable for graphs: time () </div><div class='input'><span class='va'>f_saemix_tc</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/saemix/man/saemix.html'>saemix</a></span><span class='op'>(</span><span class='va'>m_saemix_tc</span>, <span class='va'>d_saemix_tc</span>, <span class='va'>saemix_options</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Thu Oct 15 11:57:25 2020"
+#&gt; [1] "Thu Oct 15 14:53:35 2020"
#&gt; ..
#&gt; Minimisation finished
-#&gt; [1] "Thu Oct 15 11:58:16 2020"
-#&gt; Error in solve.default(Fth) :
-#&gt; Lapack routine dgesv: system is exactly singular: U[2,2] = 0
-#&gt; Error computing the Fisher Information Matrix: singular system.
-#&gt; Error in solve.default(FO) :
-#&gt; Lapack routine dgesv: system is exactly singular: U[2,2] = 0
-#&gt; Error computing the Fisher Information Matrix: singular system.</div><div class='output co'>#&gt; Nonlinear mixed-effects model fit by the SAEM algorithm
+#&gt; [1] "Thu Oct 15 14:54:25 2020"</div><div class='output co'>#&gt; Nonlinear mixed-effects model fit by the SAEM algorithm
#&gt; -----------------------------------
#&gt; ---- Data ----
#&gt; -----------------------------------
@@ -534,14 +530,14 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; ds time name value mdv cens occ ytype
#&gt; 1 1 0 parent 105.9 0 0 1 1
#&gt; 2 1 0 parent 98.0 0 0 1 1
-#&gt; 3 1 1 parent 97.4 0 0 1 1
-#&gt; 4 1 1 parent 100.5 0 0 1 1
-#&gt; 5 1 3 parent 115.6 0 0 1 1
-#&gt; 6 1 3 parent 105.6 0 0 1 1
-#&gt; 7 1 7 parent 108.6 0 0 1 1
-#&gt; 8 1 7 parent 117.0 0 0 1 1
-#&gt; 9 1 14 parent 107.0 0 0 1 1
-#&gt; 10 1 14 parent 95.8 0 0 1 1
+#&gt; 3 1 1 parent 96.6 0 0 1 1
+#&gt; 4 1 1 parent 99.8 0 0 1 1
+#&gt; 5 1 3 parent 113.0 0 0 1 1
+#&gt; 6 1 3 parent 103.2 0 0 1 1
+#&gt; 7 1 7 parent 102.9 0 0 1 1
+#&gt; 8 1 7 parent 110.8 0 0 1 1
+#&gt; 9 1 14 parent 95.9 0 0 1 1
+#&gt; 10 1 14 parent 85.9 0 0 1 1
#&gt; -----------------------------------
#&gt; ---- Model ----
#&gt; -----------------------------------
@@ -581,8 +577,8 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; res &lt;- unlist(res_list)
#&gt; return(res)
#&gt; }
-#&gt; &lt;bytecode: 0x55555c1e7720&gt;
-#&gt; &lt;environment: 0x55555be5b848&gt;
+#&gt; &lt;bytecode: 0x555555c89340&gt;
+#&gt; &lt;environment: 0x55555df58cf8&gt;
#&gt; Nb of parameters: 2
#&gt; parameter names: parent_0 log_k_parent
#&gt; distribution:
@@ -593,11 +589,11 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; parent_0 log_k_parent
#&gt; parent_0 1 0
#&gt; log_k_parent 0 1
-#&gt; Error model: combined , initial values: a.1=2.4206146215511 b.1=0.03831266409084
+#&gt; Error model: combined , initial values: a.1=1.05209877924905 b.1=0.0586479225303944
#&gt; No covariate in the model.
#&gt; Initial values
#&gt; parent_0 log_k_parent
-#&gt; Pop.CondInit 100.2498 -9.33922
+#&gt; Pop.CondInit 100.315 -4.962075
#&gt; -----------------------------------
#&gt; ---- Key algorithm options ----
#&gt; -----------------------------------
@@ -619,17 +615,17 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; ----------------------------------------------------
#&gt; ----------------- Fixed effects ------------------
#&gt; ----------------------------------------------------
-#&gt; Parameter Estimate SE CV(%)
-#&gt; parent_0 97.44 &lt;NA&gt; &lt;NA&gt;
-#&gt; log_k_parent -56.97 &lt;NA&gt; &lt;NA&gt;
-#&gt; a a.1 -7.12 &lt;NA&gt; &lt;NA&gt;
-#&gt; b b.1 0.15 &lt;NA&gt; &lt;NA&gt;
+#&gt; Parameter Estimate SE CV(%)
+#&gt; parent_0 100.232 1.266 1.3
+#&gt; log_k_parent -4.961 0.089 1.8
+#&gt; a a.1 -0.106 1.211 1142.0
+#&gt; b b.1 0.071 0.017 24.2
#&gt; ----------------------------------------------------
#&gt; ----------- Variance of random effects -----------
#&gt; ----------------------------------------------------
-#&gt; Parameter Estimate SE CV(%)
-#&gt; parent_0 omega2.parent_0 2.8 NA NA
-#&gt; log_k_parent omega2.log_k_parent 750.3 NA NA
+#&gt; Parameter Estimate SE CV(%)
+#&gt; parent_0 omega2.parent_0 3.334 5.024 151
+#&gt; log_k_parent omega2.log_k_parent 0.036 0.024 68
#&gt; ----------------------------------------------------
#&gt; ------ Correlation matrix of random effects ------
#&gt; ----------------------------------------------------
@@ -640,16 +636,16 @@ variances of the deviations of the parameters from these mean values.</p>
#&gt; --------------- Statistical criteria -------------
#&gt; ----------------------------------------------------
#&gt; Likelihood computed by linearisation
-#&gt; -2LL= 623.7744
-#&gt; AIC = 635.7744
-#&gt; BIC = 633.431
+#&gt; -2LL= 575.5586
+#&gt; AIC = 587.5586
+#&gt; BIC = 585.2153
#&gt;
#&gt; Likelihood computed by importance sampling
-#&gt; -2LL= 621.1909
-#&gt; AIC = 633.1909
-#&gt; BIC = 630.8475
+#&gt; -2LL= 575.7797
+#&gt; AIC = 587.7797
+#&gt; BIC = 585.4364
#&gt; ----------------------------------------------------</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/plot-SaemixObject-method.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saemix_tc</span>, plot.type <span class='op'>=</span> <span class='st'>"convergence"</span><span class='op'>)</span>
-</div><div class='img'><img src='saemix-3.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; Plotting convergence plots</div><div class='img'><img src='saemix-4.png' alt='' width='700' height='433' /></div><div class='input'>
+</div><div class='img'><img src='saemix-3.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; Plotting convergence plots</div><div class='img'><img src='saemix-4.png' alt='' width='700' height='433' /></div><div class='input'><span class='co'># }</span>
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
diff --git a/man/saemix.Rd b/man/saemix.Rd
index e18610c9..34ce8be1 100644
--- a/man/saemix.Rd
+++ b/man/saemix.Rd
@@ -53,7 +53,7 @@ plot(f_saemix, plot.type = "convergence")
}
# Synthetic data with two-component error
sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
-dt50_sfo_in <- c(800, 900, 1000, 1111.11, 1250)
+dt50_sfo_in <- c(80, 90, 100, 111.111, 125)
k_in <- log(2) / dt50_sfo_in
SFO <- mkinmod(parent = mkinsub("SFO"))
@@ -71,6 +71,7 @@ ds_sfo_syn <- lapply(ds_sfo_mean, function(ds) {
})
\dontrun{
f_mmkin_syn <- mmkin("SFO", ds_sfo_syn, error_model = "tc", quiet = TRUE)
+# plot(f_mmkin_syn)
m_saemix_tc <- saemix_model(f_mmkin_syn, cores = 1)
d_saemix_tc <- saemix_data(f_mmkin_syn)
f_saemix_tc <- saemix(m_saemix_tc, d_saemix_tc, saemix_options)

Contact - Imprint