From 272aba066f0d7502e319b7e7f14009318cd44348 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 15 Oct 2020 12:27:40 +0200 Subject: Updating docs of current dev version --- R/saemix.R | 42 ++- docs/dev/404.html | 4 +- docs/dev/articles/index.html | 4 +- docs/dev/articles/mkin.html | 45 +-- .../mkin_files/figure-html/unnamed-chunk-2-1.png | Bin 116140 -> 92716 bytes docs/dev/articles/web_only/NAFTA_examples.html | 154 ++++++---- .../NAFTA_examples_files/figure-html/p10-1.png | Bin 53828 -> 80950 bytes .../NAFTA_examples_files/figure-html/p11-1.png | Bin 51210 -> 77737 bytes .../NAFTA_examples_files/figure-html/p12a-1.png | Bin 54489 -> 83111 bytes .../NAFTA_examples_files/figure-html/p12b-1.png | Bin 47070 -> 72088 bytes .../NAFTA_examples_files/figure-html/p13-1.png | Bin 51343 -> 79358 bytes .../NAFTA_examples_files/figure-html/p14-1.png | Bin 53898 -> 82078 bytes .../NAFTA_examples_files/figure-html/p15a-1.png | Bin 51113 -> 78259 bytes .../NAFTA_examples_files/figure-html/p15b-1.png | Bin 52979 -> 80090 bytes .../NAFTA_examples_files/figure-html/p16-1.png | Bin 62414 -> 95465 bytes .../NAFTA_examples_files/figure-html/p5a-1.png | Bin 55286 -> 84037 bytes .../NAFTA_examples_files/figure-html/p5b-1.png | Bin 53505 -> 81732 bytes .../NAFTA_examples_files/figure-html/p6-1.png | Bin 54907 -> 84055 bytes .../NAFTA_examples_files/figure-html/p7-1.png | Bin 66709 -> 103768 bytes .../NAFTA_examples_files/figure-html/p8-1.png | Bin 61400 -> 94196 bytes .../NAFTA_examples_files/figure-html/p9a-1.png | Bin 53005 -> 80132 bytes .../NAFTA_examples_files/figure-html/p9b-1.png | Bin 49914 -> 77691 bytes docs/dev/authors.html | 4 +- docs/dev/index.html | 7 +- docs/dev/news/index.html | 16 +- docs/dev/pkgdown.css | 4 +- docs/dev/pkgdown.yml | 12 +- docs/dev/reference/endpoints.html | 30 +- docs/dev/reference/index.html | 4 +- docs/dev/reference/saemix-1.png | Bin 31551 -> 50490 bytes docs/dev/reference/saemix-2.png | Bin 58815 -> 60503 bytes docs/dev/reference/saemix-3.png | Bin 0 -> 16942 bytes docs/dev/reference/saemix-4.png | Bin 0 -> 65995 bytes docs/dev/reference/saemix.html | 323 ++++++++++++++++++--- docs/dev/sitemap.xml | 3 + man/saemix.Rd | 26 +- 36 files changed, 522 insertions(+), 156 deletions(-) create mode 100644 docs/dev/reference/saemix-3.png create mode 100644 docs/dev/reference/saemix-4.png diff --git a/R/saemix.R b/R/saemix.R index 24c0f0d0..eb64bf79 100644 --- a/R/saemix.R +++ b/R/saemix.R @@ -25,7 +25,7 @@ #' \dontrun{ #' f_mmkin <- mmkin(list("SFO-SFO" = sfo_sfo), ds, quiet = TRUE) #' library(saemix) -#' m_saemix <- saemix_model(f_mmkin) +#' m_saemix <- saemix_model(f_mmkin, cores = 1) #' d_saemix <- saemix_data(f_mmkin) #' saemix_options <- list(seed = 123456, #' save = FALSE, save.graphs = FALSE, displayProgress = FALSE, @@ -33,6 +33,30 @@ #' f_saemix <- saemix(m_saemix, d_saemix, saemix_options) #' 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) +#' k_in <- log(2) / dt50_sfo_in +#' +#' SFO <- mkinmod(parent = mkinsub("SFO")) +#' +#' pred_sfo <- function(k) { +#' mkinpredict(SFO, c(k_parent = k), +#' c(parent = 100), sampling_times) +#' } +#' +#' ds_sfo_mean <- lapply(k_in, pred_sfo) +#' set.seed(123456L) +#' ds_sfo_syn <- lapply(ds_sfo_mean, function(ds) { +#' add_err(ds, sdfunc = function(value) sqrt(1^2 + value^2 * 0.07^2), +#' n = 1)[[1]] +#' }) +#' f_mmkin_syn <- mmkin("SFO", ds_sfo_syn, error_model = "tc", quiet = TRUE) +#' 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) +#' plot(f_saemix_tc, plot.type = "convergence") +#' #' @return An [saemix::SaemixModel] object. #' @export saemix_model <- function(object, cores = parallel::detectCores()) { @@ -101,9 +125,25 @@ saemix_model <- function(object, cores = parallel::detectCores()) { raneff_0 <- mean_degparms(object, random = TRUE)$random$ds var_raneff_0 <- apply(raneff_0, 2, var) + error.model <- switch(object[[1]]$err_mod, + const = "constant", + tc = "combined", + obs = "constant") + + if (object[[1]]$err_mod == "obs") { + warning("The error model 'obs' (variance by variable) was not transferred to the saemix model") + } + + error.init <- switch(object[[1]]$err_mod, + const = c(a = mean(sapply(object, function(x) x$errparms)), b = 1), + tc = c(a = mean(sapply(object, function(x) x$errparms[1])), + b = mean(sapply(object, function(x) x$errparms[2]))), + obs = c(a = mean(sapply(object, function(x) x$errparms)), b = 1)) + res <- saemixModel(model_function, psi0, "Mixed model generated from mmkin object", transform.par = rep(0, length(degparms_optim)), + error.model = error.model, error.init = error.init, omega.init = diag(var_raneff_0) ) return(res) diff --git a/docs/dev/404.html b/docs/dev/404.html index 9d14af1e..8ca69469 100644 --- a/docs/dev/404.html +++ b/docs/dev/404.html @@ -71,7 +71,7 @@ mkin - 0.9.50.3 + 0.9.50.4 @@ -160,7 +160,7 @@ Content not found. Please use links in the navbar.
-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/dev/articles/index.html b/docs/dev/articles/index.html index b8ba57d8..81d49aa3 100644 --- a/docs/dev/articles/index.html +++ b/docs/dev/articles/index.html @@ -71,7 +71,7 @@ mkin - 0.9.50.3 + 0.9.50.4 @@ -173,7 +173,7 @@
-

Site built with pkgdown 1.5.1.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/dev/articles/mkin.html b/docs/dev/articles/mkin.html index 6865fe96..07627029 100644 --- a/docs/dev/articles/mkin.html +++ b/docs/dev/articles/mkin.html @@ -32,7 +32,7 @@ mkin - 0.9.50.3 + 0.9.50.4 @@ -80,7 +80,7 @@