From e5d1df9a9b1f0951d7dfbaf24eee4294470b73e2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 17 Nov 2022 14:54:20 +0100 Subject: Complete update of online docs for v1.2.0 --- docs/reference/synthetic_data_for_UBA_2014.html | 258 ++++++++++++------------ 1 file changed, 132 insertions(+), 126 deletions(-) (limited to 'docs/reference/synthetic_data_for_UBA_2014.html') diff --git a/docs/reference/synthetic_data_for_UBA_2014.html b/docs/reference/synthetic_data_for_UBA_2014.html index e9251de3..c00d1b55 100644 --- a/docs/reference/synthetic_data_for_UBA_2014.html +++ b/docs/reference/synthetic_data_for_UBA_2014.html @@ -32,7 +32,7 @@ Compare also the code in the example section to see the degradation models."> mkin - 1.1.0 + 1.2.0 @@ -59,11 +59,14 @@ Compare also the code in the example section to see the degradation models.">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models
  • - Example evaluation of FOCUS Example Dataset Z + Short demo of the multistart method
  • Performance benefit by using compiled model definitions in mkin
  • +
  • + Example evaluation of FOCUS Example Dataset Z +
  • Calculation of time weighted average concentrations with mkin
  • @@ -71,7 +74,10 @@ Compare also the code in the example section to see the degradation models.">Example evaluation of NAFTA SOP Attachment examples
  • - Some benchmark timings + Benchmark timings for mkin +
  • +
  • + Benchmark timings for saem.mmkin
  • @@ -117,7 +123,7 @@ Compare also the code in the example section to see the degradation models.">
    -
    synthetic_data_for_UBA_2014
    +
    synthetic_data_for_UBA_2014
    @@ -141,115 +147,115 @@ Compare also the code in the example section to see the degradation models.">

    Examples

    -
    # \dontrun{
    -# The data have been generated using the following kinetic models
    -m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"),
    -                           M1 = list(type = "SFO", to = "M2"),
    -                           M2 = list(type = "SFO"), use_of_ff = "max")
    +    
    # \dontrun{
    +# The data have been generated using the following kinetic models
    +m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"),
    +                           M1 = list(type = "SFO", to = "M2"),
    +                           M2 = list(type = "SFO"), use_of_ff = "max")
     #> Temporary DLL for differentials generated and loaded
    -
    -
    -m_synth_SFO_par <- mkinmod(parent = list(type = "SFO", to = c("M1", "M2"),
    -                                         sink = FALSE),
    -                           M1 = list(type = "SFO"),
    -                           M2 = list(type = "SFO"), use_of_ff = "max")
    +
    +
    +m_synth_SFO_par <- mkinmod(parent = list(type = "SFO", to = c("M1", "M2"),
    +                                         sink = FALSE),
    +                           M1 = list(type = "SFO"),
    +                           M2 = list(type = "SFO"), use_of_ff = "max")
     #> Temporary DLL for differentials generated and loaded
    -
    -m_synth_DFOP_lin <- mkinmod(parent = list(type = "DFOP", to = "M1"),
    -                            M1 = list(type = "SFO", to = "M2"),
    -                            M2 = list(type = "SFO"), use_of_ff = "max")
    +
    +m_synth_DFOP_lin <- mkinmod(parent = list(type = "DFOP", to = "M1"),
    +                            M1 = list(type = "SFO", to = "M2"),
    +                            M2 = list(type = "SFO"), use_of_ff = "max")
     #> Temporary DLL for differentials generated and loaded
    -
    -m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2"),
    -                                          sink = FALSE),
    -                            M1 = list(type = "SFO"),
    -                            M2 = list(type = "SFO"), use_of_ff = "max")
    +
    +m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2"),
    +                                          sink = FALSE),
    +                            M1 = list(type = "SFO"),
    +                            M2 = list(type = "SFO"), use_of_ff = "max")
     #> Temporary DLL for differentials generated and loaded
    -
    -# The model predictions without intentional error were generated as follows
    -sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
    -
    -d_synth_SFO_lin <- mkinpredict(m_synth_SFO_lin,
    -                               c(k_parent = 0.7, f_parent_to_M1 = 0.8,
    -                                 k_M1 = 0.3, f_M1_to_M2 = 0.7,
    -                                 k_M2 = 0.02),
    -                               c(parent = 100, M1 = 0, M2 = 0),
    -                               sampling_times)
    -
    -d_synth_DFOP_lin <- mkinpredict(m_synth_DFOP_lin,
    -                                c(k1 = 0.2, k2 = 0.02, g = 0.5,
    -                                  f_parent_to_M1 = 0.5, k_M1 = 0.3,
    -                                  f_M1_to_M2 = 0.7, k_M2 = 0.02),
    -                                 c(parent = 100, M1 = 0, M2 = 0),
    -                                 sampling_times)
    -
    -d_synth_SFO_par <- mkinpredict(m_synth_SFO_par,
    -                               c(k_parent = 0.2,
    -                                 f_parent_to_M1 = 0.8, k_M1 = 0.01,
    -                                 f_parent_to_M2 = 0.2, k_M2 = 0.02),
    -                                 c(parent = 100, M1 = 0, M2 = 0),
    -                                 sampling_times)
    -
    -d_synth_DFOP_par <- mkinpredict(m_synth_DFOP_par,
    -                               c(k1 = 0.3, k2 = 0.02, g = 0.7,
    -                                 f_parent_to_M1 = 0.6, k_M1 = 0.04,
    -                                 f_parent_to_M2 = 0.4, k_M2 = 0.01),
    -                                 c(parent = 100, M1 = 0, M2 = 0),
    -                                 sampling_times)
    -
    -# Construct names for datasets with errors
    -d_synth_names = paste0("d_synth_", c("SFO_lin", "SFO_par",
    -                                     "DFOP_lin", "DFOP_par"))
    -
    -# Original function used or adding errors. The add_err function now published
    -# with this package is a slightly generalised version where the names of
    -# secondary compartments that should have an initial value of zero (M1 and M2
    -# in this case) are not hardcoded any more.
    -# add_err = function(d, sdfunc, LOD = 0.1, reps = 2, seed = 123456789)
    -# {
    -#   set.seed(seed)
    -#   d_long = mkin_wide_to_long(d, time = "time")
    -#   d_rep = data.frame(lapply(d_long, rep, each = 2))
    -#   d_rep$value = rnorm(length(d_rep$value), d_rep$value, sdfunc(d_rep$value))
    -#
    -#   d_rep[d_rep$time == 0 & d_rep$name %in% c("M1", "M2"), "value"] <- 0
    -#   d_NA <- transform(d_rep, value = ifelse(value < LOD, NA, value))
    -#   d_NA$value <- round(d_NA$value, 1)
    -#   return(d_NA)
    -# }
    -
    -# The following is the simplified version of the two-component model of Rocke
    -# and Lorenzato (1995)
    -sdfunc_twocomp = function(value, sd_low, rsd_high) {
    -  sqrt(sd_low^2 + value^2 * rsd_high^2)
    -}
    -
    -# Add the errors.
    -for (d_synth_name in d_synth_names)
    -{
    -  d_synth = get(d_synth_name)
    -  assign(paste0(d_synth_name, "_a"), add_err(d_synth, function(value) 3))
    -  assign(paste0(d_synth_name, "_b"), add_err(d_synth, function(value) 7))
    -  assign(paste0(d_synth_name, "_c"), add_err(d_synth,
    -                           function(value) sdfunc_twocomp(value, 0.5, 0.07)))
    -
    -}
    -
    -d_synth_err_names = c(
    -  paste(rep(d_synth_names, each = 3), letters[1:3], sep = "_")
    -)
    -
    -# This is just one example of an evaluation using the kinetic model used for
    -# the generation of the data
    -  fit <- mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data,
    -                 quiet = TRUE)
    -  plot_sep(fit)
    +
    +# The model predictions without intentional error were generated as follows
    +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
    +
    +d_synth_SFO_lin <- mkinpredict(m_synth_SFO_lin,
    +                               c(k_parent = 0.7, f_parent_to_M1 = 0.8,
    +                                 k_M1 = 0.3, f_M1_to_M2 = 0.7,
    +                                 k_M2 = 0.02),
    +                               c(parent = 100, M1 = 0, M2 = 0),
    +                               sampling_times)
    +
    +d_synth_DFOP_lin <- mkinpredict(m_synth_DFOP_lin,
    +                                c(k1 = 0.2, k2 = 0.02, g = 0.5,
    +                                  f_parent_to_M1 = 0.5, k_M1 = 0.3,
    +                                  f_M1_to_M2 = 0.7, k_M2 = 0.02),
    +                                 c(parent = 100, M1 = 0, M2 = 0),
    +                                 sampling_times)
    +
    +d_synth_SFO_par <- mkinpredict(m_synth_SFO_par,
    +                               c(k_parent = 0.2,
    +                                 f_parent_to_M1 = 0.8, k_M1 = 0.01,
    +                                 f_parent_to_M2 = 0.2, k_M2 = 0.02),
    +                                 c(parent = 100, M1 = 0, M2 = 0),
    +                                 sampling_times)
    +
    +d_synth_DFOP_par <- mkinpredict(m_synth_DFOP_par,
    +                               c(k1 = 0.3, k2 = 0.02, g = 0.7,
    +                                 f_parent_to_M1 = 0.6, k_M1 = 0.04,
    +                                 f_parent_to_M2 = 0.4, k_M2 = 0.01),
    +                                 c(parent = 100, M1 = 0, M2 = 0),
    +                                 sampling_times)
    +
    +# Construct names for datasets with errors
    +d_synth_names = paste0("d_synth_", c("SFO_lin", "SFO_par",
    +                                     "DFOP_lin", "DFOP_par"))
    +
    +# Original function used or adding errors. The add_err function now published
    +# with this package is a slightly generalised version where the names of
    +# secondary compartments that should have an initial value of zero (M1 and M2
    +# in this case) are not hardcoded any more.
    +# add_err = function(d, sdfunc, LOD = 0.1, reps = 2, seed = 123456789)
    +# {
    +#   set.seed(seed)
    +#   d_long = mkin_wide_to_long(d, time = "time")
    +#   d_rep = data.frame(lapply(d_long, rep, each = 2))
    +#   d_rep$value = rnorm(length(d_rep$value), d_rep$value, sdfunc(d_rep$value))
    +#
    +#   d_rep[d_rep$time == 0 & d_rep$name %in% c("M1", "M2"), "value"] <- 0
    +#   d_NA <- transform(d_rep, value = ifelse(value < LOD, NA, value))
    +#   d_NA$value <- round(d_NA$value, 1)
    +#   return(d_NA)
    +# }
    +
    +# The following is the simplified version of the two-component model of Rocke
    +# and Lorenzato (1995)
    +sdfunc_twocomp = function(value, sd_low, rsd_high) {
    +  sqrt(sd_low^2 + value^2 * rsd_high^2)
    +}
    +
    +# Add the errors.
    +for (d_synth_name in d_synth_names)
    +{
    +  d_synth = get(d_synth_name)
    +  assign(paste0(d_synth_name, "_a"), add_err(d_synth, function(value) 3))
    +  assign(paste0(d_synth_name, "_b"), add_err(d_synth, function(value) 7))
    +  assign(paste0(d_synth_name, "_c"), add_err(d_synth,
    +                           function(value) sdfunc_twocomp(value, 0.5, 0.07)))
    +
    +}
    +
    +d_synth_err_names = c(
    +  paste(rep(d_synth_names, each = 3), letters[1:3], sep = "_")
    +)
    +
    +# This is just one example of an evaluation using the kinetic model used for
    +# the generation of the data
    +  fit <- mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data,
    +                 quiet = TRUE)
    +  plot_sep(fit)
     
    -  summary(fit)
    -#> mkin version used for fitting:    1.1.0 
    -#> R version used for fitting:       4.2.0 
    -#> Date of fit:     Wed May 18 20:42:21 2022 
    -#> Date of summary: Wed May 18 20:42:21 2022 
    +  summary(fit)
    +#> mkin version used for fitting:    1.2.0 
    +#> R version used for fitting:       4.2.2 
    +#> Date of fit:     Thu Nov 17 14:04:10 2022 
    +#> Date of summary: Thu Nov 17 14:04:11 2022 
     #> 
     #> Equations:
     #> d_parent/dt = - k_parent * parent
    @@ -258,7 +264,7 @@ Compare also the code in the example section to see the degradation models.">#> 
     #> Model predictions using solution type deSolve 
     #> 
    -#> Fitted using 830 model solutions performed in 1.716 s
    +#> Fitted using 833 model solutions performed in 0.574 s
     #> 
     #> Error model: Constant variance 
     #> 
    @@ -310,15 +316,15 @@ Compare also the code in the example section to see the degradation models.">#> log_k_M2         2.819e-02    7.166e-02 -3.929e-01  1.000e+00      -2.658e-01
     #> f_parent_qlogis -4.624e-01   -5.682e-01  7.478e-01 -2.658e-01       1.000e+00
     #> f_M1_qlogis      1.614e-01    4.102e-01 -8.109e-01  5.419e-01      -8.605e-01
    -#> sigma            2.063e-07   -1.980e-07  1.088e-07  1.041e-07       7.820e-09
    +#> sigma           -2.900e-08   -8.030e-09 -2.741e-08  3.938e-08      -2.681e-08
     #>                 f_M1_qlogis      sigma
    -#> parent_0          1.614e-01  2.063e-07
    -#> log_k_parent      4.102e-01 -1.980e-07
    -#> log_k_M1         -8.109e-01  1.088e-07
    -#> log_k_M2          5.419e-01  1.041e-07
    -#> f_parent_qlogis  -8.605e-01  7.820e-09
    -#> f_M1_qlogis       1.000e+00 -6.495e-08
    -#> sigma            -6.495e-08  1.000e+00
    +#> parent_0          1.614e-01 -2.900e-08
    +#> log_k_parent      4.102e-01 -8.030e-09
    +#> log_k_M1         -8.109e-01 -2.741e-08
    +#> log_k_M2          5.419e-01  3.938e-08
    +#> f_parent_qlogis  -8.605e-01 -2.681e-08
    +#> f_M1_qlogis       1.000e+00  4.971e-08
    +#> sigma             4.971e-08  1.000e+00
     #> 
     #> Backtransformed parameters:
     #> Confidence intervals for internally transformed parameters are asymmetric.
    @@ -355,8 +361,8 @@ Compare also the code in the example section to see the degradation models.">#> 
     #> Data:
     #>  time variable observed  predicted residual
    -#>     0   parent    101.5  1.021e+02 -0.56249
    -#>     0   parent    101.2  1.021e+02 -0.86249
    +#>     0   parent    101.5  1.021e+02 -0.56248
    +#>     0   parent    101.2  1.021e+02 -0.86248
     #>     1   parent     53.9  4.873e+01  5.17118
     #>     1   parent     47.5  4.873e+01 -1.22882
     #>     3   parent     10.4  1.111e+01 -0.70773
    @@ -365,8 +371,8 @@ Compare also the code in the example section to see the degradation models.">#>     7   parent      0.3  5.772e-01 -0.27717
     #>    14   parent      3.5  3.264e-03  3.49674
     #>    28   parent      3.2  1.045e-07  3.20000
    -#>    90   parent      0.6  9.534e-10  0.60000
    -#>   120   parent      3.5 -5.941e-10  3.50000
    +#>    90   parent      0.6  9.530e-10  0.60000
    +#>   120   parent      3.5 -5.940e-10  3.50000
     #>     1       M1     36.4  3.479e+01  1.61088
     #>     1       M1     37.4  3.479e+01  2.61088
     #>     3       M1     34.3  3.937e+01 -5.07027
    @@ -376,9 +382,9 @@ Compare also the code in the example section to see the degradation models.">#>    14       M1      5.8  1.995e+00  3.80469
     #>    14       M1      1.2  1.995e+00 -0.79531
     #>    60       M1      0.5  2.111e-06  0.50000
    -#>    90       M1      3.2 -9.675e-10  3.20000
    -#>   120       M1      1.5  7.671e-10  1.50000
    -#>   120       M1      0.6  7.671e-10  0.60000
    +#>    90       M1      3.2 -9.670e-10  3.20000
    +#>   120       M1      1.5  7.670e-10  1.50000
    +#>   120       M1      0.6  7.670e-10  0.60000
     #>     1       M2      4.8  4.455e+00  0.34517
     #>     3       M2     20.9  2.153e+01 -0.62527
     #>     3       M2     19.3  2.153e+01 -2.22527
    @@ -394,7 +400,7 @@ Compare also the code in the example section to see the degradation models.">#>    90       M2     10.8  1.013e+01  0.67130
     #>   120       M2      9.8  5.521e+00  4.27893
     #>   120       M2      3.3  5.521e+00 -2.22107
    -# }
    +# }
     
    @@ -409,7 +415,7 @@ Compare also the code in the example section to see the degradation models.">
    -

    Site built with pkgdown 2.0.3.

    +

    Site built with pkgdown 2.0.6.

    -- cgit v1.2.1