From 91a5834dd701211f929fd25419dc34561ce3b4e7 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 14 Feb 2025 09:15:20 +0100 Subject: Initialize dev docs --- docs/dev/reference/AIC.mmkin.html | 175 +++++ docs/dev/reference/BIC.mmkin.html | 8 + docs/dev/reference/CAKE_export.html | 178 +++++ docs/dev/reference/D24_2014.html | 218 ++++++ docs/dev/reference/DFOP.solution-1.png | Bin 0 -> 31964 bytes docs/dev/reference/DFOP.solution.html | 155 +++++ docs/dev/reference/Extract.mmkin.html | 187 ++++++ docs/dev/reference/FOCUS_2006_A.html | 8 + docs/dev/reference/FOCUS_2006_B.html | 8 + docs/dev/reference/FOCUS_2006_C.html | 8 + docs/dev/reference/FOCUS_2006_D.html | 8 + docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html | 145 ++++ docs/dev/reference/FOCUS_2006_E.html | 8 + docs/dev/reference/FOCUS_2006_F.html | 8 + docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html | 142 ++++ docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html | 145 ++++ docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html | 139 ++++ docs/dev/reference/FOCUS_2006_datasets.html | 133 ++++ docs/dev/reference/FOMC.solution-1.png | Bin 0 -> 29520 bytes docs/dev/reference/FOMC.solution.html | 166 +++++ docs/dev/reference/HS.solution-1.png | Bin 0 -> 29572 bytes docs/dev/reference/HS.solution.html | 156 +++++ docs/dev/reference/IORE.solution-1.png | Bin 0 -> 30800 bytes docs/dev/reference/IORE.solution.html | 171 +++++ docs/dev/reference/NAFTA_SOP_2015-1.png | Bin 0 -> 63875 bytes docs/dev/reference/NAFTA_SOP_2015.html | 167 +++++ docs/dev/reference/NAFTA_SOP_Appendix_B.html | 8 + docs/dev/reference/NAFTA_SOP_Appendix_D.html | 8 + docs/dev/reference/NAFTA_SOP_Attachment-1.png | Bin 0 -> 65176 bytes docs/dev/reference/NAFTA_SOP_Attachment.html | 156 +++++ docs/dev/reference/SFO.solution-1.png | Bin 0 -> 29614 bytes docs/dev/reference/SFO.solution.html | 143 ++++ docs/dev/reference/SFORB.solution-1.png | Bin 0 -> 31673 bytes docs/dev/reference/SFORB.solution.html | 165 +++++ docs/dev/reference/[.mhmkin.html | 8 + docs/dev/reference/add_err-1.png | Bin 0 -> 109428 bytes docs/dev/reference/add_err-2.png | Bin 0 -> 64140 bytes docs/dev/reference/add_err-3.png | Bin 0 -> 59180 bytes docs/dev/reference/add_err.html | 216 ++++++ docs/dev/reference/anova.saem.mmkin.html | 140 ++++ docs/dev/reference/aw.html | 153 +++++ docs/dev/reference/aw.mixed.mmkin.html | 8 + docs/dev/reference/aw.mkinfit.html | 8 + docs/dev/reference/aw.mmkin.html | 8 + docs/dev/reference/aw.multistart.html | 8 + docs/dev/reference/backtransform_odeparms.html | 8 + docs/dev/reference/best.default.html | 8 + docs/dev/reference/best.html | 8 + docs/dev/reference/check_failed.html | 100 +++ docs/dev/reference/confint.mkinfit.html | 382 +++++++++++ docs/dev/reference/create_deg_func.html | 148 +++++ docs/dev/reference/dimethenamid_2018-1.png | Bin 0 -> 253131 bytes docs/dev/reference/dimethenamid_2018.html | 347 ++++++++++ docs/dev/reference/ds_dfop.html | 8 + docs/dev/reference/ds_dfop_sfo.html | 8 + docs/dev/reference/ds_fomc.html | 8 + docs/dev/reference/ds_hs.html | 8 + docs/dev/reference/ds_mixed-1.png | Bin 0 -> 219327 bytes docs/dev/reference/ds_mixed.html | 208 ++++++ docs/dev/reference/ds_sfo.html | 8 + docs/dev/reference/endpoints.html | 181 +++++ docs/dev/reference/experimental_data_for_UBA-1.png | Bin 0 -> 103371 bytes docs/dev/reference/experimental_data_for_UBA.html | 255 +++++++ docs/dev/reference/f_time_norm_focus.html | 203 ++++++ docs/dev/reference/f_time_norm_focus.mkindsg.html | 8 + docs/dev/reference/f_time_norm_focus.numeric.html | 8 + docs/dev/reference/focus_soil_moisture.html | 123 ++++ docs/dev/reference/get_deg_func.html | 97 +++ docs/dev/reference/hierarchical_kinetics.html | 158 +++++ docs/dev/reference/html_listing.html | 8 + docs/dev/reference/illparms.html | 211 ++++++ docs/dev/reference/illparms.mhmkin.html | 8 + docs/dev/reference/illparms.mkinfit.html | 8 + docs/dev/reference/illparms.mmkin.html | 8 + docs/dev/reference/illparms.saem.mmkin.html | 8 + docs/dev/reference/ilr.html | 163 +++++ docs/dev/reference/index.html | 735 +++++++++++++++++++++ docs/dev/reference/intervals.html | 8 + docs/dev/reference/intervals.saem.mmkin.html | 121 ++++ docs/dev/reference/invilr.html | 8 + docs/dev/reference/llhist.html | 123 ++++ docs/dev/reference/loftest-1.png | Bin 0 -> 40997 bytes docs/dev/reference/loftest-2.png | Bin 0 -> 40551 bytes docs/dev/reference/loftest-3.png | Bin 0 -> 78294 bytes docs/dev/reference/loftest-4.png | Bin 0 -> 75822 bytes docs/dev/reference/loftest-5.png | Bin 0 -> 74615 bytes docs/dev/reference/loftest.html | 299 +++++++++ docs/dev/reference/loftest.mkinfit.html | 8 + docs/dev/reference/logLik.mkinfit.html | 160 +++++ docs/dev/reference/logLik.saem.mmkin.html | 109 +++ docs/dev/reference/logistic.solution-1.png | Bin 0 -> 81046 bytes docs/dev/reference/logistic.solution-2.png | Bin 0 -> 44080 bytes docs/dev/reference/logistic.solution.html | 206 ++++++ docs/dev/reference/lrtest.html | 8 + docs/dev/reference/lrtest.mkinfit.html | 191 ++++++ docs/dev/reference/lrtest.mmkin.html | 8 + docs/dev/reference/max_twa_dfop.html | 8 + docs/dev/reference/max_twa_fomc.html | 8 + docs/dev/reference/max_twa_hs.html | 8 + docs/dev/reference/max_twa_parent.html | 192 ++++++ docs/dev/reference/max_twa_sfo.html | 8 + docs/dev/reference/mccall81_245T-1.png | Bin 0 -> 62916 bytes docs/dev/reference/mccall81_245T.html | 201 ++++++ docs/dev/reference/mean_degparms.html | 134 ++++ docs/dev/reference/mhmkin-1.png | Bin 0 -> 53533 bytes docs/dev/reference/mhmkin-2.png | Bin 0 -> 112620 bytes docs/dev/reference/mhmkin.html | 286 ++++++++ docs/dev/reference/mhmkin.list.html | 8 + docs/dev/reference/mhmkin.mmkin.html | 8 + docs/dev/reference/mixed-1.png | Bin 0 -> 215777 bytes docs/dev/reference/mixed.html | 199 ++++++ docs/dev/reference/mixed.mmkin.html | 8 + docs/dev/reference/mkin_long_to_wide.html | 155 +++++ docs/dev/reference/mkin_wide_to_long.html | 135 ++++ docs/dev/reference/mkinds.html | 219 ++++++ docs/dev/reference/mkindsg.html | 407 ++++++++++++ docs/dev/reference/mkinerrmin.html | 163 +++++ docs/dev/reference/mkinerrplot-1.png | Bin 0 -> 41444 bytes docs/dev/reference/mkinerrplot.html | 201 ++++++ docs/dev/reference/mkinfit-1.png | Bin 0 -> 65304 bytes docs/dev/reference/mkinfit.html | 679 +++++++++++++++++++ docs/dev/reference/mkinmod.html | 382 +++++++++++ docs/dev/reference/mkinparplot-1.png | Bin 0 -> 26968 bytes docs/dev/reference/mkinparplot.html | 128 ++++ docs/dev/reference/mkinplot.html | 115 ++++ docs/dev/reference/mkinpredict.html | 390 +++++++++++ docs/dev/reference/mkinpredict.mkinfit.html | 8 + docs/dev/reference/mkinpredict.mkinmod.html | 8 + docs/dev/reference/mkinresplot-1.png | Bin 0 -> 24037 bytes docs/dev/reference/mkinresplot.html | 203 ++++++ docs/dev/reference/mkinsub.html | 8 + docs/dev/reference/mmkin-1.png | Bin 0 -> 111703 bytes docs/dev/reference/mmkin-2.png | Bin 0 -> 108899 bytes docs/dev/reference/mmkin-3.png | Bin 0 -> 96986 bytes docs/dev/reference/mmkin-4.png | Bin 0 -> 67584 bytes docs/dev/reference/mmkin-5.png | Bin 0 -> 65242 bytes docs/dev/reference/mmkin.html | 239 +++++++ docs/dev/reference/multistart-1.png | Bin 0 -> 68074 bytes docs/dev/reference/multistart-2.png | Bin 0 -> 56348 bytes docs/dev/reference/multistart.html | 212 ++++++ docs/dev/reference/multistart.saem.mmkin.html | 8 + docs/dev/reference/nafta-1.png | Bin 0 -> 63875 bytes docs/dev/reference/nafta.html | 215 ++++++ docs/dev/reference/nlme-1.png | Bin 0 -> 78105 bytes docs/dev/reference/nlme-2.png | Bin 0 -> 90362 bytes docs/dev/reference/nlme.html | 197 ++++++ docs/dev/reference/nlme.mmkin-1.png | Bin 0 -> 123589 bytes docs/dev/reference/nlme.mmkin-2.png | Bin 0 -> 169384 bytes docs/dev/reference/nlme.mmkin-3.png | Bin 0 -> 173476 bytes docs/dev/reference/nlme.mmkin.html | 415 ++++++++++++ docs/dev/reference/nlme_data.html | 8 + docs/dev/reference/nobs.mkinfit.html | 109 +++ docs/dev/reference/parms.html | 250 +++++++ docs/dev/reference/parms.mkinfit.html | 8 + docs/dev/reference/parms.mmkin.html | 8 + docs/dev/reference/parms.multistart.html | 8 + docs/dev/reference/parms.saem.mmkin.html | 8 + docs/dev/reference/parplot.html | 161 +++++ .../reference/parplot.multistart.saem.mmkin.html | 8 + docs/dev/reference/plot.mixed.mmkin-1.png | Bin 0 -> 86863 bytes docs/dev/reference/plot.mixed.mmkin-2.png | Bin 0 -> 174836 bytes docs/dev/reference/plot.mixed.mmkin-3.png | Bin 0 -> 173680 bytes docs/dev/reference/plot.mixed.mmkin-4.png | Bin 0 -> 176755 bytes docs/dev/reference/plot.mixed.mmkin.html | 294 +++++++++ docs/dev/reference/plot.mkinfit-1.png | Bin 0 -> 53909 bytes docs/dev/reference/plot.mkinfit-2.png | Bin 0 -> 74783 bytes docs/dev/reference/plot.mkinfit-3.png | Bin 0 -> 69703 bytes docs/dev/reference/plot.mkinfit-4.png | Bin 0 -> 73776 bytes docs/dev/reference/plot.mkinfit-5.png | Bin 0 -> 66319 bytes docs/dev/reference/plot.mkinfit-6.png | Bin 0 -> 72434 bytes docs/dev/reference/plot.mkinfit-7.png | Bin 0 -> 73460 bytes docs/dev/reference/plot.mkinfit.html | 321 +++++++++ docs/dev/reference/plot.mmkin-1.png | Bin 0 -> 49892 bytes docs/dev/reference/plot.mmkin-2.png | Bin 0 -> 51179 bytes docs/dev/reference/plot.mmkin-3.png | Bin 0 -> 47146 bytes docs/dev/reference/plot.mmkin-4.png | Bin 0 -> 33484 bytes docs/dev/reference/plot.mmkin-5.png | Bin 0 -> 59021 bytes docs/dev/reference/plot.mmkin.html | 222 +++++++ docs/dev/reference/plot.nafta.html | 128 ++++ docs/dev/reference/plot_err.html | 8 + docs/dev/reference/plot_res.html | 8 + docs/dev/reference/plot_sep.html | 8 + docs/dev/reference/print.illparms.mhmkin.html | 8 + docs/dev/reference/print.illparms.mkinfit.html | 8 + docs/dev/reference/print.illparms.mmkin.html | 8 + docs/dev/reference/print.illparms.saem.mmkin.html | 8 + docs/dev/reference/print.mhmkin.html | 8 + docs/dev/reference/print.mixed.mmkin.html | 8 + docs/dev/reference/print.mkinds.html | 8 + docs/dev/reference/print.mkindsg.html | 8 + docs/dev/reference/print.mkinmod.html | 8 + docs/dev/reference/print.mmkin.html | 8 + docs/dev/reference/print.multistart.html | 8 + docs/dev/reference/print.nafta.html | 8 + docs/dev/reference/print.nlme.mmkin.html | 8 + docs/dev/reference/print.saem.mmkin.html | 8 + docs/dev/reference/print.status.mhmkin.html | 8 + docs/dev/reference/print.status.mmkin.html | 8 + docs/dev/reference/print.summary.mkinfit.html | 8 + docs/dev/reference/print.summary.mmkin.html | 8 + docs/dev/reference/print.summary.nlme.mmkin.html | 8 + docs/dev/reference/print.summary.saem.mmkin.html | 8 + docs/dev/reference/read_spreadsheet.html | 155 +++++ docs/dev/reference/reexports.html | 118 ++++ docs/dev/reference/residuals.mkinfit.html | 121 ++++ docs/dev/reference/saem-1.png | Bin 0 -> 55172 bytes docs/dev/reference/saem-2.png | Bin 0 -> 49938 bytes docs/dev/reference/saem-3.png | Bin 0 -> 128590 bytes docs/dev/reference/saem-4.png | Bin 0 -> 174573 bytes docs/dev/reference/saem.html | 731 ++++++++++++++++++++ docs/dev/reference/saem.mmkin.html | 8 + docs/dev/reference/saemix_data.html | 8 + docs/dev/reference/saemix_model.html | 8 + docs/dev/reference/schaefer07_complex_case-1.png | Bin 0 -> 67631 bytes docs/dev/reference/schaefer07_complex_case.html | 175 +++++ docs/dev/reference/schaefer07_complex_results.html | 8 + docs/dev/reference/set_nd_nq.html | 234 +++++++ docs/dev/reference/set_nd_nq_focus.html | 8 + docs/dev/reference/sigma_twocomp-1.png | Bin 0 -> 44956 bytes docs/dev/reference/sigma_twocomp.html | 169 +++++ docs/dev/reference/status.html | 145 ++++ docs/dev/reference/status.mhmkin.html | 8 + docs/dev/reference/status.mmkin.html | 8 + docs/dev/reference/summary.mkinfit.html | 290 ++++++++ docs/dev/reference/summary.mmkin.html | 155 +++++ docs/dev/reference/summary.nlme.mmkin.html | 391 +++++++++++ docs/dev/reference/summary.saem.mmkin.html | 631 ++++++++++++++++++ docs/dev/reference/summary_listing.html | 119 ++++ .../reference/synthetic_data_for_UBA_2014-1.png | Bin 0 -> 67584 bytes .../dev/reference/synthetic_data_for_UBA_2014.html | 413 ++++++++++++ docs/dev/reference/test_data_from_UBA_2014-1.png | Bin 0 -> 57059 bytes docs/dev/reference/test_data_from_UBA_2014-2.png | Bin 0 -> 73973 bytes docs/dev/reference/test_data_from_UBA_2014.html | 195 ++++++ docs/dev/reference/tex_listing.html | 8 + docs/dev/reference/transform_odeparms.html | 293 ++++++++ docs/dev/reference/update.mkinfit-1.png | Bin 0 -> 44121 bytes docs/dev/reference/update.mkinfit-2.png | Bin 0 -> 44072 bytes docs/dev/reference/update.mkinfit.html | 138 ++++ docs/dev/reference/update.nlme.mmkin.html | 8 + docs/dev/reference/which.best.default.html | 8 + docs/dev/reference/which.best.html | 8 + 241 files changed, 19875 insertions(+) create mode 100644 docs/dev/reference/AIC.mmkin.html create mode 100644 docs/dev/reference/BIC.mmkin.html create mode 100644 docs/dev/reference/CAKE_export.html create mode 100644 docs/dev/reference/D24_2014.html create mode 100644 docs/dev/reference/DFOP.solution-1.png create mode 100644 docs/dev/reference/DFOP.solution.html create mode 100644 docs/dev/reference/Extract.mmkin.html create mode 100644 docs/dev/reference/FOCUS_2006_A.html create mode 100644 docs/dev/reference/FOCUS_2006_B.html create mode 100644 docs/dev/reference/FOCUS_2006_C.html create mode 100644 docs/dev/reference/FOCUS_2006_D.html create mode 100644 docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html create mode 100644 docs/dev/reference/FOCUS_2006_E.html create mode 100644 docs/dev/reference/FOCUS_2006_F.html create mode 100644 docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html create mode 100644 docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html create mode 100644 docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html create mode 100644 docs/dev/reference/FOCUS_2006_datasets.html create mode 100644 docs/dev/reference/FOMC.solution-1.png create mode 100644 docs/dev/reference/FOMC.solution.html create mode 100644 docs/dev/reference/HS.solution-1.png create mode 100644 docs/dev/reference/HS.solution.html create mode 100644 docs/dev/reference/IORE.solution-1.png create mode 100644 docs/dev/reference/IORE.solution.html create mode 100644 docs/dev/reference/NAFTA_SOP_2015-1.png create mode 100644 docs/dev/reference/NAFTA_SOP_2015.html create mode 100644 docs/dev/reference/NAFTA_SOP_Appendix_B.html create mode 100644 docs/dev/reference/NAFTA_SOP_Appendix_D.html create mode 100644 docs/dev/reference/NAFTA_SOP_Attachment-1.png create mode 100644 docs/dev/reference/NAFTA_SOP_Attachment.html create mode 100644 docs/dev/reference/SFO.solution-1.png create mode 100644 docs/dev/reference/SFO.solution.html create mode 100644 docs/dev/reference/SFORB.solution-1.png create mode 100644 docs/dev/reference/SFORB.solution.html create mode 100644 docs/dev/reference/[.mhmkin.html create mode 100644 docs/dev/reference/add_err-1.png create mode 100644 docs/dev/reference/add_err-2.png create mode 100644 docs/dev/reference/add_err-3.png create mode 100644 docs/dev/reference/add_err.html create mode 100644 docs/dev/reference/anova.saem.mmkin.html create mode 100644 docs/dev/reference/aw.html create mode 100644 docs/dev/reference/aw.mixed.mmkin.html create mode 100644 docs/dev/reference/aw.mkinfit.html create mode 100644 docs/dev/reference/aw.mmkin.html create mode 100644 docs/dev/reference/aw.multistart.html create mode 100644 docs/dev/reference/backtransform_odeparms.html create mode 100644 docs/dev/reference/best.default.html create mode 100644 docs/dev/reference/best.html create mode 100644 docs/dev/reference/check_failed.html create mode 100644 docs/dev/reference/confint.mkinfit.html create mode 100644 docs/dev/reference/create_deg_func.html create mode 100644 docs/dev/reference/dimethenamid_2018-1.png create mode 100644 docs/dev/reference/dimethenamid_2018.html create mode 100644 docs/dev/reference/ds_dfop.html create mode 100644 docs/dev/reference/ds_dfop_sfo.html create mode 100644 docs/dev/reference/ds_fomc.html create mode 100644 docs/dev/reference/ds_hs.html create mode 100644 docs/dev/reference/ds_mixed-1.png create mode 100644 docs/dev/reference/ds_mixed.html create mode 100644 docs/dev/reference/ds_sfo.html create mode 100644 docs/dev/reference/endpoints.html create mode 100644 docs/dev/reference/experimental_data_for_UBA-1.png create mode 100644 docs/dev/reference/experimental_data_for_UBA.html create mode 100644 docs/dev/reference/f_time_norm_focus.html create mode 100644 docs/dev/reference/f_time_norm_focus.mkindsg.html create mode 100644 docs/dev/reference/f_time_norm_focus.numeric.html create mode 100644 docs/dev/reference/focus_soil_moisture.html create mode 100644 docs/dev/reference/get_deg_func.html create mode 100644 docs/dev/reference/hierarchical_kinetics.html create mode 100644 docs/dev/reference/html_listing.html create mode 100644 docs/dev/reference/illparms.html create mode 100644 docs/dev/reference/illparms.mhmkin.html create mode 100644 docs/dev/reference/illparms.mkinfit.html create mode 100644 docs/dev/reference/illparms.mmkin.html create mode 100644 docs/dev/reference/illparms.saem.mmkin.html create mode 100644 docs/dev/reference/ilr.html create mode 100644 docs/dev/reference/index.html create mode 100644 docs/dev/reference/intervals.html create mode 100644 docs/dev/reference/intervals.saem.mmkin.html create mode 100644 docs/dev/reference/invilr.html create mode 100644 docs/dev/reference/llhist.html create mode 100644 docs/dev/reference/loftest-1.png create mode 100644 docs/dev/reference/loftest-2.png create mode 100644 docs/dev/reference/loftest-3.png create mode 100644 docs/dev/reference/loftest-4.png create mode 100644 docs/dev/reference/loftest-5.png create mode 100644 docs/dev/reference/loftest.html create mode 100644 docs/dev/reference/loftest.mkinfit.html create mode 100644 docs/dev/reference/logLik.mkinfit.html create mode 100644 docs/dev/reference/logLik.saem.mmkin.html create mode 100644 docs/dev/reference/logistic.solution-1.png create mode 100644 docs/dev/reference/logistic.solution-2.png create mode 100644 docs/dev/reference/logistic.solution.html create mode 100644 docs/dev/reference/lrtest.html create mode 100644 docs/dev/reference/lrtest.mkinfit.html create mode 100644 docs/dev/reference/lrtest.mmkin.html create mode 100644 docs/dev/reference/max_twa_dfop.html create mode 100644 docs/dev/reference/max_twa_fomc.html create mode 100644 docs/dev/reference/max_twa_hs.html create mode 100644 docs/dev/reference/max_twa_parent.html create mode 100644 docs/dev/reference/max_twa_sfo.html create mode 100644 docs/dev/reference/mccall81_245T-1.png create mode 100644 docs/dev/reference/mccall81_245T.html create mode 100644 docs/dev/reference/mean_degparms.html create mode 100644 docs/dev/reference/mhmkin-1.png create mode 100644 docs/dev/reference/mhmkin-2.png create mode 100644 docs/dev/reference/mhmkin.html create mode 100644 docs/dev/reference/mhmkin.list.html create mode 100644 docs/dev/reference/mhmkin.mmkin.html create mode 100644 docs/dev/reference/mixed-1.png create mode 100644 docs/dev/reference/mixed.html create mode 100644 docs/dev/reference/mixed.mmkin.html create mode 100644 docs/dev/reference/mkin_long_to_wide.html create mode 100644 docs/dev/reference/mkin_wide_to_long.html create mode 100644 docs/dev/reference/mkinds.html create mode 100644 docs/dev/reference/mkindsg.html create mode 100644 docs/dev/reference/mkinerrmin.html create mode 100644 docs/dev/reference/mkinerrplot-1.png create mode 100644 docs/dev/reference/mkinerrplot.html create mode 100644 docs/dev/reference/mkinfit-1.png create mode 100644 docs/dev/reference/mkinfit.html create mode 100644 docs/dev/reference/mkinmod.html create mode 100644 docs/dev/reference/mkinparplot-1.png create mode 100644 docs/dev/reference/mkinparplot.html create mode 100644 docs/dev/reference/mkinplot.html create mode 100644 docs/dev/reference/mkinpredict.html create mode 100644 docs/dev/reference/mkinpredict.mkinfit.html create mode 100644 docs/dev/reference/mkinpredict.mkinmod.html create mode 100644 docs/dev/reference/mkinresplot-1.png create mode 100644 docs/dev/reference/mkinresplot.html create mode 100644 docs/dev/reference/mkinsub.html create mode 100644 docs/dev/reference/mmkin-1.png create mode 100644 docs/dev/reference/mmkin-2.png create mode 100644 docs/dev/reference/mmkin-3.png create mode 100644 docs/dev/reference/mmkin-4.png create mode 100644 docs/dev/reference/mmkin-5.png create mode 100644 docs/dev/reference/mmkin.html create mode 100644 docs/dev/reference/multistart-1.png create mode 100644 docs/dev/reference/multistart-2.png create mode 100644 docs/dev/reference/multistart.html create mode 100644 docs/dev/reference/multistart.saem.mmkin.html create mode 100644 docs/dev/reference/nafta-1.png create mode 100644 docs/dev/reference/nafta.html create mode 100644 docs/dev/reference/nlme-1.png create mode 100644 docs/dev/reference/nlme-2.png create mode 100644 docs/dev/reference/nlme.html create mode 100644 docs/dev/reference/nlme.mmkin-1.png create mode 100644 docs/dev/reference/nlme.mmkin-2.png create mode 100644 docs/dev/reference/nlme.mmkin-3.png create mode 100644 docs/dev/reference/nlme.mmkin.html create mode 100644 docs/dev/reference/nlme_data.html create mode 100644 docs/dev/reference/nobs.mkinfit.html create mode 100644 docs/dev/reference/parms.html create mode 100644 docs/dev/reference/parms.mkinfit.html create mode 100644 docs/dev/reference/parms.mmkin.html create mode 100644 docs/dev/reference/parms.multistart.html create mode 100644 docs/dev/reference/parms.saem.mmkin.html create mode 100644 docs/dev/reference/parplot.html create mode 100644 docs/dev/reference/parplot.multistart.saem.mmkin.html create mode 100644 docs/dev/reference/plot.mixed.mmkin-1.png create mode 100644 docs/dev/reference/plot.mixed.mmkin-2.png create mode 100644 docs/dev/reference/plot.mixed.mmkin-3.png create mode 100644 docs/dev/reference/plot.mixed.mmkin-4.png create mode 100644 docs/dev/reference/plot.mixed.mmkin.html create mode 100644 docs/dev/reference/plot.mkinfit-1.png create mode 100644 docs/dev/reference/plot.mkinfit-2.png create mode 100644 docs/dev/reference/plot.mkinfit-3.png create mode 100644 docs/dev/reference/plot.mkinfit-4.png create mode 100644 docs/dev/reference/plot.mkinfit-5.png create mode 100644 docs/dev/reference/plot.mkinfit-6.png create mode 100644 docs/dev/reference/plot.mkinfit-7.png create mode 100644 docs/dev/reference/plot.mkinfit.html create mode 100644 docs/dev/reference/plot.mmkin-1.png create mode 100644 docs/dev/reference/plot.mmkin-2.png create mode 100644 docs/dev/reference/plot.mmkin-3.png create mode 100644 docs/dev/reference/plot.mmkin-4.png create mode 100644 docs/dev/reference/plot.mmkin-5.png create mode 100644 docs/dev/reference/plot.mmkin.html create mode 100644 docs/dev/reference/plot.nafta.html create mode 100644 docs/dev/reference/plot_err.html create mode 100644 docs/dev/reference/plot_res.html create mode 100644 docs/dev/reference/plot_sep.html create mode 100644 docs/dev/reference/print.illparms.mhmkin.html create mode 100644 docs/dev/reference/print.illparms.mkinfit.html create mode 100644 docs/dev/reference/print.illparms.mmkin.html create mode 100644 docs/dev/reference/print.illparms.saem.mmkin.html create mode 100644 docs/dev/reference/print.mhmkin.html create mode 100644 docs/dev/reference/print.mixed.mmkin.html create mode 100644 docs/dev/reference/print.mkinds.html create mode 100644 docs/dev/reference/print.mkindsg.html create mode 100644 docs/dev/reference/print.mkinmod.html create mode 100644 docs/dev/reference/print.mmkin.html create mode 100644 docs/dev/reference/print.multistart.html create mode 100644 docs/dev/reference/print.nafta.html create mode 100644 docs/dev/reference/print.nlme.mmkin.html create mode 100644 docs/dev/reference/print.saem.mmkin.html create mode 100644 docs/dev/reference/print.status.mhmkin.html create mode 100644 docs/dev/reference/print.status.mmkin.html create mode 100644 docs/dev/reference/print.summary.mkinfit.html create mode 100644 docs/dev/reference/print.summary.mmkin.html create mode 100644 docs/dev/reference/print.summary.nlme.mmkin.html create mode 100644 docs/dev/reference/print.summary.saem.mmkin.html create mode 100644 docs/dev/reference/read_spreadsheet.html create mode 100644 docs/dev/reference/reexports.html create mode 100644 docs/dev/reference/residuals.mkinfit.html create mode 100644 docs/dev/reference/saem-1.png create mode 100644 docs/dev/reference/saem-2.png create mode 100644 docs/dev/reference/saem-3.png create mode 100644 docs/dev/reference/saem-4.png create mode 100644 docs/dev/reference/saem.html create mode 100644 docs/dev/reference/saem.mmkin.html create mode 100644 docs/dev/reference/saemix_data.html create mode 100644 docs/dev/reference/saemix_model.html create mode 100644 docs/dev/reference/schaefer07_complex_case-1.png create mode 100644 docs/dev/reference/schaefer07_complex_case.html create mode 100644 docs/dev/reference/schaefer07_complex_results.html create mode 100644 docs/dev/reference/set_nd_nq.html create mode 100644 docs/dev/reference/set_nd_nq_focus.html create mode 100644 docs/dev/reference/sigma_twocomp-1.png create mode 100644 docs/dev/reference/sigma_twocomp.html create mode 100644 docs/dev/reference/status.html create mode 100644 docs/dev/reference/status.mhmkin.html create mode 100644 docs/dev/reference/status.mmkin.html create mode 100644 docs/dev/reference/summary.mkinfit.html create mode 100644 docs/dev/reference/summary.mmkin.html create mode 100644 docs/dev/reference/summary.nlme.mmkin.html create mode 100644 docs/dev/reference/summary.saem.mmkin.html create mode 100644 docs/dev/reference/summary_listing.html create mode 100644 docs/dev/reference/synthetic_data_for_UBA_2014-1.png create mode 100644 docs/dev/reference/synthetic_data_for_UBA_2014.html create mode 100644 docs/dev/reference/test_data_from_UBA_2014-1.png create mode 100644 docs/dev/reference/test_data_from_UBA_2014-2.png create mode 100644 docs/dev/reference/test_data_from_UBA_2014.html create mode 100644 docs/dev/reference/tex_listing.html create mode 100644 docs/dev/reference/transform_odeparms.html create mode 100644 docs/dev/reference/update.mkinfit-1.png create mode 100644 docs/dev/reference/update.mkinfit-2.png create mode 100644 docs/dev/reference/update.mkinfit.html create mode 100644 docs/dev/reference/update.nlme.mmkin.html create mode 100644 docs/dev/reference/which.best.default.html create mode 100644 docs/dev/reference/which.best.html (limited to 'docs/dev/reference') diff --git a/docs/dev/reference/AIC.mmkin.html b/docs/dev/reference/AIC.mmkin.html new file mode 100644 index 00000000..06b92093 --- /dev/null +++ b/docs/dev/reference/AIC.mmkin.html @@ -0,0 +1,175 @@ + +Calculate the AIC for a column of an mmkin object — AIC.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Provides a convenient way to compare different kinetic models fitted to the +same dataset.

+
+ +
+

Usage

+
# S3 method for class 'mmkin'
+AIC(object, ..., k = 2)
+
+# S3 method for class 'mmkin'
+BIC(object, ...)
+
+ +
+

Arguments

+ + +
object
+

An object of class mmkin, containing only one +column.

+ + +
...
+

For compatibility with the generic method

+ + +
k
+

As in the generic method

+ +
+
+

Value

+

As in the generic method (a numeric value for single fits, or a +dataframe if there are several fits in the column).

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+   # skip, as it takes > 10 s on winbuilder
+  f <- mmkin(c("SFO", "FOMC", "DFOP"),
+    list("FOCUS A" = FOCUS_2006_A,
+         "FOCUS C" = FOCUS_2006_C), cores = 1, quiet = TRUE)
+#> Warning: Optimisation did not converge:
+#> false convergence (8)
+  # We get a warning because the FOMC model does not converge for the
+  # FOCUS A dataset, as it is well described by SFO
+
+  AIC(f["SFO", "FOCUS A"]) # We get a single number for a single fit
+#> [1] 55.28197
+  AIC(f[["SFO", "FOCUS A"]]) # or when extracting an mkinfit object
+#> [1] 55.28197
+
+  # For FOCUS A, the models fit almost equally well, so the higher the number
+  # of parameters, the higher (worse) the AIC
+  AIC(f[, "FOCUS A"])
+#>      df      AIC
+#> SFO   3 55.28197
+#> FOMC  4 57.28198
+#> DFOP  5 59.28197
+  AIC(f[, "FOCUS A"], k = 0) # If we do not penalize additional parameters, we get nearly the same
+#>      df      AIC
+#> SFO   3 49.28197
+#> FOMC  4 49.28198
+#> DFOP  5 49.28197
+  BIC(f[, "FOCUS A"])        # Comparing the BIC gives a very similar picture
+#>      df      BIC
+#> SFO   3 55.52030
+#> FOMC  4 57.59974
+#> DFOP  5 59.67918
+
+  # For FOCUS C, the more complex models fit better
+  AIC(f[, "FOCUS C"])
+#>      df      AIC
+#> SFO   3 59.29336
+#> FOMC  4 44.68652
+#> DFOP  5 29.02372
+  BIC(f[, "FOCUS C"])
+#>      df      BIC
+#> SFO   3 59.88504
+#> FOMC  4 45.47542
+#> DFOP  5 30.00984
+  
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/BIC.mmkin.html b/docs/dev/reference/BIC.mmkin.html new file mode 100644 index 00000000..d84916d6 --- /dev/null +++ b/docs/dev/reference/BIC.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/CAKE_export.html b/docs/dev/reference/CAKE_export.html new file mode 100644 index 00000000..026bc3da --- /dev/null +++ b/docs/dev/reference/CAKE_export.html @@ -0,0 +1,178 @@ + +Export a list of datasets format to a CAKE study file — CAKE_export • mkin + Skip to contents + + +
+
+
+ +
+

In addition to the datasets, the pathways in the degradation model can be +specified as well.

+
+ +
+

Usage

+
CAKE_export(
+  ds,
+  map = c(parent = "Parent"),
+  links = NA,
+  filename = "CAKE_export.csf",
+  path = ".",
+  overwrite = FALSE,
+  study = "Degradinol aerobic soil degradation",
+  description = "",
+  time_unit = "days",
+  res_unit = "% AR",
+  comment = "",
+  date = Sys.Date(),
+  optimiser = "IRLS"
+)
+
+ +
+

Arguments

+ + +
ds
+

A named list of datasets in long format as compatible with +mkinfit.

+ + +
map
+

A character vector with CAKE compartment names (Parent, A1, ...), +named with the names used in the list of datasets.

+ + + +

An optional character vector of target compartments, named with +the names of the source compartments. In order to make this easier, the +names are used as in the datasets supplied.

+ + +
filename
+

Where to write the result. Should end in .csf in order to be +compatible with CAKE.

+ + +
path
+

An optional path to the output file.

+ + +
overwrite
+

If TRUE, existing files are overwritten.

+ + +
study
+

The name of the study.

+ + +
description
+

An optional description.

+ + +
time_unit
+

The time unit for the residue data.

+ + +
res_unit
+

The unit used for the residues.

+ + +
comment
+

An optional comment.

+ + +
date
+

The date of file creation.

+ + +
optimiser
+

Can be OLS or IRLS.

+ +
+
+

Value

+

The function is called for its side effect.

+
+
+

Author

+

Johannes Ranke

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/D24_2014.html b/docs/dev/reference/D24_2014.html new file mode 100644 index 00000000..890e91d8 --- /dev/null +++ b/docs/dev/reference/D24_2014.html @@ -0,0 +1,218 @@ + +Aerobic soil degradation data on 2,4-D from the EU assessment in 2014 — D24_2014 • mkin + Skip to contents + + +
+
+
+ +
+

The five datasets were extracted from the active substance evaluation dossier +published by EFSA. Kinetic evaluations shown for these datasets are intended +to illustrate and advance kinetic modelling. The fact that these data and +some results are shown here does not imply a license to use them in the +context of pesticide registrations, as the use of the data may be +constrained by data protection regulations.

+
+ +
+

Usage

+
D24_2014
+
+ +
+

Format

+

An mkindsg object grouping five datasets

+
+
+

Source

+

Hellenic Ministry of Rural Development and Agriculture (2014) +Final addendum to the Renewal Assessment Report - public version - 2,4-D +Volume 3 Annex B.8 Fate and behaviour in the environment +https://open.efsa.europa.eu/study-inventory/EFSA-Q-2013-00811

+
+
+

Details

+

Data for the first dataset are from p. 685. Data for the other four +datasets were used in the preprocessed versions given in the kinetics +section (p. 761ff.), with the exception of residues smaller than 1 for DCP +in the soil from Site I2, where the values given on p. 694 were used.

+

The R code used to create this data object is installed with this package +in the 'dataset_generation' directory. In the code, page numbers are given for +specific pieces of information in the comments.

+
+ +
+

Examples

+
print(D24_2014)
+#> <mkindsg> holding 5 mkinds objects
+#> Title $title:  Aerobic soil degradation data on 2,4-D from the EU assessment in 2014 
+#> Occurrence of observed compounds $observed_n:
+#> D24 DCP DCA 
+#>   5   4   4 
+#> Time normalisation factors $f_time_norm:
+#> [1] 1.6062378 0.7118732 0.7156063 0.7156063 0.8977124
+#> Meta information $meta:
+#>                                 study usda_soil_type study_moisture_ref_type
+#> Mississippi                Cohen 1991      Silt loam                    <NA>
+#> Fayette     Liu and Adelfinskaya 2011      Silt loam                     pF1
+#> RefSol 03-G Liu and Adelfinskaya 2011           Loam                     pF1
+#> Site E1     Liu and Adelfinskaya 2011           Loam                     pF1
+#> Site I2     Liu and Adelfinskaya 2011     Loamy sand                     pF1
+#>             rel_moisture temperature
+#> Mississippi           NA          25
+#> Fayette              0.5          20
+#> RefSol 03-G          0.5          20
+#> Site E1              0.5          20
+#> Site I2              0.5          20
+# \dontrun{
+print(D24_2014$ds[[1]], data = TRUE)
+#> <mkinds> with $title:  Mississippi 
+#> Observed compounds $observed:  D24 
+#> Sampling times $sampling_times:
+#> 0, 2, 4, 7, 15, 24, 35, 56, 71, 114, 183, 273, 365 
+#> With a maximum of  1  replicates
+#>    time  D24
+#> 1     0 96.8
+#> 2     2 81.0
+#> 3     4 81.7
+#> 4     7 88.2
+#> 5    15 66.3
+#> 6    24 72.9
+#> 7    35 62.6
+#> 8    56 54.6
+#> 9    71 35.2
+#> 10  114 18.0
+#> 11  183 11.3
+#> 12  273  9.9
+#> 13  365  6.3
+m_D24 = mkinmod(D24 = mkinsub("SFO", to = "DCP"),
+  DCP = mkinsub("SFO", to = "DCA"),
+  DCA = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+print(m_D24)
+#> <mkinmod> model generated with
+#> Use of formation fractions $use_of_ff: max 
+#> Specification $spec:
+#> $D24
+#> $type: SFO; $to: DCP; $sink: TRUE
+#> $DCP
+#> $type: SFO; $to: DCA; $sink: TRUE
+#> $DCA
+#> $type: SFO; $sink: TRUE
+#> Coefficient matrix $coefmat available
+#> Compiled model $cf available
+#> Differential equations:
+#> d_D24/dt = - k_D24 * D24
+#> d_DCP/dt = + f_D24_to_DCP * k_D24 * D24 - k_DCP * DCP
+#> d_DCA/dt = + f_DCP_to_DCA * k_DCP * DCP - k_DCA * DCA
+m_D24_2 = mkinmod(D24 = mkinsub("DFOP", to = "DCP"),
+  DCP = mkinsub("SFO", to = "DCA"),
+  DCA = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+print(m_D24_2)
+#> <mkinmod> model generated with
+#> Use of formation fractions $use_of_ff: max 
+#> Specification $spec:
+#> $D24
+#> $type: DFOP; $to: DCP; $sink: TRUE
+#> $DCP
+#> $type: SFO; $to: DCA; $sink: TRUE
+#> $DCA
+#> $type: SFO; $sink: TRUE
+#> Compiled model $cf available
+#> Differential equations:
+#> d_D24/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * D24
+#> d_DCP/dt = + f_D24_to_DCP * ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
+#>            exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2
+#>            * time))) * D24 - k_DCP * DCP
+#> d_DCA/dt = + f_DCP_to_DCA * k_DCP * DCP - k_DCA * DCA
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/DFOP.solution-1.png b/docs/dev/reference/DFOP.solution-1.png new file mode 100644 index 00000000..6b78836f Binary files /dev/null and b/docs/dev/reference/DFOP.solution-1.png differ diff --git a/docs/dev/reference/DFOP.solution.html b/docs/dev/reference/DFOP.solution.html new file mode 100644 index 00000000..633e909c --- /dev/null +++ b/docs/dev/reference/DFOP.solution.html @@ -0,0 +1,155 @@ + +Double First-Order in Parallel kinetics — DFOP.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing decline from a defined starting value using the sum of +two exponential decline functions.

+
+ +
+

Usage

+
DFOP.solution(t, parent_0, k1, k2, g)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
k1
+

First kinetic constant.

+ + +
k2
+

Second kinetic constant.

+ + +
g
+

Fraction of the starting value declining according to the first +kinetic constant.

+ +
+
+

Value

+

The value of the response variable at time t.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

See also

+ +
+ +
+

Examples

+

+  plot(function(x) DFOP.solution(x, 100, 5, 0.5, 0.3), 0, 4, ylim = c(0,100))
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/Extract.mmkin.html b/docs/dev/reference/Extract.mmkin.html new file mode 100644 index 00000000..a7b231f4 --- /dev/null +++ b/docs/dev/reference/Extract.mmkin.html @@ -0,0 +1,187 @@ + +Subsetting method for mmkin objects — [.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Subsetting method for mmkin objects

+
+ +
+

Usage

+
# S3 method for class 'mmkin'
+x[i, j, ..., drop = FALSE]
+
+ +
+

Arguments

+ + +
x
+

An mmkin object

+ + +
i
+

Row index selecting the fits for specific models

+ + +
j
+

Column index selecting the fits to specific datasets

+ + +
...
+

Not used, only there to satisfy the generic method definition

+ + +
drop
+

If FALSE, the method always returns an mmkin object, otherwise +either a list of mkinfit objects or a single mkinfit object.

+ +
+
+

Value

+

An object of class mmkin.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  # Only use one core, to pass R CMD check --as-cran
+  fits <- mmkin(c("SFO", "FOMC"), list(B = FOCUS_2006_B, C = FOCUS_2006_C),
+                cores = 1, quiet = TRUE)
+  fits["FOMC", ]
+#> <mmkin> object
+#> Status of individual fits:
+#> 
+#>       dataset
+#> model  B  C 
+#>   FOMC OK OK
+#> 
+#> OK: No warnings
+  fits[, "B"]
+#> <mmkin> object
+#> Status of individual fits:
+#> 
+#>       dataset
+#> model  B 
+#>   SFO  OK
+#>   FOMC OK
+#> 
+#> OK: No warnings
+  fits["SFO", "B"]
+#> <mmkin> object
+#> Status of individual fits:
+#> 
+#>      dataset
+#> model B 
+#>   SFO OK
+#> 
+#> OK: No warnings
+
+  head(
+    # This extracts an mkinfit object with lots of components
+    fits[["FOMC", "B"]]
+  )
+#> $par
+#>  parent_0 log_alpha  log_beta     sigma 
+#> 99.666192  2.549850  5.050587  1.890202 
+#> 
+#> $objective
+#> [1] 28.58291
+#> 
+#> $convergence
+#> [1] 0
+#> 
+#> $iterations
+#> [1] 21
+#> 
+#> $evaluations
+#> function gradient 
+#>       25       78 
+#> 
+#> $message
+#> [1] "both X-convergence and relative convergence (5)"
+#> 
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_A.html b/docs/dev/reference/FOCUS_2006_A.html new file mode 100644 index 00000000..b819cd4d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_A.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_B.html b/docs/dev/reference/FOCUS_2006_B.html new file mode 100644 index 00000000..b819cd4d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_B.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_C.html b/docs/dev/reference/FOCUS_2006_C.html new file mode 100644 index 00000000..b819cd4d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_C.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_D.html b/docs/dev/reference/FOCUS_2006_D.html new file mode 100644 index 00000000..b819cd4d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_D.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html b/docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html new file mode 100644 index 00000000..d315baa2 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html @@ -0,0 +1,145 @@ + +Results of fitting the DFOP model to Datasets A to B of FOCUS (2006) — FOCUS_2006_DFOP_ref_A_to_B • mkin + Skip to contents + + +
+
+
+ +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
+

Usage

+
FOCUS_2006_DFOP_ref_A_to_B
+
+ +
+

Format

+

A data frame containing the following variables.

package
+

a factor giving the name of the software package

+ +
M0
+

The fitted initial concentration of the parent compound

+ +
f
+

The fitted f parameter

+ +
k1
+

The fitted k1 parameter

+ +
k2
+

The fitted k2 parameter

+ +
DT50
+

The resulting half-life of the parent compound

+ +
DT90
+

The resulting DT90 of the parent compound

+ +
dataset
+

The FOCUS dataset that was used

+ + +
+
+

Source

+

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+ +
+

Examples

+
data(FOCUS_2006_DFOP_ref_A_to_B)
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_E.html b/docs/dev/reference/FOCUS_2006_E.html new file mode 100644 index 00000000..b819cd4d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_E.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_F.html b/docs/dev/reference/FOCUS_2006_F.html new file mode 100644 index 00000000..b819cd4d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_F.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html b/docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html new file mode 100644 index 00000000..24bf6df8 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html @@ -0,0 +1,142 @@ + +Results of fitting the FOMC model to Datasets A to F of FOCUS (2006) — FOCUS_2006_FOMC_ref_A_to_F • mkin + Skip to contents + + +
+
+
+ +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
+

Usage

+
FOCUS_2006_FOMC_ref_A_to_F
+
+ +
+

Format

+

A data frame containing the following variables.

package
+

a factor giving the name of the software package

+ +
M0
+

The fitted initial concentration of the parent compound

+ +
alpha
+

The fitted alpha parameter

+ +
beta
+

The fitted beta parameter

+ +
DT50
+

The resulting half-life of the parent compound

+ +
DT90
+

The resulting DT90 of the parent compound

+ +
dataset
+

The FOCUS dataset that was used

+ + +
+
+

Source

+

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+ +
+

Examples

+
data(FOCUS_2006_FOMC_ref_A_to_F)
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html b/docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html new file mode 100644 index 00000000..1f7fad2f --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html @@ -0,0 +1,145 @@ + +Results of fitting the HS model to Datasets A to F of FOCUS (2006) — FOCUS_2006_HS_ref_A_to_F • mkin + Skip to contents + + +
+
+
+ +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
+

Usage

+
FOCUS_2006_HS_ref_A_to_F
+
+ +
+

Format

+

A data frame containing the following variables.

package
+

a factor giving the name of the software package

+ +
M0
+

The fitted initial concentration of the parent compound

+ +
tb
+

The fitted tb parameter

+ +
k1
+

The fitted k1 parameter

+ +
k2
+

The fitted k2 parameter

+ +
DT50
+

The resulting half-life of the parent compound

+ +
DT90
+

The resulting DT90 of the parent compound

+ +
dataset
+

The FOCUS dataset that was used

+ + +
+
+

Source

+

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+ +
+

Examples

+
data(FOCUS_2006_HS_ref_A_to_F)
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html b/docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html new file mode 100644 index 00000000..39b06514 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html @@ -0,0 +1,139 @@ + +Results of fitting the SFO model to Datasets A to F of FOCUS (2006) — FOCUS_2006_SFO_ref_A_to_F • mkin + Skip to contents + + +
+
+
+ +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
+

Usage

+
FOCUS_2006_SFO_ref_A_to_F
+
+ +
+

Format

+

A data frame containing the following variables.

package
+

a factor giving the name of the software package

+ +
M0
+

The fitted initial concentration of the parent compound

+ +
k
+

The fitted first-order degradation rate constant

+ +
DT50
+

The resulting half-life of the parent compound

+ +
DT90
+

The resulting DT90 of the parent compound

+ +
dataset
+

The FOCUS dataset that was used

+ + +
+
+

Source

+

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+ +
+

Examples

+
data(FOCUS_2006_SFO_ref_A_to_F)
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_datasets.html b/docs/dev/reference/FOCUS_2006_datasets.html new file mode 100644 index 00000000..a147a4f9 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_datasets.html @@ -0,0 +1,133 @@ + +Datasets A to F from the FOCUS Kinetics report from 2006 — FOCUS_2006_datasets • mkin + Skip to contents + + +
+
+
+ +
+

Data taken from FOCUS (2006), p. 258.

+
+ +
+

Usage

+
FOCUS_2006_A
+  FOCUS_2006_B
+  FOCUS_2006_C
+  FOCUS_2006_D
+  FOCUS_2006_E
+  FOCUS_2006_F
+
+ +
+

Format

+

6 datasets with observations on the following variables.

name
+

a factor containing the name of the observed variable

+ +
time
+

a numeric vector containing time points

+ +
value
+

a numeric vector containing concentrations in percent of applied radioactivity

+ + +
+
+

Source

+

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+ +
+

Examples

+
FOCUS_2006_C
+#>     name time value
+#> 1 parent    0  85.1
+#> 2 parent    1  57.9
+#> 3 parent    3  29.9
+#> 4 parent    7  14.6
+#> 5 parent   14   9.7
+#> 6 parent   28   6.6
+#> 7 parent   63   4.0
+#> 8 parent   91   3.9
+#> 9 parent  119   0.6
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/FOMC.solution-1.png b/docs/dev/reference/FOMC.solution-1.png new file mode 100644 index 00000000..18a4b586 Binary files /dev/null and b/docs/dev/reference/FOMC.solution-1.png differ diff --git a/docs/dev/reference/FOMC.solution.html b/docs/dev/reference/FOMC.solution.html new file mode 100644 index 00000000..5d1f2443 --- /dev/null +++ b/docs/dev/reference/FOMC.solution.html @@ -0,0 +1,166 @@ + +First-Order Multi-Compartment kinetics — FOMC.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing exponential decline from a defined starting value, with +a decreasing rate constant.

+
+ +
+

Usage

+
FOMC.solution(t, parent_0, alpha, beta)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
alpha
+

Shape parameter determined by coefficient of variation of rate +constant values.

+ + +
beta
+

Location parameter.

+ +
+
+

Value

+

The value of the response variable at time t.

+
+
+

Details

+

The form given here differs slightly from the original reference by +Gustafson and Holden (1990). The parameter beta corresponds to 1/beta +in the original equation.

+
+
+

Note

+

The solution of the FOMC kinetic model reduces to the +SFO.solution for large values of alpha and beta +with \(k = \frac{\beta}{\alpha}\).

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

Gustafson DI and Holden LR (1990) Nonlinear pesticide dissipation in soil: +A new model based on spatial variability. Environmental Science and +Technology 24, 1032-1038

+
+
+

See also

+ +
+ +
+

Examples

+

+  plot(function(x) FOMC.solution(x, 100, 10, 2), 0, 2, ylim = c(0, 100))
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/HS.solution-1.png b/docs/dev/reference/HS.solution-1.png new file mode 100644 index 00000000..61d89dbc Binary files /dev/null and b/docs/dev/reference/HS.solution-1.png differ diff --git a/docs/dev/reference/HS.solution.html b/docs/dev/reference/HS.solution.html new file mode 100644 index 00000000..d15e75dd --- /dev/null +++ b/docs/dev/reference/HS.solution.html @@ -0,0 +1,156 @@ + +Hockey-Stick kinetics — HS.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing two exponential decline functions with a break point +between them.

+
+ +
+

Usage

+
HS.solution(t, parent_0, k1, k2, tb)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
k1
+

First kinetic constant.

+ + +
k2
+

Second kinetic constant.

+ + +
tb
+

Break point. Before this time, exponential decline according to +k1 is calculated, after this time, exponential decline proceeds +according to k2.

+ +
+
+

Value

+

The value of the response variable at time t.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

See also

+ +
+ +
+

Examples

+

+  plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100))
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/IORE.solution-1.png b/docs/dev/reference/IORE.solution-1.png new file mode 100644 index 00000000..54c9dcae Binary files /dev/null and b/docs/dev/reference/IORE.solution-1.png differ diff --git a/docs/dev/reference/IORE.solution.html b/docs/dev/reference/IORE.solution.html new file mode 100644 index 00000000..47cc1e3d --- /dev/null +++ b/docs/dev/reference/IORE.solution.html @@ -0,0 +1,171 @@ + +Indeterminate order rate equation kinetics — IORE.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing exponential decline from a defined starting value, with +a concentration dependent rate constant.

+
+ +
+

Usage

+
IORE.solution(t, parent_0, k__iore, N)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
k__iore
+

Rate constant. Note that this depends on the concentration +units used.

+ + +
N
+

Exponent describing the nonlinearity of the rate equation

+ +
+
+

Value

+

The value of the response variable at time t.

+
+
+

Note

+

The solution of the IORE kinetic model reduces to the +SFO.solution if N = 1. The parameters of the IORE model can +be transformed to equivalent parameters of the FOMC mode - see the NAFTA +guidance for details.

+
+
+

References

+

NAFTA Technical Working Group on Pesticides (not dated) Guidance +for Evaluating and Calculating Degradation Kinetics in Environmental Media

+
+
+

See also

+ +
+ +
+

Examples

+

+  plot(function(x) IORE.solution(x, 100, 0.2, 1.3), 0, 2, ylim = c(0, 100))
+
+  # \dontrun{
+    fit.fomc <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+    fit.iore <- mkinfit("IORE", FOCUS_2006_C, quiet = TRUE)
+    fit.iore.deS <- mkinfit("IORE", FOCUS_2006_C, solution_type = "deSolve", quiet = TRUE)
+#> Error in is.loaded(initfunc, PACKAGE = dllname, type = "") : 
+#>   invalid 'PACKAGE' argument
+
+    print(data.frame(fit.fomc$par, fit.iore$par, fit.iore.deS$par,
+                     row.names = paste("model par", 1:4)))
+#>             fit.fomc.par fit.iore.par fit.iore.deS.par
+#> model par 1  85.87489063    85.874890        85.874890
+#> model par 2   0.05192238    -4.826631        -4.826631
+#> model par 3   0.65096665     1.949403         1.949403
+#> model par 4   1.85744396     1.857444         1.857444
+    print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes,
+                iore.deS = endpoints(fit.iore)$distimes))
+#>              DT50    DT90 DT50back
+#> fomc     1.785233 15.1479 4.559973
+#> iore     1.785233 15.1479 4.559973
+#> iore.deS 1.785233 15.1479 4.559973
+  # }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/NAFTA_SOP_2015-1.png b/docs/dev/reference/NAFTA_SOP_2015-1.png new file mode 100644 index 00000000..98d4246c Binary files /dev/null and b/docs/dev/reference/NAFTA_SOP_2015-1.png differ diff --git a/docs/dev/reference/NAFTA_SOP_2015.html b/docs/dev/reference/NAFTA_SOP_2015.html new file mode 100644 index 00000000..3b176eed --- /dev/null +++ b/docs/dev/reference/NAFTA_SOP_2015.html @@ -0,0 +1,167 @@ + +Example datasets from the NAFTA SOP published 2015 — NAFTA_SOP_2015 • mkin + Skip to contents + + +
+
+
+ +
+

Data taken from US EPA (2015), p. 19 and 23.

+
+ +
+

Usage

+
NAFTA_SOP_Appendix_B
+  NAFTA_SOP_Appendix_D
+
+ +
+

Format

+

2 datasets with observations on the following variables.

name
+

a factor containing the name of the observed variable

+ +
time
+

a numeric vector containing time points

+ +
value
+

a numeric vector containing concentrations

+ + +
+
+

Source

+

NAFTA (2011) Guidance for evaluating and calculating degradation kinetics + in environmental media. NAFTA Technical Working Group on Pesticides + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation + accessed 2019-02-22

+

US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to + Calculate Representative Half-life Values and Characterizing Pesticide + Degradation + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance

+
+ +
+

Examples

+
  nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1)
+#> The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
+#> The representative half-life of the IORE model is longer than the one corresponding
+#> to the terminal degradation rate found with the DFOP model.
+#> The representative half-life obtained from the DFOP model may be used
+  print(nafta_evaluation)
+#> Sums of squares:
+#>       SFO      IORE      DFOP 
+#> 1378.6832  615.7730  517.8836 
+#> 
+#> Critical sum of squares for checking the SFO model:
+#> [1] 717.4598
+#> 
+#> Parameters:
+#> $SFO
+#>          Estimate   Pr(>t)    Lower   Upper
+#> parent_0  83.7558 1.80e-14 77.18268 90.3288
+#> k_parent   0.0017 7.43e-05  0.00112  0.0026
+#> sigma      8.7518 1.22e-05  5.64278 11.8608
+#> 
+#> $IORE
+#>                Estimate Pr(>t)    Lower    Upper
+#> parent_0       9.69e+01     NA 8.88e+01 1.05e+02
+#> k__iore_parent 8.40e-14     NA 1.79e-18 3.94e-09
+#> N_parent       6.68e+00     NA 4.19e+00 9.17e+00
+#> sigma          5.85e+00     NA 3.76e+00 7.94e+00
+#> 
+#> $DFOP
+#>          Estimate   Pr(>t)    Lower    Upper
+#> parent_0 9.76e+01 1.94e-13 9.02e+01 1.05e+02
+#> k1       4.24e-02 5.92e-03 2.03e-02 8.88e-02
+#> k2       8.24e-04 6.48e-03 3.89e-04 1.75e-03
+#> g        2.88e-01 2.47e-05 1.95e-01 4.03e-01
+#> sigma    5.36e+00 2.22e-05 3.43e+00 7.30e+00
+#> 
+#> 
+#> DTx values:
+#>      DT50    DT90 DT50_rep
+#> SFO   407    1350      407
+#> IORE  541 5190000  1560000
+#> DFOP  429    2380      841
+#> 
+#> Representative half-life:
+#> [1] 841.41
+  plot(nafta_evaluation)
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/NAFTA_SOP_Appendix_B.html b/docs/dev/reference/NAFTA_SOP_Appendix_B.html new file mode 100644 index 00000000..c3c9b055 --- /dev/null +++ b/docs/dev/reference/NAFTA_SOP_Appendix_B.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/NAFTA_SOP_Appendix_D.html b/docs/dev/reference/NAFTA_SOP_Appendix_D.html new file mode 100644 index 00000000..c3c9b055 --- /dev/null +++ b/docs/dev/reference/NAFTA_SOP_Appendix_D.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/NAFTA_SOP_Attachment-1.png b/docs/dev/reference/NAFTA_SOP_Attachment-1.png new file mode 100644 index 00000000..a6066441 Binary files /dev/null and b/docs/dev/reference/NAFTA_SOP_Attachment-1.png differ diff --git a/docs/dev/reference/NAFTA_SOP_Attachment.html b/docs/dev/reference/NAFTA_SOP_Attachment.html new file mode 100644 index 00000000..afae4f43 --- /dev/null +++ b/docs/dev/reference/NAFTA_SOP_Attachment.html @@ -0,0 +1,156 @@ + +Example datasets from Attachment 1 to the NAFTA SOP published 2015 — NAFTA_SOP_Attachment • mkin + Skip to contents + + +
+
+
+ +
+

Data taken from from Attachment 1 of the SOP.

+
+ +
+

Usage

+
NAFTA_SOP_Attachment
+
+ +
+

Format

+

A list (NAFTA_SOP_Attachment) containing 16 datasets suitable + for the evaluation with nafta

+
+
+

Source

+

NAFTA (2011) Guidance for evaluating and calculating degradation kinetics + in environmental media. NAFTA Technical Working Group on Pesticides + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation + accessed 2019-02-22

+

US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to + Calculate Representative Half-life Values and Characterizing Pesticide + Degradation + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance

+
+ +
+

Examples

+
  nafta_att_p5a <- nafta(NAFTA_SOP_Attachment[["p5a"]], cores = 1)
+#> The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
+#> The half-life obtained from the IORE model may be used
+  print(nafta_att_p5a)
+#> Sums of squares:
+#>       SFO      IORE      DFOP 
+#> 465.21753  56.27506  32.06401 
+#> 
+#> Critical sum of squares for checking the SFO model:
+#> [1] 64.4304
+#> 
+#> Parameters:
+#> $SFO
+#>          Estimate   Pr(>t)  Lower   Upper
+#> parent_0  95.8401 4.67e-21 92.245 99.4357
+#> k_parent   0.0102 3.92e-12  0.009  0.0117
+#> sigma      4.8230 3.81e-06  3.214  6.4318
+#> 
+#> $IORE
+#>                Estimate Pr(>t)    Lower    Upper
+#> parent_0       1.01e+02     NA 9.91e+01 1.02e+02
+#> k__iore_parent 1.54e-05     NA 4.08e-06 5.84e-05
+#> N_parent       2.57e+00     NA 2.25e+00 2.89e+00
+#> sigma          1.68e+00     NA 1.12e+00 2.24e+00
+#> 
+#> $DFOP
+#>          Estimate   Pr(>t)   Lower    Upper
+#> parent_0 9.99e+01 1.41e-26 98.8116 101.0810
+#> k1       2.67e-02 5.05e-06  0.0243   0.0295
+#> k2       3.41e-12 5.00e-01  0.0000      Inf
+#> g        6.47e-01 3.67e-06  0.6248   0.6677
+#> sigma    1.27e+00 8.91e-06  0.8395   1.6929
+#> 
+#> 
+#> DTx values:
+#>      DT50     DT90 DT50_rep
+#> SFO  67.7 2.25e+02 6.77e+01
+#> IORE 58.2 1.07e+03 3.22e+02
+#> DFOP 55.5 3.70e+11 2.03e+11
+#> 
+#> Representative half-life:
+#> [1] 321.51
+  plot(nafta_att_p5a)
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/SFO.solution-1.png b/docs/dev/reference/SFO.solution-1.png new file mode 100644 index 00000000..34fdd460 Binary files /dev/null and b/docs/dev/reference/SFO.solution-1.png differ diff --git a/docs/dev/reference/SFO.solution.html b/docs/dev/reference/SFO.solution.html new file mode 100644 index 00000000..f61d1d79 --- /dev/null +++ b/docs/dev/reference/SFO.solution.html @@ -0,0 +1,143 @@ + +Single First-Order kinetics — SFO.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing exponential decline from a defined starting value.

+
+ +
+

Usage

+
SFO.solution(t, parent_0, k)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
k
+

Kinetic rate constant.

+ +
+
+

Value

+

The value of the response variable at time t.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

See also

+ +
+ +
+

Examples

+

+  plot(function(x) SFO.solution(x, 100, 3), 0, 2)
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/SFORB.solution-1.png b/docs/dev/reference/SFORB.solution-1.png new file mode 100644 index 00000000..08d25616 Binary files /dev/null and b/docs/dev/reference/SFORB.solution-1.png differ diff --git a/docs/dev/reference/SFORB.solution.html b/docs/dev/reference/SFORB.solution.html new file mode 100644 index 00000000..d9e9440f --- /dev/null +++ b/docs/dev/reference/SFORB.solution.html @@ -0,0 +1,165 @@ + +Single First-Order Reversible Binding kinetics — SFORB.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing the solution of the differential equations describing +the kinetic model with first-order terms for a two-way transfer from a free +to a bound fraction, and a first-order degradation term for the free +fraction. The initial condition is a defined amount in the free fraction +and no substance in the bound fraction.

+
+ +
+

Usage

+
SFORB.solution(t, parent_0, k_12, k_21, k_1output)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
k_12
+

Kinetic constant describing transfer from free to bound.

+ + +
k_21
+

Kinetic constant describing transfer from bound to free.

+ + +
k_1output
+

Kinetic constant describing degradation of the free +fraction.

+ +
+
+

Value

+

The value of the response variable, which is the sum of free and +bound fractions at time t.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

See also

+ +
+ +
+

Examples

+

+  plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/[.mhmkin.html b/docs/dev/reference/[.mhmkin.html new file mode 100644 index 00000000..19cc9c91 --- /dev/null +++ b/docs/dev/reference/[.mhmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/add_err-1.png b/docs/dev/reference/add_err-1.png new file mode 100644 index 00000000..1bcea3d5 Binary files /dev/null and b/docs/dev/reference/add_err-1.png differ diff --git a/docs/dev/reference/add_err-2.png b/docs/dev/reference/add_err-2.png new file mode 100644 index 00000000..67c083ea Binary files /dev/null and b/docs/dev/reference/add_err-2.png differ diff --git a/docs/dev/reference/add_err-3.png b/docs/dev/reference/add_err-3.png new file mode 100644 index 00000000..f25ae5e7 Binary files /dev/null and b/docs/dev/reference/add_err-3.png differ diff --git a/docs/dev/reference/add_err.html b/docs/dev/reference/add_err.html new file mode 100644 index 00000000..00a2b1d0 --- /dev/null +++ b/docs/dev/reference/add_err.html @@ -0,0 +1,216 @@ + +Add normally distributed errors to simulated kinetic degradation data — add_err • mkin + Skip to contents + + +
+
+
+ +
+

Normally distributed errors are added to data predicted for a specific +degradation model using mkinpredict. The variance of the error +may depend on the predicted value and is specified as a standard deviation.

+
+ +
+

Usage

+
add_err(
+  prediction,
+  sdfunc,
+  secondary = c("M1", "M2"),
+  n = 10,
+  LOD = 0.1,
+  reps = 2,
+  digits = 1,
+  seed = NA
+)
+
+ +
+

Arguments

+ + +
prediction
+

A prediction from a kinetic model as produced by +mkinpredict.

+ + +
sdfunc
+

A function taking the predicted value as its only argument and +returning a standard deviation that should be used for generating the +random error terms for this value.

+ + +
secondary
+

The names of state variables that should have an initial +value of zero

+ + +
n
+

The number of datasets to be generated.

+ + +
LOD
+

The limit of detection (LOD). Values that are below the LOD after +adding the random error will be set to NA.

+ + +
reps
+

The number of replicates to be generated within the datasets.

+ + +
digits
+

The number of digits to which the values will be rounded.

+ + +
seed
+

The seed used for the generation of random numbers. If NA, the +seed is not set.

+ +
+
+

Value

+

A list of datasets compatible with mmkin, i.e. the +components of the list are datasets compatible with mkinfit.

+
+
+

References

+

Ranke J and Lehmann R (2015) To t-test or not to t-test, that is +the question. XV Symposium on Pesticide Chemistry 2-4 September 2015, +Piacenza, Italy +https://jrwb.de/posters/piacenza_2015.pdf

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# The kinetic model
+m_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"),
+                     M1 = mkinsub("SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+# Generate a prediction for a specific set of parameters
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+
+# This is the prediction used for the "Type 2 datasets" on the Piacenza poster
+# from 2015
+d_SFO_SFO <- mkinpredict(m_SFO_SFO,
+                         c(k_parent = 0.1, f_parent_to_M1 = 0.5,
+                           k_M1 = log(2)/1000),
+                         c(parent = 100, M1 = 0),
+                         sampling_times)
+
+# Add an error term with a constant (independent of the value) standard deviation
+# of 10, and generate three datasets
+d_SFO_SFO_err <- add_err(d_SFO_SFO, function(x) 10, n = 3, seed = 123456789 )
+
+# Name the datasets for nicer plotting
+names(d_SFO_SFO_err) <- paste("Dataset", 1:3)
+
+# Name the model in the list of models (with only one member in this case) for
+# nicer plotting later on.  Be quiet and use only one core not to offend CRAN
+# checks
+# \dontrun{
+f_SFO_SFO <- mmkin(list("SFO-SFO" = m_SFO_SFO),
+                   d_SFO_SFO_err, cores = 1,
+                   quiet = TRUE)
+
+plot(f_SFO_SFO)
+
+
+# We would like to inspect the fit for dataset 3 more closely
+# Using double brackets makes the returned object an mkinfit object
+# instead of a list of mkinfit objects, so plot.mkinfit is used
+plot(f_SFO_SFO[[3]], show_residuals = TRUE)
+
+
+# If we use single brackets, we should give two indices (model and dataset),
+# and plot.mmkin is used
+plot(f_SFO_SFO[1, 3])
+
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/anova.saem.mmkin.html b/docs/dev/reference/anova.saem.mmkin.html new file mode 100644 index 00000000..c30a8927 --- /dev/null +++ b/docs/dev/reference/anova.saem.mmkin.html @@ -0,0 +1,140 @@ + +Anova method for saem.mmkin objects — anova.saem.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Generate an anova object. The method to calculate the BIC is that from the +saemix package. As in other prominent anova methods, models are sorted by +number of parameters, and the tests (if requested) are always relative to +the model on the previous line.

+
+ +
+

Usage

+
# S3 method for class 'saem.mmkin'
+anova(
+  object,
+  ...,
+  method = c("is", "lin", "gq"),
+  test = FALSE,
+  model.names = NULL
+)
+
+ +
+

Arguments

+ + +
object
+

An saem.mmkin object

+ + +
...
+

further such objects

+ + +
method
+

Method for likelihood calculation: "is" (importance sampling), +"lin" (linear approximation), or "gq" (Gaussian quadrature). Passed +to saemix::logLik.SaemixObject

+ + +
test
+

Should a likelihood ratio test be performed? If TRUE, +the alternative models are tested against the first model. Should +only be done for nested models.

+ + +
model.names
+

Optional character vector of model names

+ +
+
+

Value

+

an "anova" data frame; the traditional (S3) result of anova()

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/aw.html b/docs/dev/reference/aw.html new file mode 100644 index 00000000..c87247c5 --- /dev/null +++ b/docs/dev/reference/aw.html @@ -0,0 +1,153 @@ + +Calculate Akaike weights for model averaging — aw • mkin + Skip to contents + + +
+
+
+ +
+

Akaike weights are calculated based on the relative +expected Kullback-Leibler information as specified +by Burnham and Anderson (2004).

+
+ +
+

Usage

+
aw(object, ...)
+
+# S3 method for class 'mkinfit'
+aw(object, ...)
+
+# S3 method for class 'mmkin'
+aw(object, ...)
+
+# S3 method for class 'mixed.mmkin'
+aw(object, ...)
+
+# S3 method for class 'multistart'
+aw(object, ...)
+
+ +
+

Arguments

+ + +
object
+

An mmkin column object, containing two or more +mkinfit models that have been fitted to the same data, +or an mkinfit object. In the latter case, further mkinfit +objects fitted to the same data should be specified +as dots arguments.

+ + +
...
+

Not used in the method for mmkin column objects, +further mkinfit objects in the method for mkinfit objects.

+ +
+
+

References

+

Burnham KP and Anderson DR (2004) Multimodel +Inference: Understanding AIC and BIC in Model Selection. +Sociological Methods & Research 33(2) 261-304

+
+ +
+

Examples

+
# \dontrun{
+f_sfo <- mkinfit("SFO", FOCUS_2006_D, quiet = TRUE)
+f_dfop <- mkinfit("DFOP", FOCUS_2006_D, quiet = TRUE)
+aw_sfo_dfop <- aw(f_sfo, f_dfop)
+sum(aw_sfo_dfop)
+#> [1] 1
+aw_sfo_dfop # SFO gets more weight as it has less parameters and a similar fit
+#> [1] 0.5970258 0.4029742
+f <- mmkin(c("SFO", "FOMC", "DFOP"), list("FOCUS D" = FOCUS_2006_D), cores = 1, quiet = TRUE)
+aw(f)
+#> [1] 0.4808722 0.1945539 0.3245740
+sum(aw(f))
+#> [1] 1
+aw(f[c("SFO", "DFOP")])
+#> [1] 0.5970258 0.4029742
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/aw.mixed.mmkin.html b/docs/dev/reference/aw.mixed.mmkin.html new file mode 100644 index 00000000..ccfdbfc6 --- /dev/null +++ b/docs/dev/reference/aw.mixed.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/aw.mkinfit.html b/docs/dev/reference/aw.mkinfit.html new file mode 100644 index 00000000..ccfdbfc6 --- /dev/null +++ b/docs/dev/reference/aw.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/aw.mmkin.html b/docs/dev/reference/aw.mmkin.html new file mode 100644 index 00000000..ccfdbfc6 --- /dev/null +++ b/docs/dev/reference/aw.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/aw.multistart.html b/docs/dev/reference/aw.multistart.html new file mode 100644 index 00000000..ccfdbfc6 --- /dev/null +++ b/docs/dev/reference/aw.multistart.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/backtransform_odeparms.html b/docs/dev/reference/backtransform_odeparms.html new file mode 100644 index 00000000..b07fb165 --- /dev/null +++ b/docs/dev/reference/backtransform_odeparms.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/best.default.html b/docs/dev/reference/best.default.html new file mode 100644 index 00000000..06f15f0c --- /dev/null +++ b/docs/dev/reference/best.default.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/best.html b/docs/dev/reference/best.html new file mode 100644 index 00000000..06f15f0c --- /dev/null +++ b/docs/dev/reference/best.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/check_failed.html b/docs/dev/reference/check_failed.html new file mode 100644 index 00000000..9dea2650 --- /dev/null +++ b/docs/dev/reference/check_failed.html @@ -0,0 +1,100 @@ + +Check if fit within an mhmkin object failed — check_failed • mkin + Skip to contents + + +
+
+
+ +
+

Check if fit within an mhmkin object failed

+
+ +
+

Usage

+
check_failed(x)
+
+ +
+

Arguments

+ + +
x
+

The object to be checked

+ +
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/confint.mkinfit.html b/docs/dev/reference/confint.mkinfit.html new file mode 100644 index 00000000..a0051a85 --- /dev/null +++ b/docs/dev/reference/confint.mkinfit.html @@ -0,0 +1,382 @@ + +Confidence intervals for parameters of mkinfit objects — confint.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

The default method 'quadratic' is based on the quadratic approximation of +the curvature of the likelihood function at the maximum likelihood parameter +estimates. +The alternative method 'profile' is based on the profile likelihood for each +parameter. The 'profile' method uses two nested optimisations and can take a +very long time, even if parallelized by specifying 'cores' on unixoid +platforms. The speed of the method could likely be improved by using the +method of Venzon and Moolgavkar (1988).

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+confint(
+  object,
+  parm,
+  level = 0.95,
+  alpha = 1 - level,
+  cutoff,
+  method = c("quadratic", "profile"),
+  transformed = TRUE,
+  backtransform = TRUE,
+  cores = parallel::detectCores(),
+  rel_tol = 0.01,
+  quiet = FALSE,
+  ...
+)
+
+ +
+

Arguments

+ + +
object
+

An mkinfit object

+ + +
parm
+

A vector of names of the parameters which are to be given +confidence intervals. If missing, all parameters are considered.

+ + +
level
+

The confidence level required

+ + +
alpha
+

The allowed error probability, overrides 'level' if specified.

+ + +
cutoff
+

Possibility to specify an alternative cutoff for the difference +in the log-likelihoods at the confidence boundary. Specifying an explicit +cutoff value overrides arguments 'level' and 'alpha'

+ + +
method
+

The 'quadratic' method approximates the likelihood function at +the optimised parameters using the second term of the Taylor expansion, +using a second derivative (hessian) contained in the object. +The 'profile' method searches the parameter space for the +cutoff of the confidence intervals by means of a likelihood ratio test.

+ + +
transformed
+

If the quadratic approximation is used, should it be +applied to the likelihood based on the transformed parameters?

+ + +
backtransform
+

If we approximate the likelihood in terms of the +transformed parameters, should we backtransform the parameters with +their confidence intervals?

+ + +
cores
+

The number of cores to be used for multicore processing. +On Windows machines, cores > 1 is currently not supported.

+ + +
rel_tol
+

If the method is 'profile', what should be the accuracy +of the lower and upper bounds, relative to the estimate obtained from +the quadratic method?

+ + +
quiet
+

Should we suppress the message "Profiling the likelihood"

+ + +
...
+

Not used

+ +
+
+

Value

+

A matrix with columns giving lower and upper confidence limits for +each parameter.

+
+
+

References

+

Bates DM and Watts GW (1988) Nonlinear regression analysis & its applications

+

Pawitan Y (2013) In all likelihood - Statistical modelling and +inference using likelihood. Clarendon Press, Oxford.

+

Venzon DJ and Moolgavkar SH (1988) A Method for Computing +Profile-Likelihood Based Confidence Intervals, Applied Statistics, 37, +87–94.

+
+ +
+

Examples

+
f <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE)
+confint(f, method = "quadratic")
+#>                2.5%      97.5%
+#> parent_0 71.8242430 93.1600766
+#> k_parent  0.2109541  0.4440528
+#> sigma     1.9778868  7.3681380
+
+# \dontrun{
+confint(f, method = "profile")
+#> Profiling the likelihood
+#>                2.5%      97.5%
+#> parent_0 73.0641834 92.1392181
+#> k_parent  0.2170293  0.4235348
+#> sigma     3.1307772  8.0628314
+
+# Set the number of cores for the profiling method for further examples
+if (identical(Sys.getenv("NOT_CRAN"), "true")) {
+  n_cores <- parallel::detectCores() - 1
+} else {
+  n_cores <- 1
+}
+if (Sys.getenv("TRAVIS") != "") n_cores = 1
+if (Sys.info()["sysname"] == "Windows") n_cores = 1
+
+SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"),
+  use_of_ff = "min", quiet = TRUE)
+SFO_SFO.ff <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"),
+  use_of_ff = "max", quiet = TRUE)
+f_d_1 <- mkinfit(SFO_SFO, subset(FOCUS_2006_D, value != 0), quiet = TRUE)
+system.time(ci_profile <- confint(f_d_1, method = "profile", cores = 1, quiet = TRUE))
+#>    user  system elapsed 
+#>   1.182   0.004   1.186 
+# Using more cores does not save much time here, as parent_0 takes up most of the time
+# If we additionally exclude parent_0 (the confidence of which is often of
+# minor interest), we get a nice performance improvement if we use at least 4 cores
+system.time(ci_profile_no_parent_0 <- confint(f_d_1, method = "profile",
+  c("k_parent_sink", "k_parent_m1", "k_m1_sink", "sigma"), cores = n_cores))
+#> Profiling the likelihood
+#>    user  system elapsed 
+#>   0.429   0.171   0.324 
+ci_profile
+#>                       2.5%        97.5%
+#> parent_0      96.456003640 1.027703e+02
+#> k_parent_sink  0.040762501 5.549764e-02
+#> k_parent_m1    0.046786482 5.500879e-02
+#> k_m1_sink      0.003892605 6.702778e-03
+#> sigma          2.535612399 3.985263e+00
+ci_quadratic_transformed <- confint(f_d_1, method = "quadratic")
+ci_quadratic_transformed
+#>                       2.5%        97.5%
+#> parent_0      96.403841640 1.027931e+02
+#> k_parent_sink  0.041033378 5.596269e-02
+#> k_parent_m1    0.046777902 5.511931e-02
+#> k_m1_sink      0.004012217 6.897547e-03
+#> sigma          2.396089689 3.854918e+00
+ci_quadratic_untransformed <- confint(f_d_1, method = "quadratic", transformed = FALSE)
+ci_quadratic_untransformed
+#>                       2.5%        97.5%
+#> parent_0      96.403841645 102.79312449
+#> k_parent_sink  0.040485331   0.05535491
+#> k_parent_m1    0.046611582   0.05494364
+#> k_m1_sink      0.003835483   0.00668582
+#> sigma          2.396089689   3.85491806
+# Against the expectation based on Bates and Watts (1988), the confidence
+# intervals based on the internal parameter transformation are less
+# congruent with the likelihood based intervals. Note the superiority of the
+# interval based on the untransformed fit for k_m1_sink
+rel_diffs_transformed <- abs((ci_quadratic_transformed - ci_profile)/ci_profile)
+rel_diffs_untransformed <- abs((ci_quadratic_untransformed - ci_profile)/ci_profile)
+rel_diffs_transformed < rel_diffs_untransformed
+#>                2.5% 97.5%
+#> parent_0      FALSE FALSE
+#> k_parent_sink  TRUE FALSE
+#> k_parent_m1    TRUE FALSE
+#> k_m1_sink     FALSE FALSE
+#> sigma         FALSE FALSE
+signif(rel_diffs_transformed, 3)
+#>                   2.5%    97.5%
+#> parent_0      0.000541 0.000222
+#> k_parent_sink 0.006650 0.008380
+#> k_parent_m1   0.000183 0.002010
+#> k_m1_sink     0.030700 0.029100
+#> sigma         0.055000 0.032700
+signif(rel_diffs_untransformed, 3)
+#>                   2.5%    97.5%
+#> parent_0      0.000541 0.000222
+#> k_parent_sink 0.006800 0.002570
+#> k_parent_m1   0.003740 0.001180
+#> k_m1_sink     0.014700 0.002530
+#> sigma         0.055000 0.032700
+
+
+# Investigate a case with formation fractions
+f_d_2 <- mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), quiet = TRUE)
+ci_profile_ff <- confint(f_d_2, method = "profile", cores = n_cores)
+#> Profiling the likelihood
+ci_profile_ff
+#>                        2.5%        97.5%
+#> parent_0       96.456003640 1.027703e+02
+#> k_parent        0.090911032 1.071578e-01
+#> k_m1            0.003892606 6.702775e-03
+#> f_parent_to_m1  0.471328495 5.611550e-01
+#> sigma           2.535612399 3.985263e+00
+ci_quadratic_transformed_ff <- confint(f_d_2, method = "quadratic")
+ci_quadratic_transformed_ff
+#>                        2.5%        97.5%
+#> parent_0       96.403833581 102.79311649
+#> k_parent        0.090823771   0.10725430
+#> k_m1            0.004012219   0.00689755
+#> f_parent_to_m1  0.469118824   0.55959615
+#> sigma           2.396089689   3.85491806
+ci_quadratic_untransformed_ff <- confint(f_d_2, method = "quadratic", transformed = FALSE)
+ci_quadratic_untransformed_ff
+#>                        2.5%        97.5%
+#> parent_0       96.403833586 1.027931e+02
+#> k_parent        0.090491913 1.069035e-01
+#> k_m1            0.003835485 6.685823e-03
+#> f_parent_to_m1  0.469113477 5.598387e-01
+#> sigma           2.396089689 3.854918e+00
+rel_diffs_transformed_ff <- abs((ci_quadratic_transformed_ff - ci_profile_ff)/ci_profile_ff)
+rel_diffs_untransformed_ff <- abs((ci_quadratic_untransformed_ff - ci_profile_ff)/ci_profile_ff)
+# While the confidence interval for the parent rate constant is closer to
+# the profile based interval when using the internal parameter
+# transformation, the interval for the metabolite rate constant is 'better
+# without internal parameter transformation.
+rel_diffs_transformed_ff < rel_diffs_untransformed_ff
+#>                 2.5% 97.5%
+#> parent_0       FALSE FALSE
+#> k_parent        TRUE  TRUE
+#> k_m1           FALSE FALSE
+#> f_parent_to_m1  TRUE FALSE
+#> sigma           TRUE FALSE
+rel_diffs_transformed_ff
+#>                        2.5%        97.5%
+#> parent_0       0.0005408690 0.0002217233
+#> k_parent       0.0009598532 0.0009001864
+#> k_m1           0.0307283045 0.0290588367
+#> f_parent_to_m1 0.0046881768 0.0027780062
+#> sigma          0.0550252516 0.0327066836
+rel_diffs_untransformed_ff
+#>                        2.5%        97.5%
+#> parent_0       0.0005408689 0.0002217233
+#> k_parent       0.0046102155 0.0023732280
+#> k_m1           0.0146740687 0.0025291815
+#> f_parent_to_m1 0.0046995210 0.0023457712
+#> sigma          0.0550252516 0.0327066836
+
+# The profiling for the following fit does not finish in a reasonable time,
+# therefore we use the quadratic approximation
+m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
+  M1 = mkinsub("SFO"),
+  M2 = mkinsub("SFO"),
+  use_of_ff = "max", quiet = TRUE)
+DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
+f_tc_2 <- mkinfit(m_synth_DFOP_par, DFOP_par_c, error_model = "tc",
+  error_model_algorithm = "direct", quiet = TRUE)
+confint(f_tc_2, method = "quadratic")
+#>                        2.5%        97.5%
+#> parent_0       94.596181875 106.19936592
+#> k_M1            0.037605432   0.04490757
+#> k_M2            0.008568745   0.01087675
+#> f_parent_to_M1  0.021464676   0.62023880
+#> f_parent_to_M2  0.015167158   0.37975350
+#> k1              0.273897535   0.33388072
+#> k2              0.018614555   0.02250379
+#> g               0.671943738   0.73583261
+#> sigma_low       0.251283679   0.83992102
+#> rsd_high        0.040411022   0.07662008
+confint(f_tc_2, "parent_0", method = "quadratic")
+#>              2.5%    97.5%
+#> parent_0 94.59618 106.1994
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/create_deg_func.html b/docs/dev/reference/create_deg_func.html new file mode 100644 index 00000000..4c66c02b --- /dev/null +++ b/docs/dev/reference/create_deg_func.html @@ -0,0 +1,148 @@ + +Create degradation functions for known analytical solutions — create_deg_func • mkin + Skip to contents + + +
+
+
+ +
+

Create degradation functions for known analytical solutions

+
+ +
+

Usage

+
create_deg_func(spec, use_of_ff = c("min", "max"))
+
+ +
+

Arguments

+ + +
spec
+

List of model specifications as contained in mkinmod objects

+ + +
use_of_ff
+

Minimum or maximum use of formation fractions

+ +
+
+

Value

+

Degradation function to be attached to mkinmod objects

+
+ +
+

Examples

+

+SFO_SFO <- mkinmod(
+  parent = mkinsub("SFO", "m1"),
+  m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+FOCUS_D <- subset(FOCUS_2006_D, value != 0) # to avoid warnings
+fit_1 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE)
+# \dontrun{
+fit_2 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE)
+if (require(rbenchmark))
+  benchmark(
+    analytical = mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE),
+    deSolve = mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE),
+    replications = 2)
+#> Loading required package: rbenchmark
+#>         test replications elapsed relative user.self sys.self user.child
+#> 1 analytical            2   0.249    1.000     0.249        0          0
+#> 2    deSolve            2   0.307    1.233     0.306        0          0
+#>   sys.child
+#> 1         0
+#> 2         0
+  DFOP_SFO <- mkinmod(
+    parent = mkinsub("DFOP", "m1"),
+    m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+  benchmark(
+    analytical = mkinfit(DFOP_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE),
+    deSolve = mkinfit(DFOP_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE),
+    replications = 2)
+#>         test replications elapsed relative user.self sys.self user.child
+#> 1 analytical            2   0.391    1.000     0.391        0          0
+#> 2    deSolve            2   0.543    1.389     0.542        0          0
+#>   sys.child
+#> 1         0
+#> 2         0
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/dimethenamid_2018-1.png b/docs/dev/reference/dimethenamid_2018-1.png new file mode 100644 index 00000000..3a509a7f Binary files /dev/null and b/docs/dev/reference/dimethenamid_2018-1.png differ diff --git a/docs/dev/reference/dimethenamid_2018.html b/docs/dev/reference/dimethenamid_2018.html new file mode 100644 index 00000000..4bd35bc6 --- /dev/null +++ b/docs/dev/reference/dimethenamid_2018.html @@ -0,0 +1,347 @@ + +Aerobic soil degradation data on dimethenamid and dimethenamid-P from the EU assessment in 2018 — dimethenamid_2018 • mkin + Skip to contents + + +
+
+
+ +
+

The datasets were extracted from the active substance evaluation dossier +published by EFSA. Kinetic evaluations shown for these datasets are intended +to illustrate and advance kinetic modelling. The fact that these data and +some results are shown here does not imply a license to use them in the +context of pesticide registrations, as the use of the data may be +constrained by data protection regulations.

+
+ +
+

Usage

+
dimethenamid_2018
+
+ +
+

Format

+

An mkindsg object grouping seven datasets with some meta information

+
+
+

Source

+

Rapporteur Member State Germany, Co-Rapporteur Member State Bulgaria (2018) +Renewal Assessment Report Dimethenamid-P Volume 3 - B.8 Environmental fate and behaviour +Rev. 2 - November 2017 +https://open.efsa.europa.eu/study-inventory/EFSA-Q-2014-00716

+
+
+

Details

+

The R code used to create this data object is installed with this package +in the 'dataset_generation' directory. In the code, page numbers are given for +specific pieces of information in the comments.

+
+ +
+

Examples

+
print(dimethenamid_2018)
+#> <mkindsg> holding 7 mkinds objects
+#> Title $title:  Aerobic soil degradation data on dimethenamid-P from the EU assessment in 2018 
+#> Occurrence of observed compounds $observed_n:
+#> DMTAP   M23   M27   M31  DMTA 
+#>     3     7     7     7     4 
+#> Time normalisation factors $f_time_norm:
+#> [1] 1.0000000 0.9706477 1.2284784 1.2284784 0.6233856 0.7678922 0.6733938
+#> Meta information $meta:
+#>                      study  usda_soil_type study_moisture_ref_type rel_moisture
+#> Calke        Unsworth 2014      Sandy loam                     pF2         1.00
+#> Borstel  Staudenmaier 2009            Sand                     pF1         0.50
+#> Elliot 1        Wendt 1997       Clay loam                   pF2.5         0.75
+#> Elliot 2        Wendt 1997       Clay loam                   pF2.5         0.75
+#> Flaach          König 1996 Sandy clay loam                     pF1         0.40
+#> BBA 2.2         König 1995      Loamy sand                     pF1         0.40
+#> BBA 2.3         König 1995      Sandy loam                     pF1         0.40
+#>          study_ref_moisture temperature
+#> Calke                    NA          20
+#> Borstel               23.00          20
+#> Elliot 1              33.37          23
+#> Elliot 2              33.37          23
+#> Flaach                   NA          20
+#> BBA 2.2                  NA          20
+#> BBA 2.3                  NA          20
+dmta_ds <- lapply(1:7, function(i) {
+  ds_i <- dimethenamid_2018$ds[[i]]$data
+  ds_i[ds_i$name == "DMTAP", "name"] <-  "DMTA"
+  ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
+  ds_i
+})
+names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
+dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
+dmta_ds[["Elliot 1"]] <- NULL
+dmta_ds[["Elliot 2"]] <- NULL
+# \dontrun{
+# We don't use DFOP for the parent compound, as this gives numerical
+# instabilities in the fits
+sfo_sfo3p <- mkinmod(
+ DMTA = mkinsub("SFO", c("M23", "M27", "M31")),
+ M23 = mkinsub("SFO"),
+ M27 = mkinsub("SFO"),
+ M31 = mkinsub("SFO", "M27", sink = FALSE),
+ quiet = TRUE
+)
+dmta_sfo_sfo3p_tc <- mmkin(list("SFO-SFO3+" = sfo_sfo3p),
+  dmta_ds, error_model = "tc", quiet = TRUE)
+print(dmta_sfo_sfo3p_tc)
+#> <mmkin> object
+#> Status of individual fits:
+#> 
+#>            dataset
+#> model       Calke Borstel Flaach BBA 2.2 BBA 2.3 Elliot
+#>   SFO-SFO3+ OK    OK      OK     OK      OK      OK    
+#> 
+#> OK: No warnings
+# The default (test_log_parms = FALSE) gives an undue
+# influence of ill-defined rate constants that have
+# extremely small values:
+plot(mixed(dmta_sfo_sfo3p_tc), test_log_parms = FALSE)
+
+# If we disregards ill-defined rate constants, the results
+# look more plausible, but the truth is likely to be in
+# between these variants
+plot(mixed(dmta_sfo_sfo3p_tc), test_log_parms = TRUE)
+# We can also specify a default value for the failing
+# log parameters, to mimic FOCUS guidance
+plot(mixed(dmta_sfo_sfo3p_tc), test_log_parms = TRUE,
+  default_log_parms = log(2)/1000)
+# As these attempts are not satisfying, we use nonlinear mixed-effects models
+# f_dmta_nlme_tc <- nlme(dmta_sfo_sfo3p_tc)
+# nlme reaches maxIter = 50 without convergence
+f_dmta_saem_tc <- saem(dmta_sfo_sfo3p_tc)
+# I am commenting out the convergence plot as rendering them
+# with pkgdown fails (at least without further tweaks to the
+# graphics device used)
+#saemix::plot(f_dmta_saem_tc$so, plot.type = "convergence")
+summary(f_dmta_saem_tc)
+#> saemix version used for fitting:      3.3 
+#> mkin version used for pre-fitting:  1.2.10 
+#> R version used for fitting:         4.4.2 
+#> Date of fit:     Fri Feb 14 07:29:22 2025 
+#> Date of summary: Fri Feb 14 07:29:22 2025 
+#> 
+#> Equations:
+#> d_DMTA/dt = - k_DMTA * DMTA
+#> d_M23/dt = + f_DMTA_to_M23 * k_DMTA * DMTA - k_M23 * M23
+#> d_M27/dt = + f_DMTA_to_M27 * k_DMTA * DMTA - k_M27 * M27 + k_M31 * M31
+#> d_M31/dt = + f_DMTA_to_M31 * k_DMTA * DMTA - k_M31 * M31
+#> 
+#> Data:
+#> 563 observations of 4 variable(s) grouped in 6 datasets
+#> 
+#> Model predictions using solution type deSolve 
+#> 
+#> Fitted in 295.57 s
+#> Using 300, 100 iterations and 9 chains
+#> 
+#> Variance model: Two-component variance function 
+#> 
+#> Starting values for degradation parameters:
+#>       DMTA_0   log_k_DMTA    log_k_M23    log_k_M27    log_k_M31 f_DMTA_ilr_1 
+#>      95.5662      -2.9048      -3.8130      -4.1600      -4.1486       0.1341 
+#> f_DMTA_ilr_2 f_DMTA_ilr_3 
+#>       0.1385      -1.6700 
+#> 
+#> Fixed degradation parameter values:
+#> None
+#> 
+#> Starting values for random effects (square root of initial entries in omega):
+#>              DMTA_0 log_k_DMTA log_k_M23 log_k_M27 log_k_M31 f_DMTA_ilr_1
+#> DMTA_0        4.802     0.0000    0.0000     0.000    0.0000       0.0000
+#> log_k_DMTA    0.000     0.9834    0.0000     0.000    0.0000       0.0000
+#> log_k_M23     0.000     0.0000    0.6983     0.000    0.0000       0.0000
+#> log_k_M27     0.000     0.0000    0.0000     1.028    0.0000       0.0000
+#> log_k_M31     0.000     0.0000    0.0000     0.000    0.9841       0.0000
+#> f_DMTA_ilr_1  0.000     0.0000    0.0000     0.000    0.0000       0.7185
+#> f_DMTA_ilr_2  0.000     0.0000    0.0000     0.000    0.0000       0.0000
+#> f_DMTA_ilr_3  0.000     0.0000    0.0000     0.000    0.0000       0.0000
+#>              f_DMTA_ilr_2 f_DMTA_ilr_3
+#> DMTA_0             0.0000       0.0000
+#> log_k_DMTA         0.0000       0.0000
+#> log_k_M23          0.0000       0.0000
+#> log_k_M27          0.0000       0.0000
+#> log_k_M31          0.0000       0.0000
+#> f_DMTA_ilr_1       0.0000       0.0000
+#> f_DMTA_ilr_2       0.7378       0.0000
+#> f_DMTA_ilr_3       0.0000       0.4451
+#> 
+#> Starting values for error model parameters:
+#> a.1 b.1 
+#>   1   1 
+#> 
+#> Results:
+#> 
+#> Likelihood computed by importance sampling
+#>    AIC  BIC logLik
+#>   2276 2273  -1120
+#> 
+#> Optimised parameters:
+#>                    est.   lower   upper
+#> DMTA_0          88.4862 84.1127 92.8598
+#> log_k_DMTA      -3.0512 -3.5674 -2.5351
+#> log_k_M23       -4.0576 -4.9013 -3.2139
+#> log_k_M27       -3.8584 -4.2572 -3.4595
+#> log_k_M31       -3.9779 -4.4844 -3.4714
+#> f_DMTA_ilr_1     0.1264 -0.2186  0.4714
+#> f_DMTA_ilr_2     0.1509 -0.2547  0.5565
+#> f_DMTA_ilr_3    -1.3891 -1.6962 -1.0819
+#> a.1              0.9196  0.8307  1.0085
+#> b.1              0.1377  0.1205  0.1549
+#> SD.DMTA_0        3.5956 -0.8167  8.0078
+#> SD.log_k_DMTA    0.6437  0.2784  1.0091
+#> SD.log_k_M23     0.9929  0.3719  1.6139
+#> SD.log_k_M27     0.4530  0.1522  0.7537
+#> SD.log_k_M31     0.5773  0.1952  0.9595
+#> SD.f_DMTA_ilr_1  0.4063  0.1505  0.6621
+#> SD.f_DMTA_ilr_2  0.4800  0.1817  0.7783
+#> SD.f_DMTA_ilr_3  0.3582  0.1350  0.5814
+#> 
+#> Correlation: 
+#>              DMTA_0  l__DMTA lg__M23 lg__M27 lg__M31 f_DMTA__1 f_DMTA__2
+#> log_k_DMTA    0.0306                                                    
+#> log_k_M23    -0.0234 -0.0032                                            
+#> log_k_M27    -0.0380 -0.0049  0.0041                                    
+#> log_k_M31    -0.0247 -0.0031  0.0022  0.0817                            
+#> f_DMTA_ilr_1 -0.0046 -0.0006  0.0425 -0.0438  0.0319                    
+#> f_DMTA_ilr_2 -0.0008 -0.0002  0.0216 -0.0267 -0.0890 -0.0349            
+#> f_DMTA_ilr_3 -0.1805 -0.0136  0.0434  0.0791  0.0390 -0.0061    0.0053  
+#> 
+#> Random effects:
+#>                   est.   lower  upper
+#> SD.DMTA_0       3.5956 -0.8167 8.0078
+#> SD.log_k_DMTA   0.6437  0.2784 1.0091
+#> SD.log_k_M23    0.9929  0.3719 1.6139
+#> SD.log_k_M27    0.4530  0.1522 0.7537
+#> SD.log_k_M31    0.5773  0.1952 0.9595
+#> SD.f_DMTA_ilr_1 0.4063  0.1505 0.6621
+#> SD.f_DMTA_ilr_2 0.4800  0.1817 0.7783
+#> SD.f_DMTA_ilr_3 0.3582  0.1350 0.5814
+#> 
+#> Variance model:
+#>       est.  lower  upper
+#> a.1 0.9196 0.8307 1.0085
+#> b.1 0.1377 0.1205 0.1549
+#> 
+#> Backtransformed parameters:
+#>                   est.     lower    upper
+#> DMTA_0        88.48621 84.112654 92.85977
+#> k_DMTA         0.04730  0.028230  0.07926
+#> k_M23          0.01729  0.007437  0.04020
+#> k_M27          0.02110  0.014162  0.03144
+#> k_M31          0.01872  0.011283  0.03107
+#> f_DMTA_to_M23  0.14551        NA       NA
+#> f_DMTA_to_M27  0.12169        NA       NA
+#> f_DMTA_to_M31  0.11062        NA       NA
+#> 
+#> Resulting formation fractions:
+#>               ff
+#> DMTA_M23  0.1455
+#> DMTA_M27  0.1217
+#> DMTA_M31  0.1106
+#> DMTA_sink 0.6222
+#> 
+#> Estimated disappearance times:
+#>       DT50   DT90
+#> DMTA 14.65  48.68
+#> M23  40.09 133.17
+#> M27  32.85 109.11
+#> M31  37.02 122.97
+# As the confidence interval for the random effects of DMTA_0
+# includes zero, we could try an alternative model without
+# such random effects
+# f_dmta_saem_tc_2 <- saem(dmta_sfo_sfo3p_tc,
+#   covariance.model = diag(c(0, rep(1, 7))))
+# saemix::plot(f_dmta_saem_tc_2$so, plot.type = "convergence")
+# This does not perform better judged by AIC and BIC
+# saemix::compare.saemix(f_dmta_saem_tc$so, f_dmta_saem_tc_2$so)
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/ds_dfop.html b/docs/dev/reference/ds_dfop.html new file mode 100644 index 00000000..66134d2e --- /dev/null +++ b/docs/dev/reference/ds_dfop.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/ds_dfop_sfo.html b/docs/dev/reference/ds_dfop_sfo.html new file mode 100644 index 00000000..66134d2e --- /dev/null +++ b/docs/dev/reference/ds_dfop_sfo.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/ds_fomc.html b/docs/dev/reference/ds_fomc.html new file mode 100644 index 00000000..66134d2e --- /dev/null +++ b/docs/dev/reference/ds_fomc.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/ds_hs.html b/docs/dev/reference/ds_hs.html new file mode 100644 index 00000000..66134d2e --- /dev/null +++ b/docs/dev/reference/ds_hs.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/ds_mixed-1.png b/docs/dev/reference/ds_mixed-1.png new file mode 100644 index 00000000..7968f1c9 Binary files /dev/null and b/docs/dev/reference/ds_mixed-1.png differ diff --git a/docs/dev/reference/ds_mixed.html b/docs/dev/reference/ds_mixed.html new file mode 100644 index 00000000..875949dd --- /dev/null +++ b/docs/dev/reference/ds_mixed.html @@ -0,0 +1,208 @@ + +Synthetic data for hierarchical kinetic degradation models — ds_mixed • mkin + Skip to contents + + +
+
+
+ +
+

The R code used to create this data object is installed with this package in +the 'dataset_generation' directory.

+
+ + + +
+

Examples

+
# \dontrun{
+  sfo_mmkin <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc", cores = 15)
+  sfo_saem <- saem(sfo_mmkin, no_random_effect = "parent_0")
+  plot(sfo_saem)
+
+# }
+
+# This is the code used to generate the datasets
+cat(readLines(system.file("dataset_generation/ds_mixed.R", package = "mkin")), sep = "\n")
+#> # Synthetic data for hierarchical kinetic models
+#> # Refactored version of the code previously in tests/testthat/setup_script.R
+#> # The number of datasets was 3 for FOMC, and 10 for HS in that script, now it
+#> # is always 15 for consistency
+#> 
+#> library(mkin)  # We use mkinmod and mkinpredict
+#> sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+#> n <- 15
+#> log_sd <- 0.3
+#> err_1 = list(const = 1, prop = 0.05)
+#> tc <- function(value) sigma_twocomp(value, err_1$const, err_1$prop)
+#> const <- function(value) 2
+#> 
+#> set.seed(123456)
+#> SFO <- mkinmod(parent = mkinsub("SFO"))
+#> sfo_pop <- list(parent_0 = 100, k_parent = 0.03)
+#> sfo_parms <- as.matrix(data.frame(
+#>     k_parent = rlnorm(n, log(sfo_pop$k_parent), log_sd)))
+#> set.seed(123456)
+#> ds_sfo <- lapply(1:n, function(i) {
+#>   ds_mean <- mkinpredict(SFO, sfo_parms[i, ],
+#>     c(parent = sfo_pop$parent_0), sampling_times)
+#>   add_err(ds_mean, tc, n = 1)[[1]]
+#> })
+#> attr(ds_sfo, "pop") <- sfo_pop
+#> attr(ds_sfo, "parms") <- sfo_parms
+#> 
+#> set.seed(123456)
+#> FOMC <- mkinmod(parent = mkinsub("FOMC"))
+#> fomc_pop <- list(parent_0 = 100, alpha = 2, beta = 8)
+#> fomc_parms <- as.matrix(data.frame(
+#>     alpha = rlnorm(n, log(fomc_pop$alpha), 0.4),
+#>     beta = rlnorm(n, log(fomc_pop$beta), 0.2)))
+#> set.seed(123456)
+#> ds_fomc <- lapply(1:n, function(i) {
+#>   ds_mean <- mkinpredict(FOMC, fomc_parms[i, ],
+#>     c(parent = fomc_pop$parent_0), sampling_times)
+#>   add_err(ds_mean, tc, n = 1)[[1]]
+#> })
+#> attr(ds_fomc, "pop") <- fomc_pop
+#> attr(ds_fomc, "parms") <- fomc_parms
+#> 
+#> set.seed(123456)
+#> DFOP <- mkinmod(parent = mkinsub("DFOP"))
+#> dfop_pop <- list(parent_0 = 100, k1 = 0.06, k2 = 0.015, g = 0.4)
+#> dfop_parms <- as.matrix(data.frame(
+#>   k1 = rlnorm(n, log(dfop_pop$k1), log_sd),
+#>   k2 = rlnorm(n, log(dfop_pop$k2), log_sd),
+#>   g = plogis(rnorm(n, qlogis(dfop_pop$g), log_sd))))
+#> set.seed(123456)
+#> ds_dfop <- lapply(1:n, function(i) {
+#>   ds_mean <- mkinpredict(DFOP, dfop_parms[i, ],
+#>     c(parent = dfop_pop$parent_0), sampling_times)
+#>   add_err(ds_mean, tc, n = 1)[[1]]
+#> })
+#> attr(ds_dfop, "pop") <- dfop_pop
+#> attr(ds_dfop, "parms") <- dfop_parms
+#> 
+#> set.seed(123456)
+#> HS <- mkinmod(parent = mkinsub("HS"))
+#> hs_pop <- list(parent_0 = 100, k1 = 0.08, k2 = 0.01, tb = 15)
+#> hs_parms <- as.matrix(data.frame(
+#>   k1 = rlnorm(n, log(hs_pop$k1), log_sd),
+#>   k2 = rlnorm(n, log(hs_pop$k2), log_sd),
+#>   tb = rlnorm(n, log(hs_pop$tb), 0.1)))
+#> set.seed(123456)
+#> ds_hs <- lapply(1:n, function(i) {
+#>   ds_mean <- mkinpredict(HS, hs_parms[i, ],
+#>     c(parent = hs_pop$parent_0), sampling_times)
+#>   add_err(ds_mean, const, n = 1)[[1]]
+#> })
+#> attr(ds_hs, "pop") <- hs_pop
+#> attr(ds_hs, "parms") <- hs_parms
+#> 
+#> set.seed(123456)
+#> DFOP_SFO <- mkinmod(
+#>   parent = mkinsub("DFOP", "m1"),
+#>   m1 = mkinsub("SFO"),
+#>   quiet = TRUE)
+#> dfop_sfo_pop <- list(parent_0 = 100,
+#>   k_m1 = 0.007, f_parent_to_m1 = 0.5,
+#>   k1 = 0.1, k2 = 0.02, g = 0.5)
+#> dfop_sfo_parms <- as.matrix(data.frame(
+#>   k1 = rlnorm(n, log(dfop_sfo_pop$k1), log_sd),
+#>   k2 = rlnorm(n, log(dfop_sfo_pop$k2), log_sd),
+#>   g = plogis(rnorm(n, qlogis(dfop_sfo_pop$g), log_sd)),
+#>   f_parent_to_m1 = plogis(rnorm(n,
+#>       qlogis(dfop_sfo_pop$f_parent_to_m1), log_sd)),
+#>   k_m1 = rlnorm(n, log(dfop_sfo_pop$k_m1), log_sd)))
+#> ds_dfop_sfo_mean <- lapply(1:n,
+#>   function(i) {
+#>     mkinpredict(DFOP_SFO, dfop_sfo_parms[i, ],
+#>       c(parent = dfop_sfo_pop$parent_0, m1 = 0), sampling_times)
+#>   }
+#> )
+#> set.seed(123456)
+#> ds_dfop_sfo <- lapply(ds_dfop_sfo_mean, function(ds) {
+#>   add_err(ds,
+#>     sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2),
+#>     n = 1, secondary = "m1")[[1]]
+#> })
+#> attr(ds_dfop_sfo, "pop") <- dfop_sfo_pop
+#> attr(ds_dfop_sfo, "parms") <- dfop_sfo_parms
+#> 
+#> #save(ds_sfo, ds_fomc, ds_dfop, ds_hs, ds_dfop_sfo, file = "data/ds_mixed.rda", version = 2)
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/ds_sfo.html b/docs/dev/reference/ds_sfo.html new file mode 100644 index 00000000..66134d2e --- /dev/null +++ b/docs/dev/reference/ds_sfo.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/endpoints.html b/docs/dev/reference/endpoints.html new file mode 100644 index 00000000..daa1ec0b --- /dev/null +++ b/docs/dev/reference/endpoints.html @@ -0,0 +1,181 @@ + +Function to calculate endpoints for further use from kinetic models fitted with mkinfit — endpoints • mkin + Skip to contents + + +
+
+
+ +
+

This function calculates DT50 and DT90 values as well as formation fractions +from kinetic models fitted with mkinfit. If the SFORB model was specified +for one of the parents or metabolites, the Eigenvalues are returned. These +are equivalent to the rate constants of the DFOP model, but with the +advantage that the SFORB model can also be used for metabolites.

+
+ +
+

Usage

+
endpoints(fit, covariates = NULL, covariate_quantile = 0.5)
+
+ +
+

Arguments

+ + +
fit
+

An object of class mkinfit, nlme.mmkin or saem.mmkin, or +another object that has list components mkinmod containing an mkinmod +degradation model, and two numeric vectors, bparms.optim and bparms.fixed, +that contain parameter values for that model.

+ + +
covariates
+

Numeric vector with covariate values for all variables in +any covariate models in the object. If given, it overrides 'covariate_quantile'.

+ + +
covariate_quantile
+

This argument only has an effect if the fitted +object has covariate models. If so, the default is to show endpoints +for the median of the covariate values (50th percentile).

+ +
+
+

Value

+

A list with a matrix of dissipation times named distimes, and, if +applicable, a vector of formation fractions named ff and, if the SFORB model +was in use, a vector of eigenvalues of these SFORB models, equivalent to +DFOP rate constants

+
+
+

Details

+

Additional DT50 values are calculated from the FOMC DT90 and k1 and k2 from +HS and DFOP, as well as from Eigenvalues b1 and b2 of any SFORB models

+
+
+

Note

+

The function is used internally by summary.mkinfit, +summary.nlme.mmkin and summary.saem.mmkin.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+  endpoints(fit)
+#> $distimes
+#>            DT50    DT90 DT50back
+#> parent 1.785233 15.1479 4.559973
+#> 
+  # \dontrun{
+    fit_2 <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE)
+    endpoints(fit_2)
+#> $distimes
+#>            DT50     DT90 DT50back  DT50_k1  DT50_k2
+#> parent 1.886925 21.25106 6.397207 1.508293 38.83438
+#> 
+    fit_3 <- mkinfit("SFORB", FOCUS_2006_C, quiet = TRUE)
+    endpoints(fit_3)
+#> $ff
+#> parent_free 
+#>           1 
+#> 
+#> $SFORB
+#> parent_b1 parent_b2  parent_g 
+#> 0.4595574 0.0178488 0.8539454 
+#> 
+#> $distimes
+#>            DT50     DT90 DT50back DT50_parent_b1 DT50_parent_b2
+#> parent 1.886925 21.25106 6.397208       1.508293       38.83438
+#> 
+  # }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/experimental_data_for_UBA-1.png b/docs/dev/reference/experimental_data_for_UBA-1.png new file mode 100644 index 00000000..07c1b33e Binary files /dev/null and b/docs/dev/reference/experimental_data_for_UBA-1.png differ diff --git a/docs/dev/reference/experimental_data_for_UBA.html b/docs/dev/reference/experimental_data_for_UBA.html new file mode 100644 index 00000000..93ed1dfa --- /dev/null +++ b/docs/dev/reference/experimental_data_for_UBA.html @@ -0,0 +1,255 @@ + +Experimental datasets used for development and testing of error models — experimental_data_for_UBA_2019 • mkin + Skip to contents + + +
+
+
+ +
+

The 12 datasets were extracted from active substance evaluation dossiers published + by EFSA. Kinetic evaluations shown for these datasets are intended to illustrate + and advance error model specifications. The fact that these data and some + results are shown here do not imply a license to use them in the context of + pesticide registrations, as the use of the data may be constrained by + data protection regulations.

+

Preprocessing of data was performed based on the recommendations of the FOCUS + kinetics workgroup (FOCUS, 2014) as described below.

+

Datasets 1 and 2 are from the Renewal Assessment Report (RAR) for imazamox + (France, 2015, p. 15). For setting values reported as zero, an LOQ of 0.1 + was assumed. Metabolite residues reported for day zero were added to the + parent compound residues.

+

Datasets 3 and 4 are from the Renewal Assessment Report (RAR) for isofetamid + (Belgium, 2014, p. 8) and show the data for two different radiolabels. For + dataset 4, the value given for the metabolite in the day zero sampling + in replicate B was added to the parent compound, following the respective + FOCUS recommendation.

+

Dataset 5 is from the Renewal Assessment Report (RAR) for ethofumesate + (Austria, 2015, p. 16).

+

Datasets 6 to 10 are from the Renewal Assessment Report (RAR) for glyphosate + (Germany, 2013, pages 8, 28, 50, 51). For the initial sampling, + the residues given for the metabolite were added to the parent + value, following the recommendation of the FOCUS kinetics workgroup.

+

Dataset 11 is from the Renewal Assessment Report (RAR) for 2,4-D + (Hellas, 2013, p. 644). Values reported as zero were set to NA, with + the exception of the day three sampling of metabolite A2, which was set + to one half of the LOD reported to be 1% AR.

+

Dataset 12 is from the Renewal Assessment Report (RAR) for thifensulfuron-methyl + (United Kingdom, 2014, p. 81).

+
+ +
+

Usage

+
experimental_data_for_UBA_2019
+
+ +
+

Format

+

A list containing twelve datasets as an R6 class defined by mkinds, + each containing, among others, the following components

title
+

The name of the dataset, e.g. Soil 1

+ +
data
+

A data frame with the data in the form expected by mkinfit

+ + +
+
+

Source

+ + +

Austria (2015). Ethofumesate Renewal Assessment Report Volume 3 Annex B.8 (AS)

+

Belgium (2014). Isofetamid (IKF-5411) Draft Assessment Report Volume 3 Annex B.8 (AS)

+

France (2015). Imazamox Draft Renewal Assessment Report Volume 3 Annex B.8 (AS)

+

FOCUS (2014) “Generic guidance for Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

Germany (2013). Renewal Assessment Report Glyphosate Volume 3 Annex B.8: Environmental Fate + and Behaviour

+

Hellas (2013). Renewal Assessment Report 2,4-D Volume 3 Annex B.8: Fate and behaviour in the + environment

+

Ranke (2019) Documentation of results obtained for the error model expertise + written for the German Umweltbundesamt.

+

United Kingdom (2014). Thifensulfuron-methyl - Annex B.8 (Volume 3) to the Report and Proposed + Decision of the United Kingdom made to the European Commission under Regulation (EC) No. + 1141/2010 for renewal of an active substance

+
+ +
+

Examples

+
# \dontrun{
+
+# Model definitions
+sfo_sfo <- mkinmod(
+  parent = mkinsub("SFO", to = "A1"),
+  A1 = mkinsub("SFO"),
+  use_of_ff = "max"
+)
+#> Temporary DLL for differentials generated and loaded
+
+dfop_sfo <- mkinmod(
+  parent = mkinsub("DFOP", to = "A1"),
+  A1 = mkinsub("SFO"),
+  use_of_ff = "max"
+)
+#> Temporary DLL for differentials generated and loaded
+
+sfo_sfo_sfo <- mkinmod(
+  parent = mkinsub("SFO", to = "A1"),
+  A1 = mkinsub("SFO", to = "A2"),
+  A2 = mkinsub("SFO"),
+  use_of_ff = "max"
+)
+#> Temporary DLL for differentials generated and loaded
+
+dfop_sfo_sfo <- mkinmod(
+  parent = mkinsub("DFOP", to = "A1"),
+  A1 = mkinsub("SFO", to = "A2"),
+  A2 = mkinsub("SFO"),
+  use_of_ff = "max"
+)
+#> Temporary DLL for differentials generated and loaded
+d_1_2 <- lapply(experimental_data_for_UBA_2019[1:2], function(x) x$data)
+names(d_1_2) <- paste("Soil", 1:2)
+
+
+f_1_2_tc <- mmkin(list("DFOP-SFO-SFO" = dfop_sfo_sfo), d_1_2, error_model = "tc")
+
+plot(f_1_2_tc, resplot = "errmod")
+
+
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/f_time_norm_focus.html b/docs/dev/reference/f_time_norm_focus.html new file mode 100644 index 00000000..f59f5eb2 --- /dev/null +++ b/docs/dev/reference/f_time_norm_focus.html @@ -0,0 +1,203 @@ + +Normalisation factors for aerobic soil degradation according to FOCUS guidance — f_time_norm_focus • mkin + Skip to contents + + +
+
+
+ +
+

Time step normalisation factors for aerobic soil degradation as described +in Appendix 8 to the FOCUS kinetics guidance (FOCUS 2014, p. 369).

+
+ +
+

Usage

+
f_time_norm_focus(object, ...)
+
+# S3 method for class 'numeric'
+f_time_norm_focus(
+  object,
+  moisture = NA,
+  field_moisture = NA,
+  temperature = object,
+  Q10 = 2.58,
+  walker = 0.7,
+  f_na = NA,
+  ...
+)
+
+# S3 method for class 'mkindsg'
+f_time_norm_focus(
+  object,
+  study_moisture_ref_source = c("auto", "meta", "focus"),
+  Q10 = 2.58,
+  walker = 0.7,
+  f_na = NA,
+  ...
+)
+
+ +
+

Arguments

+ + +
object
+

An object containing information used for the calculations

+ + +
...
+

Currently not used

+ + +
moisture
+

Numeric vector of moisture contents in \% w/w

+ + +
field_moisture
+

Numeric vector of moisture contents at field capacity +(pF2) in \% w/w

+ + +
temperature
+

Numeric vector of temperatures in °C

+ + +
Q10
+

The Q10 value used for temperature normalisation

+ + +
walker
+

The Walker exponent used for moisture normalisation

+ + +
f_na
+

The factor to use for NA values. If set to NA, only factors +for complete cases will be returned.

+ + +
study_moisture_ref_source
+

Source for the reference value +used to calculate the study moisture. If 'auto', preference is given +to a reference moisture given in the meta information, otherwise +the focus soil moisture for the soil class is used

+ +
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

See also

+ +
+ +
+

Examples

+
f_time_norm_focus(25, 20, 25) # 1.37, compare FOCUS 2014 p. 184
+#> [1] 1.373956
+
+D24_2014$meta
+#>                                 study usda_soil_type study_moisture_ref_type
+#> Mississippi                Cohen 1991      Silt loam                    <NA>
+#> Fayette     Liu and Adelfinskaya 2011      Silt loam                     pF1
+#> RefSol 03-G Liu and Adelfinskaya 2011           Loam                     pF1
+#> Site E1     Liu and Adelfinskaya 2011           Loam                     pF1
+#> Site I2     Liu and Adelfinskaya 2011     Loamy sand                     pF1
+#>             rel_moisture temperature
+#> Mississippi           NA          25
+#> Fayette              0.5          20
+#> RefSol 03-G          0.5          20
+#> Site E1              0.5          20
+#> Site I2              0.5          20
+# No moisture normalisation in the first dataset, so we use f_na = 1 to get
+# temperature only normalisation as in the EU evaluation
+f_time_norm_focus(D24_2014, study_moisture_ref_source = "focus", f_na = 1)
+#> $f_time_norm was (re)set to normalised values
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/f_time_norm_focus.mkindsg.html b/docs/dev/reference/f_time_norm_focus.mkindsg.html new file mode 100644 index 00000000..9a442194 --- /dev/null +++ b/docs/dev/reference/f_time_norm_focus.mkindsg.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/f_time_norm_focus.numeric.html b/docs/dev/reference/f_time_norm_focus.numeric.html new file mode 100644 index 00000000..9a442194 --- /dev/null +++ b/docs/dev/reference/f_time_norm_focus.numeric.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/focus_soil_moisture.html b/docs/dev/reference/focus_soil_moisture.html new file mode 100644 index 00000000..8feadc34 --- /dev/null +++ b/docs/dev/reference/focus_soil_moisture.html @@ -0,0 +1,123 @@ + +FOCUS default values for soil moisture contents at field capacity, MWHC and 1/3 bar — focus_soil_moisture • mkin + Skip to contents + + +
+
+
+ +
+

The value were transcribed from p. 36. The table assumes field capacity +corresponds to pF2, MWHC to pF 1 and 1/3 bar to pF 2.5.

+
+ +
+

Usage

+
focus_soil_moisture
+
+ +
+

Format

+

A matrix with upper case USDA soil classes as row names, and water tension +('pF1', 'pF2', 'pF 2.5') as column names

+
+
+

Source

+

Anonymous (2014) Generic Guidance for Tier 1 FOCUS Ground Water Assessment +Version 2.2, May 2014 https://esdac.jrc.ec.europa.eu/projects/ground-water

+
+ +
+

Examples

+
focus_soil_moisture
+#>                 pF1 pF2 pF2.5
+#> Sand             24  12     7
+#> Loamy sand       24  14     9
+#> Sandy loam       27  19    15
+#> Sandy clay loam  28  22    18
+#> Clay loam        32  28    25
+#> Loam             31  25    21
+#> Silt loam        32  26    21
+#> Silty clay loam  34  30    27
+#> Silt             31  27    21
+#> Sandy clay       41  35    31
+#> Silty clay       44  40    36
+#> Clay             53  48    43
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/get_deg_func.html b/docs/dev/reference/get_deg_func.html new file mode 100644 index 00000000..d3f3dc10 --- /dev/null +++ b/docs/dev/reference/get_deg_func.html @@ -0,0 +1,97 @@ + +Retrieve a degradation function from the mmkin namespace — get_deg_func • mkin + Skip to contents + + +
+
+
+ +
+

Retrieve a degradation function from the mmkin namespace

+
+ +
+

Usage

+
get_deg_func()
+
+ +
+

Value

+

A function that was likely previously assigned from within +nlme.mmkin

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/hierarchical_kinetics.html b/docs/dev/reference/hierarchical_kinetics.html new file mode 100644 index 00000000..1c225992 --- /dev/null +++ b/docs/dev/reference/hierarchical_kinetics.html @@ -0,0 +1,158 @@ + +Hierarchical kinetics template — hierarchical_kinetics • mkin + Skip to contents + + +
+
+
+ +
+

R markdown format for setting up hierarchical kinetics based on a template +provided with the mkin package. This format is based on rmarkdown::pdf_document. +Chunk options are adapted. Echoing R code from code chunks and caching are +turned on per default. character for prepending output from code chunks is +set to the empty string, code tidying is off, figure alignment defaults to +centering, and positioning of figures is set to "H", which means that +figures will not move around in the document, but stay where the user +includes them.

+
+ +
+

Usage

+
hierarchical_kinetics(..., keep_tex = FALSE)
+
+ +
+

Arguments

+ + +
...
+

Arguments to rmarkdown::pdf_document

+ + +
keep_tex
+

Keep the intermediate tex file used in the conversion to PDF. +Note that this argument does not control whether to keep the auxiliary +files (e.g., .aux) generated by LaTeX when compiling .tex to +.pdf. To keep these files, you may set options(tinytex.clean = +FALSE).

+ +
+
+

Value

+

R Markdown output format to pass to +render

+
+
+

Details

+

The latter feature (positioning the figures with "H") depends on the LaTeX +package 'float'. In addition, the LaTeX package 'listing' is used in the +template for showing model fit summaries in the Appendix. This means that +the LaTeX packages 'float' and 'listing' need to be installed in the TeX +distribution used.

+

On Windows, the easiest way to achieve this (if no TeX distribution +is present before) is to install the 'tinytex' R package, to run +'tinytex::install_tinytex()' to get the basic tiny Tex distribution, +and then to run 'tinytex::tlmgr_install(c("float", "listing"))'.

+
+ +
+

Examples

+

+# \dontrun{
+library(rmarkdown)
+# The following is now commented out after the relase of v1.2.3 for the generation
+# of online docs, as the command creates a directory and opens an editor
+#draft("example_analysis.rmd", template = "hierarchical_kinetics", package = "mkin")
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/html_listing.html b/docs/dev/reference/html_listing.html new file mode 100644 index 00000000..779fff4c --- /dev/null +++ b/docs/dev/reference/html_listing.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/illparms.html b/docs/dev/reference/illparms.html new file mode 100644 index 00000000..0b5f6661 --- /dev/null +++ b/docs/dev/reference/illparms.html @@ -0,0 +1,211 @@ + +Method to get the names of ill-defined parameters — illparms • mkin + Skip to contents + + +
+
+
+ +
+

The method for generalised nonlinear regression fits as obtained +with mkinfit and mmkin checks if the degradation parameters +pass the Wald test (in degradation kinetics often simply called t-test) for +significant difference from zero. For this test, the parameterisation +without parameter transformations is used.

+
+ +
+

Usage

+
illparms(object, ...)
+
+# S3 method for class 'mkinfit'
+illparms(object, conf.level = 0.95, ...)
+
+# S3 method for class 'illparms.mkinfit'
+print(x, ...)
+
+# S3 method for class 'mmkin'
+illparms(object, conf.level = 0.95, ...)
+
+# S3 method for class 'illparms.mmkin'
+print(x, ...)
+
+# S3 method for class 'saem.mmkin'
+illparms(
+  object,
+  conf.level = 0.95,
+  random = TRUE,
+  errmod = TRUE,
+  slopes = TRUE,
+  ...
+)
+
+# S3 method for class 'illparms.saem.mmkin'
+print(x, ...)
+
+# S3 method for class 'mhmkin'
+illparms(object, conf.level = 0.95, random = TRUE, errmod = TRUE, ...)
+
+# S3 method for class 'illparms.mhmkin'
+print(x, ...)
+
+ +
+

Arguments

+ + +
object
+

The object to investigate

+ + +
...
+

For potential future extensions

+ + +
conf.level
+

The confidence level for checking p values

+ + +
x
+

The object to be printed

+ + +
random
+

For hierarchical fits, should random effects be tested?

+ + +
errmod
+

For hierarchical fits, should error model parameters be +tested?

+ + +
slopes
+

For hierarchical saem fits using saemix as backend, +should slope parameters in the covariate model(starting with 'beta_') be +tested?

+ +
+
+

Value

+

For mkinfit or saem objects, a character vector of parameter +names. For mmkin or mhmkin objects, a matrix like object of class +'illparms.mmkin' or 'illparms.mhmkin'.

+
+
+

Details

+

The method for hierarchical model fits, also known as nonlinear +mixed-effects model fits as obtained with saem and mhmkin +checks if any of the confidence intervals for the random +effects expressed as standard deviations include zero, and if +the confidence intervals for the error model parameters include +zero.

+
+
+

Note

+

All return objects have printing methods. For the single fits, printing +does not output anything in the case no ill-defined parameters are found.

+
+ +
+

Examples

+
fit <- mkinfit("FOMC", FOCUS_2006_A, quiet = TRUE)
+#> Warning: Optimisation did not converge:
+#> false convergence (8)
+illparms(fit)
+#> [1] "parent_0" "alpha"    "beta"     "sigma"   
+# \dontrun{
+fits <- mmkin(
+  c("SFO", "FOMC"),
+  list("FOCUS A" = FOCUS_2006_A,
+       "FOCUS C" = FOCUS_2006_C),
+  quiet = TRUE)
+illparms(fits)
+#>       dataset
+#> model  FOCUS A                      FOCUS C
+#>   SFO                                      
+#>   FOMC parent_0, alpha, beta, sigma        
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/illparms.mhmkin.html b/docs/dev/reference/illparms.mhmkin.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/illparms.mhmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/illparms.mkinfit.html b/docs/dev/reference/illparms.mkinfit.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/illparms.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/illparms.mmkin.html b/docs/dev/reference/illparms.mmkin.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/illparms.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/illparms.saem.mmkin.html b/docs/dev/reference/illparms.saem.mmkin.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/illparms.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/ilr.html b/docs/dev/reference/ilr.html new file mode 100644 index 00000000..c6efae2d --- /dev/null +++ b/docs/dev/reference/ilr.html @@ -0,0 +1,163 @@ + +Function to perform isometric log-ratio transformation — ilr • mkin + Skip to contents + + +
+
+
+ +
+

This implementation is a special case of the class of isometric log-ratio +transformations.

+
+ +
+

Usage

+
ilr(x)
+
+invilr(x)
+
+ +
+

Arguments

+ + +
x
+

A numeric vector. Naturally, the forward transformation is only +sensible for vectors with all elements being greater than zero.

+ +
+
+

Value

+

The result of the forward or backward transformation. The returned +components always sum to 1 for the case of the inverse log-ratio +transformation.

+
+
+

References

+

Peter Filzmoser, Karel Hron (2008) Outlier Detection for +Compositional Data Using Robust Methods. Math Geosci 40 233-248

+
+
+

See also

+

Another implementation can be found in R package +robCompositions.

+
+
+

Author

+

René Lehmann and Johannes Ranke

+
+ +
+

Examples

+

+# Order matters
+ilr(c(0.1, 1, 10))
+#> [1] -1.628174 -2.820079
+ilr(c(10, 1, 0.1))
+#> [1] 1.628174 2.820079
+# Equal entries give ilr transformations with zeros as elements
+ilr(c(3, 3, 3))
+#> [1] 0 0
+# Almost equal entries give small numbers
+ilr(c(0.3, 0.4, 0.3))
+#> [1] -0.2034219  0.1174457
+# Only the ratio between the numbers counts, not their sum
+invilr(ilr(c(0.7, 0.29, 0.01)))
+#> [1] 0.70 0.29 0.01
+invilr(ilr(2.1 * c(0.7, 0.29, 0.01)))
+#> [1] 0.70 0.29 0.01
+# Inverse transformation of larger numbers gives unequal elements
+invilr(-10)
+#> [1] 7.213536e-07 9.999993e-01
+invilr(c(-10, 0))
+#> [1] 7.207415e-07 9.991507e-01 8.486044e-04
+# The sum of the elements of the inverse ilr is 1
+sum(invilr(c(-10, 0)))
+#> [1] 1
+# This is why we do not need all elements of the inverse transformation to go back:
+a <- c(0.1, 0.3, 0.5)
+b <- invilr(a)
+length(b) # Four elements
+#> [1] 4
+ilr(c(b[1:3], 1 - sum(b[1:3]))) # Gives c(0.1, 0.3, 0.5)
+#> [1] 0.1 0.3 0.5
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/index.html b/docs/dev/reference/index.html new file mode 100644 index 00000000..476b8804 --- /dev/null +++ b/docs/dev/reference/index.html @@ -0,0 +1,735 @@ + +Package index • mkin + Skip to contents + + +
+
+
+ +
+

Main functions

+ +

Essential functionality

+ + +
+ + + + +
+ + mkinmod() print(<mkinmod>) mkinsub() + +
+
Function to set up a kinetic model with one or more state variables
+
+ + mkinfit() + +
+
Fit a kinetic model to data with one or more state variables
+
+ + mmkin() print(<mmkin>) + +
+
Fit one or more kinetic models with one or more state variables to one or more datasets
+
+ + mhmkin() `[`(<mhmkin>) print(<mhmkin>) + +
+
Fit nonlinear mixed-effects models built from one or more kinetic degradation models and one or more error models
+
+

Generics

+ +

Generic functions introduced by the package

+ + +
+ + + + +
+ + parms() + +
+
Extract model parameters
+
+ + status() print(<status.mmkin>) print(<status.mhmkin>) + +
+
Method to get status information for fit array objects
+
+ + illparms() print(<illparms.mkinfit>) print(<illparms.mmkin>) print(<illparms.saem.mmkin>) print(<illparms.mhmkin>) + +
+
Method to get the names of ill-defined parameters
+
+ + endpoints() + +
+
Function to calculate endpoints for further use from kinetic models fitted with mkinfit
+
+ + aw() + +
+
Calculate Akaike weights for model averaging
+
+

Show results

+ +

Functions working with mkinfit objects

+ + +
+ + + + +
+ + plot(<mkinfit>) plot_sep() plot_res() plot_err() + +
+
Plot the observed data and the fitted model of an mkinfit object
+
+ + summary(<mkinfit>) print(<summary.mkinfit>) + +
+
Summary method for class "mkinfit"
+
+ + confint(<mkinfit>) + +
+
Confidence intervals for parameters of mkinfit objects
+
+ + update(<mkinfit>) + +
+
Update an mkinfit model with different arguments
+
+ + lrtest(<mkinfit>) lrtest(<mmkin>) + +
+
Likelihood ratio test for mkinfit models
+
+ + loftest() + +
+
Lack-of-fit test for models fitted to data with replicates
+
+ + mkinerrmin() + +
+
Calculate the minimum error to assume in order to pass the variance test
+
+ + CAKE_export() + +
+
Export a list of datasets format to a CAKE study file
+
+

Work with mmkin objects

+ +

Functions working with aggregated results

+ + +
+ + + + +
+ + `[`(<mmkin>) + +
+
Subsetting method for mmkin objects
+
+ + plot(<mmkin>) + +
+
Plot model fits (observed and fitted) and the residuals for a row or column of an mmkin object
+
+ + AIC(<mmkin>) BIC(<mmkin>) + +
+
Calculate the AIC for a column of an mmkin object
+
+ + summary(<mmkin>) print(<summary.mmkin>) + +
+
Summary method for class "mmkin"
+
+

Mixed models

+ +

Create and work with nonlinear hierarchical models

+ + +
+ + + + +
+ + hierarchical_kinetics() + +
+
Hierarchical kinetics template
+
+ + read_spreadsheet() + +
+
Read datasets and relevant meta information from a spreadsheet file
+
+ + nlme(<mmkin>) print(<nlme.mmkin>) update(<nlme.mmkin>) + +
+
Create an nlme model for an mmkin row object
+
+ + saem() print(<saem.mmkin>) saemix_model() saemix_data() + +
+
Fit nonlinear mixed models with SAEM
+
+ + mhmkin() `[`(<mhmkin>) print(<mhmkin>) + +
+
Fit nonlinear mixed-effects models built from one or more kinetic degradation models and one or more error models
+
+ + plot(<mixed.mmkin>) + +
+
Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object
+
+ + summary(<nlme.mmkin>) print(<summary.nlme.mmkin>) + +
+
Summary method for class "nlme.mmkin"
+
+ + summary(<saem.mmkin>) print(<summary.saem.mmkin>) + +
+
Summary method for class "saem.mmkin"
+
+ + anova(<saem.mmkin>) + +
+
Anova method for saem.mmkin objects
+
+ + logLik(<saem.mmkin>) + +
+
logLik method for saem.mmkin objects
+
+ + nlme_function() nlme_data() + +
+
Helper functions to create nlme models from mmkin row objects
+
+ + get_deg_func() + +
+
Retrieve a degradation function from the mmkin namespace
+
+ + mixed() print(<mixed.mmkin>) + +
+
Create a mixed effects model from an mmkin row object
+
+ + reexports intervals lrtest nlme + +
+
Objects exported from other packages
+
+ + intervals(<saem.mmkin>) + +
+
Confidence intervals for parameters in saem.mmkin objects
+
+ + multistart() print(<multistart>) best() which.best() + +
+
Perform a hierarchical model fit with multiple starting values
+
+ + llhist() + +
+
Plot the distribution of log likelihoods from multistart objects
+
+ + parplot() + +
+
Plot parameter variability of multistart objects
+
+ + check_failed() + +
+
Check if fit within an mhmkin object failed
+
+

Datasets and known results

+ + + + +
+ + + + +
+ + ds_mixed ds_sfo ds_fomc ds_dfop ds_hs ds_dfop_sfo + +
+
Synthetic data for hierarchical kinetic degradation models
+
+ + D24_2014 + +
+
Aerobic soil degradation data on 2,4-D from the EU assessment in 2014
+
+ + dimethenamid_2018 + +
+
Aerobic soil degradation data on dimethenamid and dimethenamid-P from the EU assessment in 2018
+
+ + FOCUS_2006_A FOCUS_2006_B FOCUS_2006_C FOCUS_2006_D FOCUS_2006_E FOCUS_2006_F + +
+
Datasets A to F from the FOCUS Kinetics report from 2006
+
+ + FOCUS_2006_SFO_ref_A_to_F + +
+
Results of fitting the SFO model to Datasets A to F of FOCUS (2006)
+
+ + FOCUS_2006_FOMC_ref_A_to_F + +
+
Results of fitting the FOMC model to Datasets A to F of FOCUS (2006)
+
+ + FOCUS_2006_HS_ref_A_to_F + +
+
Results of fitting the HS model to Datasets A to F of FOCUS (2006)
+
+ + FOCUS_2006_DFOP_ref_A_to_B + +
+
Results of fitting the DFOP model to Datasets A to B of FOCUS (2006)
+
+ + NAFTA_SOP_Appendix_B NAFTA_SOP_Appendix_D + +
+
Example datasets from the NAFTA SOP published 2015
+
+ + NAFTA_SOP_Attachment + +
+
Example datasets from Attachment 1 to the NAFTA SOP published 2015
+
+ + mccall81_245T + +
+
Datasets on aerobic soil metabolism of 2,4,5-T in six soils
+
+ + schaefer07_complex_case + +
+
Metabolism data set used for checking the software quality of KinGUI
+
+ + synthetic_data_for_UBA_2014 + +
+
Synthetic datasets for one parent compound with two metabolites
+
+ + experimental_data_for_UBA_2019 + +
+
Experimental datasets used for development and testing of error models
+
+ + test_data_from_UBA_2014 + +
+
Three experimental datasets from two water sediment systems and one soil
+
+ + focus_soil_moisture + +
+
FOCUS default values for soil moisture contents at field capacity, MWHC and 1/3 bar
+
+ + print(<mkinds>) + +
+
A dataset class for mkin
+
+ + print(<mkindsg>) + +
+
A class for dataset groups for mkin
+
+

NAFTA guidance

+ + + + +
+ + + + +
+ + nafta() print(<nafta>) + +
+
Evaluate parent kinetics using the NAFTA guidance
+
+ + plot(<nafta>) + +
+
Plot the results of the three models used in the NAFTA scheme.
+
+

Utility functions

+ + + + +
+ + + + +
+ + summary_listing() tex_listing() html_listing() + +
+
Display the output of a summary function according to the output format
+
+ + f_time_norm_focus() + +
+
Normalisation factors for aerobic soil degradation according to FOCUS guidance
+
+ + set_nd_nq() set_nd_nq_focus() + +
+
Set non-detects and unquantified values in residue series without replicates
+
+ + max_twa_parent() max_twa_sfo() max_twa_fomc() max_twa_dfop() max_twa_hs() + +
+
Function to calculate maximum time weighted average concentrations from kinetic models fitted with mkinfit
+
+ + mkin_wide_to_long() + +
+
Convert a dataframe with observations over time into long format
+
+ + mkin_long_to_wide() + +
+
Convert a dataframe from long to wide format
+
+

Helper functions mainly used internally

+ + + + +
+ + + + +
+ + mkinpredict() + +
+
Produce predictions from a kinetic model using specific parameters
+
+ + transform_odeparms() backtransform_odeparms() + +
+
Functions to transform and backtransform kinetic parameters for fitting
+
+ + ilr() invilr() + +
+
Function to perform isometric log-ratio transformation
+
+ + logLik(<mkinfit>) + +
+
Calculated the log-likelihood of a fitted mkinfit object
+
+ + residuals(<mkinfit>) + +
+
Extract residuals from an mkinfit model
+
+ + nobs(<mkinfit>) + +
+
Number of observations on which an mkinfit object was fitted
+
+ + mkinresplot() + +
+
Function to plot residuals stored in an mkin object
+
+ + mkinparplot() + +
+
Function to plot the confidence intervals obtained using mkinfit
+
+ + mkinerrplot() + +
+
Function to plot squared residuals and the error model for an mkin object
+
+ + mean_degparms() + +
+
Calculate mean degradation parameters for an mmkin row object
+
+ + create_deg_func() + +
+
Create degradation functions for known analytical solutions
+
+

Analytical solutions

+ +

Parent only model solutions

+ + +
+ + + + +
+ + SFO.solution() + +
+
Single First-Order kinetics
+
+ + FOMC.solution() + +
+
First-Order Multi-Compartment kinetics
+
+ + DFOP.solution() + +
+
Double First-Order in Parallel kinetics
+
+ + SFORB.solution() + +
+
Single First-Order Reversible Binding kinetics
+
+ + HS.solution() + +
+
Hockey-Stick kinetics
+
+ + IORE.solution() + +
+
Indeterminate order rate equation kinetics
+
+ + logistic.solution() + +
+
Logistic kinetics
+
+

Generate synthetic datasets

+ + + + +
+ + + + +
+ + add_err() + +
+
Add normally distributed errors to simulated kinetic degradation data
+
+ + sigma_twocomp() + +
+
Two-component error model
+
+

Deprecated functions

+ +

Functions that have been superseded

+ + +
+ + + + +
+ + mkinplot() + +
+
Plot the observed data and the fitted model of an mkinfit object
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/intervals.html b/docs/dev/reference/intervals.html new file mode 100644 index 00000000..9cc267c0 --- /dev/null +++ b/docs/dev/reference/intervals.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/intervals.saem.mmkin.html b/docs/dev/reference/intervals.saem.mmkin.html new file mode 100644 index 00000000..4e25aa77 --- /dev/null +++ b/docs/dev/reference/intervals.saem.mmkin.html @@ -0,0 +1,121 @@ + +Confidence intervals for parameters in saem.mmkin objects — intervals.saem.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Confidence intervals for parameters in saem.mmkin objects

+
+ +
+

Usage

+
# S3 method for class 'saem.mmkin'
+intervals(object, level = 0.95, backtransform = TRUE, ...)
+
+ +
+

Arguments

+ + +
object
+

The fitted saem.mmkin object

+ + +
level
+

The confidence level. Must be the default of 0.95 as this is what +is available in the saemix object

+ + +
backtransform
+

In case the model was fitted with mkin transformations, +should we backtransform the parameters where a one to one correlation +between transformed and backtransformed parameters exists?

+ + +
...
+

For compatibility with the generic method

+ +
+
+

Value

+

An object with 'intervals.saem.mmkin' and 'intervals.lme' in the +class attribute

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/invilr.html b/docs/dev/reference/invilr.html new file mode 100644 index 00000000..32ca219f --- /dev/null +++ b/docs/dev/reference/invilr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/llhist.html b/docs/dev/reference/llhist.html new file mode 100644 index 00000000..fca1f427 --- /dev/null +++ b/docs/dev/reference/llhist.html @@ -0,0 +1,123 @@ + +Plot the distribution of log likelihoods from multistart objects — llhist • mkin + Skip to contents + + +
+
+
+ +
+

Produces a histogram of log-likelihoods. In addition, the likelihood of the +original fit is shown as a red vertical line.

+
+ +
+

Usage

+
llhist(object, breaks = "Sturges", lpos = "topleft", main = "", ...)
+
+ +
+

Arguments

+ + +
object
+

The multistart object

+ + +
breaks
+

Passed to hist

+ + +
lpos
+

Positioning of the legend.

+ + +
main
+

Title of the plot

+ + +
...
+

Passed to hist

+ +
+
+

See also

+ +
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/loftest-1.png b/docs/dev/reference/loftest-1.png new file mode 100644 index 00000000..e6281140 Binary files /dev/null and b/docs/dev/reference/loftest-1.png differ diff --git a/docs/dev/reference/loftest-2.png b/docs/dev/reference/loftest-2.png new file mode 100644 index 00000000..32842c7d Binary files /dev/null and b/docs/dev/reference/loftest-2.png differ diff --git a/docs/dev/reference/loftest-3.png b/docs/dev/reference/loftest-3.png new file mode 100644 index 00000000..e2a5663d Binary files /dev/null and b/docs/dev/reference/loftest-3.png differ diff --git a/docs/dev/reference/loftest-4.png b/docs/dev/reference/loftest-4.png new file mode 100644 index 00000000..a052626b Binary files /dev/null and b/docs/dev/reference/loftest-4.png differ diff --git a/docs/dev/reference/loftest-5.png b/docs/dev/reference/loftest-5.png new file mode 100644 index 00000000..168aa062 Binary files /dev/null and b/docs/dev/reference/loftest-5.png differ diff --git a/docs/dev/reference/loftest.html b/docs/dev/reference/loftest.html new file mode 100644 index 00000000..72496e83 --- /dev/null +++ b/docs/dev/reference/loftest.html @@ -0,0 +1,299 @@ + +Lack-of-fit test for models fitted to data with replicates — loftest • mkin + Skip to contents + + +
+
+
+ +
+

This is a generic function with a method currently only defined for mkinfit +objects. It fits an anova model to the data contained in the object and +compares the likelihoods using the likelihood ratio test +lrtest.default from the lmtest package.

+
+ +
+

Usage

+
loftest(object, ...)
+
+# S3 method for class 'mkinfit'
+loftest(object, ...)
+
+ +
+

Arguments

+ + +
object
+

A model object with a defined loftest method

+ + +
...
+

Not used

+ +
+
+

Details

+

The anova model is interpreted as the simplest form of an mkinfit model, +assuming only a constant variance about the means, but not enforcing any +structure of the means, so we have one model parameter for every mean +of replicate samples.

+
+
+

See also

+

lrtest

+
+ +
+

Examples

+
# \dontrun{
+test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent")
+sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE)
+plot_res(sfo_fit) # We see a clear pattern in the residuals
+
+loftest(sfo_fit)  # We have a clear lack of fit
+#> Likelihood ratio test
+#> 
+#> Model 1: ANOVA with error model const
+#> Model 2: SFO with error model const
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1  10 -40.710                         
+#> 2   3 -63.954 -7 46.487  7.027e-08 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+#
+# We try a different model (the one that was used to generate the data)
+dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE)
+plot_res(dfop_fit) # We don't see systematic deviations, but heteroscedastic residuals
+
+# therefore we should consider adapting the error model, although we have
+loftest(dfop_fit) # no lack of fit
+#> Likelihood ratio test
+#> 
+#> Model 1: ANOVA with error model const
+#> Model 2: DFOP with error model const
+#>   #Df  LogLik Df Chisq Pr(>Chisq)
+#> 1  10 -40.710                    
+#> 2   5 -42.453 -5 3.485     0.6257
+#
+# This is the anova model used internally for the comparison
+test_data_anova <- test_data
+test_data_anova$time <- as.factor(test_data_anova$time)
+anova_fit <- lm(value ~ time, data = test_data_anova)
+summary(anova_fit)
+#> 
+#> Call:
+#> lm(formula = value ~ time, data = test_data_anova)
+#> 
+#> Residuals:
+#>     Min      1Q  Median      3Q     Max 
+#> -6.1000 -0.5625  0.0000  0.5625  6.1000 
+#> 
+#> Coefficients:
+#>             Estimate Std. Error t value Pr(>|t|)    
+#> (Intercept)  103.150      2.323  44.409 7.44e-12 ***
+#> time1        -19.950      3.285  -6.073 0.000185 ***
+#> time3        -50.800      3.285 -15.465 8.65e-08 ***
+#> time7        -68.500      3.285 -20.854 6.28e-09 ***
+#> time14       -79.750      3.285 -24.278 1.63e-09 ***
+#> time28       -86.000      3.285 -26.181 8.35e-10 ***
+#> time60       -94.900      3.285 -28.891 3.48e-10 ***
+#> time90       -98.500      3.285 -29.986 2.49e-10 ***
+#> time120     -100.450      3.285 -30.580 2.09e-10 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+#> 
+#> Residual standard error: 3.285 on 9 degrees of freedom
+#> Multiple R-squared:  0.9953,	Adjusted R-squared:  0.9912 
+#> F-statistic: 240.5 on 8 and 9 DF,  p-value: 1.417e-09
+#> 
+logLik(anova_fit) # We get the same likelihood and degrees of freedom
+#> 'log Lik.' -40.71015 (df=10)
+#
+test_data_2 <- synthetic_data_for_UBA_2014[[12]]$data
+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
+sfo_lin_fit <- mkinfit(m_synth_SFO_lin, test_data_2, quiet = TRUE)
+plot_res(sfo_lin_fit) # not a good model, we try parallel formation
+
+loftest(sfo_lin_fit)
+#> Likelihood ratio test
+#> 
+#> Model 1: ANOVA with error model const
+#> Model 2: m_synth_SFO_lin with error model const and fixed parameter(s) M1_0, M2_0
+#>   #Df   LogLik  Df  Chisq Pr(>Chisq)    
+#> 1  28  -93.606                          
+#> 2   7 -171.927 -21 156.64  < 2.2e-16 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+#
+m_synth_SFO_par <- mkinmod(parent = list(type = "SFO", to = c("M1", "M2")),
+  M1 = list(type = "SFO"),
+  M2 = list(type = "SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+sfo_par_fit <- mkinfit(m_synth_SFO_par, test_data_2, quiet = TRUE)
+plot_res(sfo_par_fit) # much better for metabolites
+
+loftest(sfo_par_fit)
+#> Likelihood ratio test
+#> 
+#> Model 1: ANOVA with error model const
+#> Model 2: m_synth_SFO_par with error model const and fixed parameter(s) M1_0, M2_0
+#>   #Df   LogLik  Df  Chisq Pr(>Chisq)    
+#> 1  28  -93.606                          
+#> 2   7 -156.331 -21 125.45  < 2.2e-16 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+#
+m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2")),
+  M1 = list(type = "SFO"),
+  M2 = list(type = "SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+dfop_par_fit <- mkinfit(m_synth_DFOP_par, test_data_2, quiet = TRUE)
+plot_res(dfop_par_fit) # No visual lack of fit
+
+loftest(dfop_par_fit)  # no lack of fit found by the test
+#> Likelihood ratio test
+#> 
+#> Model 1: ANOVA with error model const
+#> Model 2: m_synth_DFOP_par with error model const and fixed parameter(s) M1_0, M2_0
+#>   #Df   LogLik  Df  Chisq Pr(>Chisq)
+#> 1  28  -93.606                      
+#> 2   9 -102.763 -19 18.313     0.5016
+#
+# The anova model used for comparison in the case of transformation products
+test_data_anova_2 <- dfop_par_fit$data
+test_data_anova_2$variable <- as.factor(test_data_anova_2$variable)
+test_data_anova_2$time <- as.factor(test_data_anova_2$time)
+anova_fit_2 <- lm(observed ~ time:variable - 1, data = test_data_anova_2)
+summary(anova_fit_2)
+#> 
+#> Call:
+#> lm(formula = observed ~ time:variable - 1, data = test_data_anova_2)
+#> 
+#> Residuals:
+#>     Min      1Q  Median      3Q     Max 
+#> -6.1000 -0.5875  0.0000  0.5875  6.1000 
+#> 
+#> Coefficients: (2 not defined because of singularities)
+#>                        Estimate Std. Error t value Pr(>|t|)    
+#> time0:variableparent    103.150      1.573  65.562  < 2e-16 ***
+#> time1:variableparent     83.200      1.573  52.882  < 2e-16 ***
+#> time3:variableparent     52.350      1.573  33.274  < 2e-16 ***
+#> time7:variableparent     34.650      1.573  22.024  < 2e-16 ***
+#> time14:variableparent    23.400      1.573  14.873 6.35e-14 ***
+#> time28:variableparent    17.150      1.573  10.901 5.47e-11 ***
+#> time60:variableparent     8.250      1.573   5.244 1.99e-05 ***
+#> time90:variableparent     4.650      1.573   2.956 0.006717 ** 
+#> time120:variableparent    2.700      1.573   1.716 0.098507 .  
+#> time0:variableM1             NA         NA      NA       NA    
+#> time1:variableM1         11.850      1.573   7.532 6.93e-08 ***
+#> time3:variableM1         22.700      1.573  14.428 1.26e-13 ***
+#> time7:variableM1         33.050      1.573  21.007  < 2e-16 ***
+#> time14:variableM1        31.250      1.573  19.863  < 2e-16 ***
+#> time28:variableM1        18.900      1.573  12.013 7.02e-12 ***
+#> time60:variableM1         7.550      1.573   4.799 6.28e-05 ***
+#> time90:variableM1         3.850      1.573   2.447 0.021772 *  
+#> time120:variableM1        2.050      1.573   1.303 0.204454    
+#> time0:variableM2             NA         NA      NA       NA    
+#> time1:variableM2          6.700      1.573   4.259 0.000254 ***
+#> time3:variableM2         16.750      1.573  10.646 8.93e-11 ***
+#> time7:variableM2         25.800      1.573  16.399 6.89e-15 ***
+#> time14:variableM2        28.600      1.573  18.178 6.35e-16 ***
+#> time28:variableM2        25.400      1.573  16.144 9.85e-15 ***
+#> time60:variableM2        21.600      1.573  13.729 3.81e-13 ***
+#> time90:variableM2        17.800      1.573  11.314 2.51e-11 ***
+#> time120:variableM2       14.100      1.573   8.962 2.79e-09 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+#> 
+#> Residual standard error: 2.225 on 25 degrees of freedom
+#> Multiple R-squared:  0.9979,	Adjusted R-squared:  0.9957 
+#> F-statistic: 469.2 on 25 and 25 DF,  p-value: < 2.2e-16
+#> 
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/loftest.mkinfit.html b/docs/dev/reference/loftest.mkinfit.html new file mode 100644 index 00000000..f66a5906 --- /dev/null +++ b/docs/dev/reference/loftest.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/logLik.mkinfit.html b/docs/dev/reference/logLik.mkinfit.html new file mode 100644 index 00000000..bc2847cc --- /dev/null +++ b/docs/dev/reference/logLik.mkinfit.html @@ -0,0 +1,160 @@ + +Calculated the log-likelihood of a fitted mkinfit object — logLik.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

This function returns the product of the likelihood densities of each +observed value, as calculated as part of the fitting procedure using +dnorm, i.e. assuming normal distribution, and with the means +predicted by the degradation model, and the standard deviations predicted by +the error model.

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+logLik(object, ...)
+
+ +
+

Arguments

+ + +
object
+

An object of class mkinfit.

+ + +
...
+

For compatibility with the generic method

+ +
+
+

Value

+

An object of class logLik with the number of estimated +parameters (degradation model parameters plus variance model parameters) +as attribute.

+
+
+

Details

+

The total number of estimated parameters returned with the value of the +likelihood is calculated as the sum of fitted degradation model parameters +and the fitted error model parameters.

+
+
+

See also

+

Compare the AIC of columns of mmkin objects using +AIC.mmkin.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  # \dontrun{
+  sfo_sfo <- mkinmod(
+    parent = mkinsub("SFO", to = "m1"),
+    m1 = mkinsub("SFO")
+  )
+#> Temporary DLL for differentials generated and loaded
+  d_t <- subset(FOCUS_2006_D, value != 0)
+  f_nw <- mkinfit(sfo_sfo, d_t, quiet = TRUE) # no weighting (weights are unity)
+  f_obs <- update(f_nw, error_model = "obs")
+  f_tc <- update(f_nw, error_model = "tc")
+  AIC(f_nw, f_obs, f_tc)
+#>       df      AIC
+#> f_nw   5 204.4486
+#> f_obs  6 205.8727
+#> f_tc   6 141.9656
+  # }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/logLik.saem.mmkin.html b/docs/dev/reference/logLik.saem.mmkin.html new file mode 100644 index 00000000..d542868e --- /dev/null +++ b/docs/dev/reference/logLik.saem.mmkin.html @@ -0,0 +1,109 @@ + +logLik method for saem.mmkin objects — logLik.saem.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

logLik method for saem.mmkin objects

+
+ +
+

Usage

+
# S3 method for class 'saem.mmkin'
+logLik(object, ..., method = c("is", "lin", "gq"))
+
+ +
+

Arguments

+ + +
object
+

The fitted saem.mmkin object

+ + +
...
+

Passed to saemix::logLik.SaemixObject

+ + +
method
+

Passed to saemix::logLik.SaemixObject

+ +
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/logistic.solution-1.png b/docs/dev/reference/logistic.solution-1.png new file mode 100644 index 00000000..65739bb7 Binary files /dev/null and b/docs/dev/reference/logistic.solution-1.png differ diff --git a/docs/dev/reference/logistic.solution-2.png b/docs/dev/reference/logistic.solution-2.png new file mode 100644 index 00000000..e737621e Binary files /dev/null and b/docs/dev/reference/logistic.solution-2.png differ diff --git a/docs/dev/reference/logistic.solution.html b/docs/dev/reference/logistic.solution.html new file mode 100644 index 00000000..f5fe368a --- /dev/null +++ b/docs/dev/reference/logistic.solution.html @@ -0,0 +1,206 @@ + +Logistic kinetics — logistic.solution • mkin + Skip to contents + + +
+
+
+ +
+

Function describing exponential decline from a defined starting value, with +an increasing rate constant, supposedly caused by microbial growth

+
+ +
+

Usage

+
logistic.solution(t, parent_0, kmax, k0, r)
+
+ +
+

Arguments

+ + +
t
+

Time.

+ + +
parent_0
+

Starting value for the response variable at time zero.

+ + +
kmax
+

Maximum rate constant.

+ + +
k0
+

Minimum rate constant effective at time zero.

+ + +
r
+

Growth rate of the increase in the rate constant.

+ +
+
+

Value

+

The value of the response variable at time t.

+
+
+

Note

+

The solution of the logistic model reduces to the +SFO.solution if k0 is equal to kmax.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

See also

+

Other parent solutions: +DFOP.solution(), +FOMC.solution(), +HS.solution(), +IORE.solution(), +SFO.solution(), +SFORB.solution()

+
+ +
+

Examples

+

+  # Reproduce the plot on page 57 of FOCUS (2014)
+  plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.2),
+       from = 0, to = 100, ylim = c(0, 100),
+       xlab = "Time", ylab = "Residue")
+  plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.4),
+       from = 0, to = 100, add = TRUE, lty = 2, col = 2)
+  plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.8),
+       from = 0, to = 100, add = TRUE, lty = 3, col = 3)
+  plot(function(x) logistic.solution(x, 100, 0.08, 0.001, 0.2),
+       from = 0, to = 100, add = TRUE, lty = 4, col = 4)
+  plot(function(x) logistic.solution(x, 100, 0.08, 0.08, 0.2),
+       from = 0, to = 100, add = TRUE, lty = 5, col = 5)
+  legend("topright", inset = 0.05,
+         legend = paste0("k0 = ", c(0.0001, 0.0001, 0.0001, 0.001, 0.08),
+                         ", r = ", c(0.2, 0.4, 0.8, 0.2, 0.2)),
+         lty = 1:5, col = 1:5)
+
+
+  # Fit with synthetic data
+  logistic <- mkinmod(parent = mkinsub("logistic"))
+
+  sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+  parms_logistic <- c(kmax = 0.08, k0 = 0.0001, r = 0.2)
+  d_logistic <- mkinpredict(logistic,
+    parms_logistic, c(parent = 100),
+    sampling_times)
+  d_2_1 <- add_err(d_logistic,
+    sdfunc = function(x) sigma_twocomp(x, 0.5, 0.07),
+    n = 1, reps = 2, digits = 5, LOD = 0.1, seed = 123456)[[1]]
+
+  m <- mkinfit("logistic", d_2_1, quiet = TRUE)
+  plot_sep(m)
+
+  summary(m)$bpar
+#>              Estimate   se_notrans   t value       Pr(>t)        Lower
+#> parent_0 1.057896e+02 1.9023449604 55.610120 3.768360e-16 1.016451e+02
+#> kmax     6.398190e-02 0.0143201030  4.467978 3.841828e-04 3.929235e-02
+#> k0       1.612775e-04 0.0005866813  0.274898 3.940351e-01 5.846688e-08
+#> r        2.263946e-01 0.1718110664  1.317695 1.061043e-01 4.335843e-02
+#> sigma    5.332935e+00 0.9145907310  5.830952 4.036926e-05 3.340213e+00
+#>                Upper
+#> parent_0 109.9341588
+#> kmax       0.1041853
+#> k0         0.4448749
+#> r          1.1821120
+#> sigma      7.3256566
+  endpoints(m)$distimes
+#>            DT50     DT90  DT50_k0 DT50_kmax
+#> parent 36.86533 62.41511 4297.853  10.83349
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/lrtest.html b/docs/dev/reference/lrtest.html new file mode 100644 index 00000000..9cc267c0 --- /dev/null +++ b/docs/dev/reference/lrtest.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/lrtest.mkinfit.html b/docs/dev/reference/lrtest.mkinfit.html new file mode 100644 index 00000000..c34e1cdd --- /dev/null +++ b/docs/dev/reference/lrtest.mkinfit.html @@ -0,0 +1,191 @@ + +Likelihood ratio test for mkinfit models — lrtest.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

Compare two mkinfit models based on their likelihood. If two fitted +mkinfit objects are given as arguments, it is checked if they have been +fitted to the same data. It is the responsibility of the user to make sure +that the models are nested, i.e. one of them has less degrees of freedom +and can be expressed by fixing the parameters of the other.

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+lrtest(object, object_2 = NULL, ...)
+
+# S3 method for class 'mmkin'
+lrtest(object, ...)
+
+ +
+

Arguments

+ + +
object
+

An mkinfit object, or an mmkin column +object containing two fits to the same data.

+ + +
object_2
+

Optionally, another mkinfit object fitted to the same data.

+ + +
...
+

Argument to mkinfit, passed to +update.mkinfit for creating the alternative fitted object.

+ +
+
+

Details

+

Alternatively, an argument to mkinfit can be given which is then passed +to update.mkinfit to obtain the alternative model.

+

The comparison is then made by the lrtest.default +method from the lmtest package. The model with the higher number of fitted +parameters (alternative hypothesis) is listed first, then the model with the +lower number of fitted parameters (null hypothesis).

+
+ +
+

Examples

+
# \dontrun{
+test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent")
+sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE)
+dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE)
+lrtest(dfop_fit, sfo_fit)
+#> Likelihood ratio test
+#> 
+#> Model 1: DFOP with error model const
+#> Model 2: SFO with error model const
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1   5 -42.453                         
+#> 2   3 -63.954 -2 43.002  4.594e-10 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+lrtest(sfo_fit, dfop_fit)
+#> Likelihood ratio test
+#> 
+#> Model 1: DFOP with error model const
+#> Model 2: SFO with error model const
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1   5 -42.453                         
+#> 2   3 -63.954 -2 43.002  4.594e-10 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+
+# The following two examples are commented out as they fail during
+# generation of the static help pages by pkgdown
+#lrtest(dfop_fit, error_model = "tc")
+#lrtest(dfop_fit, fixed_parms = c(k2 = 0))
+
+# However, this equivalent syntax also works for static help pages
+lrtest(dfop_fit, update(dfop_fit, error_model = "tc"))
+#> Likelihood ratio test
+#> 
+#> Model 1: DFOP with error model tc
+#> Model 2: DFOP with error model const
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1   6 -34.587                         
+#> 2   5 -42.453 -1 15.731  7.302e-05 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+lrtest(dfop_fit, update(dfop_fit, fixed_parms = c(k2 = 0)))
+#> Likelihood ratio test
+#> 
+#> Model 1: DFOP with error model const
+#> Model 2: DFOP with error model const and fixed parameter(s) k2
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1   5 -42.453                         
+#> 2   4 -57.340 -1 29.776  4.851e-08 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/lrtest.mmkin.html b/docs/dev/reference/lrtest.mmkin.html new file mode 100644 index 00000000..dcefa4aa --- /dev/null +++ b/docs/dev/reference/lrtest.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/max_twa_dfop.html b/docs/dev/reference/max_twa_dfop.html new file mode 100644 index 00000000..47bf3da7 --- /dev/null +++ b/docs/dev/reference/max_twa_dfop.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/max_twa_fomc.html b/docs/dev/reference/max_twa_fomc.html new file mode 100644 index 00000000..47bf3da7 --- /dev/null +++ b/docs/dev/reference/max_twa_fomc.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/max_twa_hs.html b/docs/dev/reference/max_twa_hs.html new file mode 100644 index 00000000..47bf3da7 --- /dev/null +++ b/docs/dev/reference/max_twa_hs.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/max_twa_parent.html b/docs/dev/reference/max_twa_parent.html new file mode 100644 index 00000000..550a2678 --- /dev/null +++ b/docs/dev/reference/max_twa_parent.html @@ -0,0 +1,192 @@ + +Function to calculate maximum time weighted average concentrations from kinetic models fitted with mkinfit — max_twa_parent • mkin + Skip to contents + + +
+
+
+ +
+

This function calculates maximum moving window time weighted average +concentrations (TWAs) for kinetic models fitted with mkinfit. +Currently, only calculations for the parent are implemented for the SFO, +FOMC, DFOP and HS models, using the analytical formulas given in the PEC +soil section of the FOCUS guidance.

+
+ +
+

Usage

+
max_twa_parent(fit, windows)
+
+max_twa_sfo(M0 = 1, k, t)
+
+max_twa_fomc(M0 = 1, alpha, beta, t)
+
+max_twa_dfop(M0 = 1, k1, k2, g, t)
+
+max_twa_hs(M0 = 1, k1, k2, tb, t)
+
+ +
+

Arguments

+ + +
fit
+

An object of class mkinfit.

+ + +
windows
+

The width of the time windows for which the TWAs should be +calculated.

+ + +
M0
+

The initial concentration for which the maximum time weighted +average over the decline curve should be calculated. The default is to use +a value of 1, which means that a relative maximum time weighted average +factor (f_twa) is calculated.

+ + +
k
+

The rate constant in the case of SFO kinetics.

+ + +
t
+

The width of the time window.

+ + +
alpha
+

Parameter of the FOMC model.

+ + +
beta
+

Parameter of the FOMC model.

+ + +
k1
+

The first rate constant of the DFOP or the HS kinetics.

+ + +
k2
+

The second rate constant of the DFOP or the HS kinetics.

+ + +
g
+

Parameter of the DFOP model.

+ + +
tb
+

Parameter of the HS model.

+ +
+
+

Value

+

For max_twa_parent, a numeric vector, named using the +windows argument. For the other functions, a numeric vector of +length one (also known as 'a number').

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+  max_twa_parent(fit, c(7, 21))
+#>        7       21 
+#> 34.71343 18.22124 
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/max_twa_sfo.html b/docs/dev/reference/max_twa_sfo.html new file mode 100644 index 00000000..47bf3da7 --- /dev/null +++ b/docs/dev/reference/max_twa_sfo.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mccall81_245T-1.png b/docs/dev/reference/mccall81_245T-1.png new file mode 100644 index 00000000..3bb35cbd Binary files /dev/null and b/docs/dev/reference/mccall81_245T-1.png differ diff --git a/docs/dev/reference/mccall81_245T.html b/docs/dev/reference/mccall81_245T.html new file mode 100644 index 00000000..996e9fc2 --- /dev/null +++ b/docs/dev/reference/mccall81_245T.html @@ -0,0 +1,201 @@ + +Datasets on aerobic soil metabolism of 2,4,5-T in six soils — mccall81_245T • mkin + Skip to contents + + +
+
+
+ +
+

Time course of 2,4,5-trichlorophenoxyacetic acid, and the corresponding + 2,4,5-trichlorophenol and 2,4,5-trichloroanisole as recovered in diethylether + extracts.

+
+ +
+

Usage

+
mccall81_245T
+
+ +
+

Format

+

A dataframe containing the following variables.

name
+

the name of the compound observed. Note that T245 is used as + an acronym for 2,4,5-T. T245 is a legitimate object name + in R, which is necessary for specifying models using + mkinmod.

+ +
time
+

a numeric vector containing sampling times in days after + treatment

+ +
value
+

a numeric vector containing concentrations in percent of applied radioactivity

+ +
soil
+

a factor containing the name of the soil

+ + +
+
+

Source

+

McCall P, Vrona SA, Kelley SS (1981) Fate of uniformly carbon-14 ring labelled 2,4,5-Trichlorophenoxyacetic acid and 2,4-dichlorophenoxyacetic acid. J Agric Chem 29, 100-107 + doi:10.1021/jf00103a026

+
+ +
+

Examples

+
  SFO_SFO_SFO <- mkinmod(T245 = list(type = "SFO", to = "phenol"),
+    phenol = list(type = "SFO", to = "anisole"),
+    anisole = list(type = "SFO"))
+#> Temporary DLL for differentials generated and loaded
+  # \dontrun{
+    fit.1 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+    summary(fit.1)$bpar
+#>                         Estimate   se_notrans   t value       Pr(>t)
+#> T245_0              1.038550e+02 2.1847074943 47.537272 4.472189e-18
+#> k_T245              4.337042e-02 0.0018983965 22.845818 2.276911e-13
+#> k_phenol            4.050581e-01 0.2986993738  1.356073 9.756990e-02
+#> k_anisole           6.678742e-03 0.0008021439  8.326114 2.623177e-07
+#> f_T245_to_phenol    6.227599e-01 0.3985340721  1.562626 6.949414e-02
+#> f_phenol_to_anisole 1.000000e+00 0.6718440131  1.488441 7.867790e-02
+#> sigma               2.514628e+00 0.4907558973  5.123989 6.233159e-05
+#>                            Lower        Upper
+#> T245_0              99.246061490 1.084640e+02
+#> k_T245               0.039631621 4.746194e-02
+#> k_phenol             0.218013879 7.525762e-01
+#> k_anisole            0.005370739 8.305299e-03
+#> f_T245_to_phenol     0.547559080 6.924813e-01
+#> f_phenol_to_anisole  0.000000000 1.000000e+00
+#> sigma                1.706607296 3.322649e+00
+    endpoints(fit.1)
+#> $ff
+#>    T245_phenol      T245_sink phenol_anisole    phenol_sink 
+#>   6.227599e-01   3.772401e-01   1.000000e+00   3.072478e-10 
+#> 
+#> $distimes
+#>               DT50      DT90
+#> T245     15.982025  53.09114
+#> phenol    1.711229   5.68458
+#> anisole 103.784093 344.76329
+#> 
+    # formation fraction from phenol to anisol is practically 1. As we cannot
+    # fix formation fractions when using the ilr transformation, we can turn of
+    # the sink in the model generation
+    SFO_SFO_SFO_2 <- mkinmod(T245 = list(type = "SFO", to = "phenol"),
+      phenol = list(type = "SFO", to = "anisole", sink = FALSE),
+      anisole = list(type = "SFO"))
+#> Temporary DLL for differentials generated and loaded
+    fit.2 <- mkinfit(SFO_SFO_SFO_2, subset(mccall81_245T, soil == "Commerce"),
+      quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+    summary(fit.2)$bpar
+#>                      Estimate   se_notrans   t value       Pr(>t)        Lower
+#> T245_0           1.038550e+02 2.1623653059 48.028439 4.993108e-19 99.271020328
+#> k_T245           4.337042e-02 0.0018343666 23.643268 3.573556e-14  0.039650976
+#> k_phenol         4.050582e-01 0.1177237651  3.440752 1.679255e-03  0.218746589
+#> k_anisole        6.678742e-03 0.0006829745  9.778903 1.872894e-08  0.005377083
+#> f_T245_to_phenol 6.227599e-01 0.0342197873 18.198824 2.039411e-12  0.547975634
+#> sigma            2.514628e+00 0.3790944250  6.633250 2.875782e-06  1.710983655
+#>                         Upper
+#> T245_0           108.43904079
+#> k_T245             0.04743877
+#> k_phenol           0.75005593
+#> k_anisole          0.00829550
+#> f_T245_to_phenol   0.69212307
+#> sigma              3.31827222
+    endpoints(fit.1)
+#> $ff
+#>    T245_phenol      T245_sink phenol_anisole    phenol_sink 
+#>   6.227599e-01   3.772401e-01   1.000000e+00   3.072478e-10 
+#> 
+#> $distimes
+#>               DT50      DT90
+#> T245     15.982025  53.09114
+#> phenol    1.711229   5.68458
+#> anisole 103.784093 344.76329
+#> 
+    plot_sep(fit.2)
+
+  # }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mean_degparms.html b/docs/dev/reference/mean_degparms.html new file mode 100644 index 00000000..41517875 --- /dev/null +++ b/docs/dev/reference/mean_degparms.html @@ -0,0 +1,134 @@ + +Calculate mean degradation parameters for an mmkin row object — mean_degparms • mkin + Skip to contents + + +
+
+
+ +
+

Calculate mean degradation parameters for an mmkin row object

+
+ +
+

Usage

+
mean_degparms(
+  object,
+  random = FALSE,
+  test_log_parms = FALSE,
+  conf.level = 0.6,
+  default_log_parms = NA
+)
+
+ +
+

Arguments

+ + +
object
+

An mmkin row object containing several fits of the same model to different datasets

+ + +
random
+

Should a list with fixed and random effects be returned?

+ + +
test_log_parms
+

If TRUE, log parameters are only considered in +the mean calculations if their untransformed counterparts (most likely +rate constants) pass the t-test for significant difference from zero.

+ + +
conf.level
+

Possibility to adjust the required confidence level +for parameter that are tested if requested by 'test_log_parms'.

+ + +
default_log_parms
+

If set to a numeric value, this is used +as a default value for the tested log parameters that failed the +t-test.

+ +
+
+

Value

+

If random is FALSE (default), a named vector containing mean values +of the fitted degradation model parameters. If random is TRUE, a list with +fixed and random effects, in the format required by the start argument of +nlme for the case of a single grouping variable ds.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mhmkin-1.png b/docs/dev/reference/mhmkin-1.png new file mode 100644 index 00000000..1c99aead Binary files /dev/null and b/docs/dev/reference/mhmkin-1.png differ diff --git a/docs/dev/reference/mhmkin-2.png b/docs/dev/reference/mhmkin-2.png new file mode 100644 index 00000000..7311206d Binary files /dev/null and b/docs/dev/reference/mhmkin-2.png differ diff --git a/docs/dev/reference/mhmkin.html b/docs/dev/reference/mhmkin.html new file mode 100644 index 00000000..513fc780 --- /dev/null +++ b/docs/dev/reference/mhmkin.html @@ -0,0 +1,286 @@ + +Fit nonlinear mixed-effects models built from one or more kinetic degradation models and one or more error models — mhmkin • mkin + Skip to contents + + +
+
+
+ +
+

The name of the methods expresses that (multiple) hierarchichal +(also known as multilevel) multicompartment kinetic models are +fitted. Our kinetic models are nonlinear, so we can use various nonlinear +mixed-effects model fitting functions.

+
+ +
+

Usage

+
mhmkin(objects, ...)
+
+# S3 method for class 'mmkin'
+mhmkin(objects, ...)
+
+# S3 method for class 'list'
+mhmkin(
+  objects,
+  backend = "saemix",
+  algorithm = "saem",
+  no_random_effect = NULL,
+  ...,
+  cores = if (Sys.info()["sysname"] == "Windows") 1 else parallel::detectCores(),
+  cluster = NULL
+)
+
+# S3 method for class 'mhmkin'
+x[i, j, ..., drop = FALSE]
+
+# S3 method for class 'mhmkin'
+print(x, ...)
+
+ +
+

Arguments

+ + +
objects
+

A list of mmkin objects containing fits of the same +degradation models to the same data, but using different error models. +Alternatively, a single mmkin object containing fits of several +degradation models to the same data

+ + +
...
+

Further arguments that will be passed to the nonlinear mixed-effects +model fitting function.

+ + +
backend
+

The backend to be used for fitting. Currently, only saemix is +supported

+ + +
algorithm
+

The algorithm to be used for fitting (currently not used)

+ + +
no_random_effect
+

Default is NULL and will be passed to saem. If a +character vector is supplied, it will be passed to all calls to saem, +which will exclude random effects for all matching parameters. Alternatively, +a list of character vectors or an object of class illparms.mhmkin can be +specified. They have to have the same dimensions that the return object of +the current call will have, i.e. the number of rows must match the number +of degradation models in the mmkin object(s), and the number of columns must +match the number of error models used in the mmkin object(s).

+ + +
cores
+

The number of cores to be used for multicore processing. This +is only used when the cluster argument is NULL. On Windows +machines, cores > 1 is not supported, you need to use the cluster +argument to use multiple logical processors. Per default, all cores detected +by parallel::detectCores() are used, except on Windows where the default +is 1.

+ + +
cluster
+

A cluster as returned by makeCluster to be used for +parallel execution.

+ + +
x
+

An mhmkin object.

+ + +
i
+

Row index selecting the fits for specific models

+ + +
j
+

Column index selecting the fits to specific datasets

+ + +
drop
+

If FALSE, the method always returns an mhmkin object, otherwise +either a list of fit objects or a single fit object.

+ +
+
+

Value

+

A two-dimensional array of fit objects and/or try-errors that can +be indexed using the degradation model names for the first index (row index) +and the error model names for the second index (column index), with class +attribute 'mhmkin'.

+

An object inheriting from mhmkin.

+
+
+

See also

+

[.mhmkin for subsetting mhmkin objects

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+
# \dontrun{
+# We start with separate evaluations of all the first six datasets with two
+# degradation models and two error models
+f_sep_const <- mmkin(c("SFO", "FOMC"), ds_fomc[1:6], cores = 2, quiet = TRUE)
+f_sep_tc <- update(f_sep_const, error_model = "tc")
+# The mhmkin function sets up hierarchical degradation models aka
+# nonlinear mixed-effects models for all four combinations, specifying
+# uncorrelated random effects for all degradation parameters
+f_saem_1 <- mhmkin(list(f_sep_const, f_sep_tc), cores = 2)
+status(f_saem_1)
+#>            error
+#> degradation const tc
+#>        SFO  OK    OK
+#>        FOMC OK    OK
+#> 
+#> OK: Fit terminated successfully
+# The 'illparms' function shows that in all hierarchical fits, at least
+# one random effect is ill-defined (the confidence interval for the
+# random effect expressed as standard deviation includes zero)
+illparms(f_saem_1)
+#>            error
+#> degradation const        tc                        
+#>        SFO  sd(parent_0) sd(parent_0)              
+#>        FOMC sd(log_beta) sd(parent_0), sd(log_beta)
+# Therefore we repeat the fits, excluding the ill-defined random effects
+f_saem_2 <- update(f_saem_1, no_random_effect = illparms(f_saem_1))
+status(f_saem_2)
+#>            error
+#> degradation const tc
+#>        SFO  OK    OK
+#>        FOMC OK    OK
+#> 
+#> OK: Fit terminated successfully
+illparms(f_saem_2)
+#>            error
+#> degradation const tc
+#>        SFO          
+#>        FOMC         
+# Model comparisons show that FOMC with two-component error is preferable,
+# and confirms our reduction of the default parameter model
+anova(f_saem_1)
+#> Data: 95 observations of 1 variable(s) grouped in 6 datasets
+#> 
+#>            npar    AIC    BIC     Lik
+#> SFO const     5 574.40 573.35 -282.20
+#> SFO tc        6 543.72 542.47 -265.86
+#> FOMC const    7 489.67 488.22 -237.84
+#> FOMC tc       8 406.11 404.44 -195.05
+anova(f_saem_2)
+#> Data: 95 observations of 1 variable(s) grouped in 6 datasets
+#> 
+#>            npar    AIC    BIC     Lik
+#> SFO const     4 572.22 571.39 -282.11
+#> SFO tc        5 541.63 540.59 -265.81
+#> FOMC const    6 487.38 486.13 -237.69
+#> FOMC tc       6 402.12 400.88 -195.06
+# The convergence plot for the selected model looks fine
+saemix::plot(f_saem_2[["FOMC", "tc"]]$so, plot.type = "convergence")
+
+# The plot of predictions versus data shows that we have a pretty data-rich
+# situation with homogeneous distribution of residuals, because we used the
+# same degradation model, error model and parameter distribution model that
+# was used in the data generation.
+plot(f_saem_2[["FOMC", "tc"]])
+
+# We can specify the same parameter model reductions manually
+no_ranef <- list("parent_0", "log_beta", "parent_0", c("parent_0", "log_beta"))
+dim(no_ranef) <- c(2, 2)
+f_saem_2m <- update(f_saem_1, no_random_effect = no_ranef)
+anova(f_saem_2m)
+#> Data: 95 observations of 1 variable(s) grouped in 6 datasets
+#> 
+#>            npar    AIC    BIC     Lik
+#> SFO const     4 572.22 571.39 -282.11
+#> SFO tc        5 541.63 540.59 -265.81
+#> FOMC const    6 487.38 486.13 -237.69
+#> FOMC tc       6 402.12 400.88 -195.06
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mhmkin.list.html b/docs/dev/reference/mhmkin.list.html new file mode 100644 index 00000000..19cc9c91 --- /dev/null +++ b/docs/dev/reference/mhmkin.list.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mhmkin.mmkin.html b/docs/dev/reference/mhmkin.mmkin.html new file mode 100644 index 00000000..19cc9c91 --- /dev/null +++ b/docs/dev/reference/mhmkin.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mixed-1.png b/docs/dev/reference/mixed-1.png new file mode 100644 index 00000000..d46a2485 Binary files /dev/null and b/docs/dev/reference/mixed-1.png differ diff --git a/docs/dev/reference/mixed.html b/docs/dev/reference/mixed.html new file mode 100644 index 00000000..513fb226 --- /dev/null +++ b/docs/dev/reference/mixed.html @@ -0,0 +1,199 @@ + +Create a mixed effects model from an mmkin row object — mixed • mkin + Skip to contents + + +
+
+
+ +
+

Create a mixed effects model from an mmkin row object

+
+ +
+

Usage

+
mixed(object, ...)
+
+# S3 method for class 'mmkin'
+mixed(object, method = c("none"), ...)
+
+# S3 method for class 'mixed.mmkin'
+print(x, digits = max(3, getOption("digits") - 3), ...)
+
+ +
+

Arguments

+ + +
object
+

An mmkin row object

+ + +
...
+

Currently not used

+ + +
method
+

The method to be used

+ + +
x
+

A mixed.mmkin object to print

+ + +
digits
+

Number of digits to use for printing.

+ +
+
+

Value

+

An object of class 'mixed.mmkin' which has the observed data in a +single dataframe which is convenient for plotting

+
+ +
+

Examples

+
sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+n_biphasic <- 8
+err_1 = list(const = 1, prop = 0.07)
+
+DFOP_SFO <- mkinmod(
+  parent = mkinsub("DFOP", "m1"),
+  m1 = mkinsub("SFO"),
+  quiet = TRUE)
+
+set.seed(123456)
+log_sd <- 0.3
+syn_biphasic_parms <- as.matrix(data.frame(
+  k1 = rlnorm(n_biphasic, log(0.05), log_sd),
+  k2 = rlnorm(n_biphasic, log(0.01), log_sd),
+  g = plogis(rnorm(n_biphasic, 0, log_sd)),
+  f_parent_to_m1 = plogis(rnorm(n_biphasic, 0, log_sd)),
+  k_m1 = rlnorm(n_biphasic, log(0.002), log_sd)))
+
+ds_biphasic_mean <- lapply(1:n_biphasic,
+  function(i) {
+    mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ],
+      c(parent = 100, m1 = 0), sampling_times)
+  }
+)
+
+set.seed(123456L)
+ds_biphasic <- lapply(ds_biphasic_mean, function(ds) {
+  add_err(ds,
+    sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2),
+    n = 1, secondary = "m1")[[1]]
+})
+
+# \dontrun{
+f_mmkin <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, error_model = "tc", quiet = TRUE)
+
+f_mixed <- mixed(f_mmkin)
+print(f_mixed)
+#> Kinetic model fitted by nonlinear regression to each dataset
+#> Structural model:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> d_m1/dt = + f_parent_to_m1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g)
+#>            * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+#>            exp(-k2 * time))) * parent - k_m1 * m1
+#> 
+#> Data:
+#> 271 observations of 2 variable(s) grouped in 8 datasets
+#> 
+#> <mmkin> object
+#> Status of individual fits:
+#> 
+#>           dataset
+#> model      1  2  3  4  5  6 7  8 
+#>   DFOP-SFO OK OK OK OK OK C OK OK
+#> 
+#> C: Optimisation did not converge:
+#> iteration limit reached without convergence (10)
+#> OK: No warnings
+#> 
+#> Mean fitted parameters:
+#>        parent_0        log_k_m1 f_parent_qlogis          log_k1          log_k2 
+#>      100.605312       -8.758664       -0.001917       -3.350887       -3.990017 
+#>        g_qlogis 
+#>       -0.091167 
+plot(f_mixed)
+
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mixed.mmkin.html b/docs/dev/reference/mixed.mmkin.html new file mode 100644 index 00000000..7b45f95d --- /dev/null +++ b/docs/dev/reference/mixed.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mkin_long_to_wide.html b/docs/dev/reference/mkin_long_to_wide.html new file mode 100644 index 00000000..c8c748a4 --- /dev/null +++ b/docs/dev/reference/mkin_long_to_wide.html @@ -0,0 +1,155 @@ + +Convert a dataframe from long to wide format — mkin_long_to_wide • mkin + Skip to contents + + +
+
+
+ +
+

This function takes a dataframe in the long form, i.e. with a row for each +observed value, and converts it into a dataframe with one independent +variable and several dependent variables as columns.

+
+ +
+

Usage

+
mkin_long_to_wide(long_data, time = "time", outtime = "time")
+
+ +
+

Arguments

+ + +
long_data
+

The dataframe must contain one variable called "time" with +the time values specified by the time argument, one column called +"name" with the grouping of the observed values, and finally one column of +observed values called "value".

+ + +
time
+

The name of the time variable in the long input data.

+ + +
outtime
+

The name of the time variable in the wide output data.

+ +
+
+

Value

+

Dataframe in wide format.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+mkin_long_to_wide(FOCUS_2006_D)
+#>    time parent    m1
+#> 1     0  99.46  0.00
+#> 2     0 102.04  0.00
+#> 3     1  93.50  4.84
+#> 4     1  92.50  5.64
+#> 5     3  63.23 12.91
+#> 6     3  68.99 12.96
+#> 7     7  52.32 22.97
+#> 8     7  55.13 24.47
+#> 9    14  27.27 41.69
+#> 10   14  26.64 33.21
+#> 11   21  11.50 44.37
+#> 12   21  11.64 46.44
+#> 13   35   2.85 41.22
+#> 14   35   2.91 37.95
+#> 15   50   0.69 41.19
+#> 16   50   0.63 40.01
+#> 17   75   0.05 40.09
+#> 18   75   0.06 33.85
+#> 19  100     NA 31.04
+#> 20  100     NA 33.13
+#> 21  120     NA 25.15
+#> 22  120     NA 33.31
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkin_wide_to_long.html b/docs/dev/reference/mkin_wide_to_long.html new file mode 100644 index 00000000..98a9e7e6 --- /dev/null +++ b/docs/dev/reference/mkin_wide_to_long.html @@ -0,0 +1,135 @@ + +Convert a dataframe with observations over time into long format — mkin_wide_to_long • mkin + Skip to contents + + +
+
+
+ +
+

This function simply takes a dataframe with one independent variable and +several dependent variable and converts it into the long form as required by +mkinfit.

+
+ +
+

Usage

+
mkin_wide_to_long(wide_data, time = "t")
+
+ +
+

Arguments

+ + +
wide_data
+

The dataframe must contain one variable with the time +values specified by the time argument and usually more than one +column of observed values.

+ + +
time
+

The name of the time variable.

+ +
+
+

Value

+

Dataframe in long format as needed for mkinfit.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+wide <- data.frame(t = c(1,2,3), x = c(1,4,7), y = c(3,4,5))
+mkin_wide_to_long(wide)
+#>   name time value
+#> 1    x    1     1
+#> 2    x    2     4
+#> 3    x    3     7
+#> 4    y    1     3
+#> 5    y    2     4
+#> 6    y    3     5
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinds.html b/docs/dev/reference/mkinds.html new file mode 100644 index 00000000..a0387d78 --- /dev/null +++ b/docs/dev/reference/mkinds.html @@ -0,0 +1,219 @@ + +A dataset class for mkin — mkinds • mkin + Skip to contents + + +
+
+
+ +
+

At the moment this dataset class is hardly used in mkin. For example, +mkinfit does not take mkinds datasets as argument, but works with dataframes +such as the on contained in the data field of mkinds objects. Some datasets +provided by this package come as mkinds objects nevertheless.

+
+ +
+

Usage

+
# S3 method for class 'mkinds'
+print(x, data = FALSE, ...)
+
+ +
+

Arguments

+ + +
x
+

An mkinds object.

+ + +
data
+

Should the data be printed?

+ + +
...
+

Not used.

+ +
+
+

Public fields

+

title
+

A full title for the dataset

+ + +
sampling_times
+

The sampling times

+ + +
time_unit
+

The time unit

+ + +
observed
+

Names of the observed variables

+ + +
unit
+

The unit of the observations

+ + +
replicates
+

The maximum number of replicates per sampling time

+ + +
data
+

A data frame with at least the columns name, time +and value in order to be compatible with mkinfit

+ + +

+
+
+

Methods

+ +
+

Public methods

+ +


+

Method new()

+

Create a new mkinds object

+

Usage

+

mkinds$new(title = "", data, time_unit = NA, unit = NA)

+
+ +
+

Arguments

+

title
+

The dataset title

+ + +
data
+

The data

+ + +
time_unit
+

The time unit

+ + +
unit
+

The unit of the observations

+ + +

+
+ +


+

Method clone()

+

The objects of this class are cloneable with this method.

+

Usage

+

mkinds$clone(deep = FALSE)

+
+ +
+

Arguments

+

deep
+

Whether to make a deep clone.

+ + +

+
+ +
+ +
+ +
+

Examples

+

+mds <- mkinds$new("FOCUS A", FOCUS_2006_A)
+print(mds)
+#> <mkinds> with $title:  FOCUS A 
+#> Observed compounds $observed:  parent 
+#> Sampling times $sampling_times:
+#> 0, 3, 7, 14, 30, 62, 90, 118 
+#> With a maximum of  1  replicates
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkindsg.html b/docs/dev/reference/mkindsg.html new file mode 100644 index 00000000..fec3f4be --- /dev/null +++ b/docs/dev/reference/mkindsg.html @@ -0,0 +1,407 @@ + +A class for dataset groups for mkin — mkindsg • mkin + Skip to contents + + +
+
+
+ +
+

A container for working with datasets that share at least one compound, +so that combined evaluations are desirable.

+

Time normalisation factors are initialised with a value of 1 for each +dataset if no data are supplied.

+
+ +
+

Usage

+
# S3 method for class 'mkindsg'
+print(x, data = FALSE, verbose = data, ...)
+
+ +
+

Arguments

+ + +
x
+

An mkindsg object.

+ + +
data
+

Should the mkinds objects be printed with their data?

+ + +
verbose
+

Should the mkinds objects be printed?

+ + +
...
+

Not used.

+ +
+
+

Public fields

+

title
+

A title for the dataset group

+ + +
ds
+

A list of mkinds objects

+ + +
observed_n
+

Occurrence counts of compounds in datasets

+ + +
f_time_norm
+

Time normalisation factors

+ + +
meta
+

A data frame with a row for each dataset, +containing additional information in the form +of categorical data (factors) or numerical data +(e.g. temperature, moisture, +or covariates like soil pH).

+ + +

+
+
+

Methods

+ +
+

Public methods

+ +


+

Method new()

+

Create a new mkindsg object

+

Usage

+

mkindsg$new(title = "", ds, f_time_norm = rep(1, length(ds)), meta)

+
+ +
+

Arguments

+

title
+

The title

+ + +
ds
+

A list of mkinds objects

+ + +
f_time_norm
+

Time normalisation factors

+ + +
meta
+

The meta data

+ + +

+
+ +


+

Method clone()

+

The objects of this class are cloneable with this method.

+

Usage

+

mkindsg$clone(deep = FALSE)

+
+ +
+

Arguments

+

deep
+

Whether to make a deep clone.

+ + +

+
+ +
+ +
+ +
+

Examples

+

+mdsg <- mkindsg$new("Experimental X", experimental_data_for_UBA_2019[6:10])
+print(mdsg)
+#> <mkindsg> holding 5 mkinds objects
+#> Title $title:  Experimental X 
+#> Occurrence of observed compounds $observed_n:
+#> parent     A1 
+#>      5      5 
+print(mdsg, verbose = TRUE)
+#> <mkindsg> holding 5 mkinds objects
+#> Title $title:  Experimental X 
+#> Occurrence of observed compounds $observed_n:
+#> parent     A1 
+#>      5      5 
+#> 
+#> Datasets $ds:
+#> <mkinds> with $title:  Soil 6 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 3, 6, 10, 20, 34, 55, 90, 112, 132 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#> 
+#> <mkinds> with $title:  Soil 7 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 3, 7, 14, 30, 60, 90, 120, 180 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#> 
+#> <mkinds> with $title:  Soil 8 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 1, 3, 8, 14, 27, 48, 70 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#> 
+#> <mkinds> with $title:  Soil 9 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 1, 3, 8, 14, 27, 48, 70, 91, 120 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#> 
+#> <mkinds> with $title:  Soil 10 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 8, 14, 21, 41, 63, 91, 120 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+print(mdsg, verbose = TRUE, data = TRUE)
+#> <mkindsg> holding 5 mkinds objects
+#> Title $title:  Experimental X 
+#> Occurrence of observed compounds $observed_n:
+#> parent     A1 
+#>      5      5 
+#> 
+#> Datasets $ds:
+#> <mkinds> with $title:  Soil 6 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 3, 6, 10, 20, 34, 55, 90, 112, 132 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#>    time parent   A1
+#> 1     0   97.2   NA
+#> 2     0   96.4   NA
+#> 3     3   71.1  4.3
+#> 4     3   69.2  4.6
+#> 5     6   58.1  7.0
+#> 6     6   56.6  7.2
+#> 7    10   44.4  8.2
+#> 8    10   43.4  8.0
+#> 9    20   33.3 11.0
+#> 10   20   29.2 13.7
+#> 11   34   17.6 11.5
+#> 12   34   18.0 12.7
+#> 13   55   10.5 14.9
+#> 14   55    9.3 14.5
+#> 15   90    4.5 12.1
+#> 16   90    4.7 12.3
+#> 17  112    3.0  9.9
+#> 18  112    3.4 10.2
+#> 19  132    2.3  8.8
+#> 20  132    2.7  7.8
+#> 
+#> <mkinds> with $title:  Soil 7 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 3, 7, 14, 30, 60, 90, 120, 180 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#>    time parent   A1
+#> 1     0   93.6   NA
+#> 2     0   92.3   NA
+#> 3     3   87.0  3.9
+#> 4     3   82.2  3.1
+#> 5     7   74.0  6.9
+#> 6     7   73.9  6.6
+#> 7    14   64.2 10.4
+#> 8    14   69.5  8.3
+#> 9    30   54.0 14.4
+#> 10   30   54.6 13.7
+#> 11   60   41.1 22.1
+#> 12   60   38.4 22.3
+#> 13   90   32.5 27.5
+#> 14   90   35.5 25.4
+#> 15  120   28.1 28.0
+#> 16  120   29.0 26.6
+#> 17  180   26.5 25.8
+#> 18  180   27.6 25.3
+#> 
+#> <mkinds> with $title:  Soil 8 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 1, 3, 8, 14, 27, 48, 70 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#>    time parent   A1
+#> 1     0   91.9   NA
+#> 2     0   90.8   NA
+#> 3     1   64.9  9.6
+#> 4     1   66.2  7.7
+#> 5     3   43.5 15.0
+#> 6     3   44.1 15.1
+#> 7     8   18.3 21.2
+#> 8     8   18.1 21.1
+#> 9    14   10.2 19.7
+#> 10   14   10.8 18.9
+#> 11   27    4.9 17.5
+#> 12   27    3.3 15.9
+#> 13   48    1.6  9.5
+#> 14   48    1.5  9.8
+#> 15   70    1.1  6.2
+#> 16   70    0.9  6.1
+#> 
+#> <mkinds> with $title:  Soil 9 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 1, 3, 8, 14, 27, 48, 70, 91, 120 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#>    time parent   A1
+#> 1     0   99.8   NA
+#> 2     0   98.3   NA
+#> 3     1   77.1  4.2
+#> 4     1   77.2  3.9
+#> 5     3   59.0  7.4
+#> 6     3   58.1  7.9
+#> 7     8   27.4 14.5
+#> 8     8   29.2 13.7
+#> 9    14   19.1 14.2
+#> 10   14   29.6 12.2
+#> 11   27   10.1 13.7
+#> 12   27   18.2 13.2
+#> 13   48    4.5 13.6
+#> 14   48    9.1 15.4
+#> 15   70    2.3 10.4
+#> 16   70    2.9 11.6
+#> 17   91    2.0 10.0
+#> 18   91    1.8  9.5
+#> 19  120    2.0  9.1
+#> 20  120    2.2  9.0
+#> 
+#> <mkinds> with $title:  Soil 10 
+#> Observed compounds $observed:  parent, A1 
+#> Sampling times $sampling_times:
+#> 0, 8, 14, 21, 41, 63, 91, 120 
+#> With a maximum of  2  replicates
+#> Time unit:  days 
+#> Observation unit:  \%AR 
+#>    time parent   A1
+#> 1     0   96.1   NA
+#> 2     0   94.3   NA
+#> 3     8   73.9  3.3
+#> 4     8   73.9  3.4
+#> 5    14   69.4  3.9
+#> 6    14   73.1  2.9
+#> 7    21   65.6  6.4
+#> 8    21   65.3  7.2
+#> 9    41   55.9  9.1
+#> 10   41   54.4  8.5
+#> 11   63   47.0 11.7
+#> 12   63   49.3 12.0
+#> 13   91   44.7 13.3
+#> 14   91   46.7 13.2
+#> 15  120   42.1 14.3
+#> 16  120   41.3 12.1
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinerrmin.html b/docs/dev/reference/mkinerrmin.html new file mode 100644 index 00000000..14e4e187 --- /dev/null +++ b/docs/dev/reference/mkinerrmin.html @@ -0,0 +1,163 @@ + +Calculate the minimum error to assume in order to pass the variance test — mkinerrmin • mkin + Skip to contents + + +
+
+
+ +
+

This function finds the smallest relative error still resulting in passing +the chi-squared test as defined in the FOCUS kinetics report from 2006.

+
+ +
+

Usage

+
mkinerrmin(fit, alpha = 0.05)
+
+ +
+

Arguments

+ + +
fit
+

an object of class mkinfit.

+ + +
alpha
+

The confidence level chosen for the chi-squared test.

+ +
+
+

Value

+

A dataframe with the following components:

+
err.min
+

The +relative error, expressed as a fraction.

+
n.optim
+

The number of +optimised parameters attributed to the data series.

+
df
+

The number of +remaining degrees of freedom for the chi2 error level calculations. Note +that mean values are used for the chi2 statistic and therefore every time +point with observed values in the series only counts one time.

+

The +dataframe has one row for the total dataset and one further row for each +observed state variable in the model.

+
+
+

Details

+

This function is used internally by summary.mkinfit.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in EU +Registration” Report of the FOCUS Work Group on Degradation Kinetics, EC +Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+ +
+

Examples

+

+SFO_SFO = mkinmod(parent = mkinsub("SFO", to = "m1"),
+                  m1 = mkinsub("SFO"),
+                  use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+fit_FOCUS_D = mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+round(mkinerrmin(fit_FOCUS_D), 4)
+#>          err.min n.optim df
+#> All data  0.0640       4 15
+#> parent    0.0646       2  7
+#> m1        0.0469       2  8
+# \dontrun{
+  fit_FOCUS_E = mkinfit(SFO_SFO, FOCUS_2006_E, quiet = TRUE)
+  round(mkinerrmin(fit_FOCUS_E), 4)
+#>          err.min n.optim df
+#> All data  0.1544       4 13
+#> parent    0.1659       2  7
+#> m1        0.1095       2  6
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinerrplot-1.png b/docs/dev/reference/mkinerrplot-1.png new file mode 100644 index 00000000..03a054c8 Binary files /dev/null and b/docs/dev/reference/mkinerrplot-1.png differ diff --git a/docs/dev/reference/mkinerrplot.html b/docs/dev/reference/mkinerrplot.html new file mode 100644 index 00000000..01adc052 --- /dev/null +++ b/docs/dev/reference/mkinerrplot.html @@ -0,0 +1,201 @@ + +Function to plot squared residuals and the error model for an mkin object — mkinerrplot • mkin + Skip to contents + + +
+
+
+ +
+

This function plots the squared residuals for the specified subset of the +observed variables from an mkinfit object. In addition, one or more dashed +line(s) show the fitted error model. A combined plot of the fitted model +and this error model plot can be obtained with plot.mkinfit +using the argument show_errplot = TRUE.

+
+ +
+

Usage

+
mkinerrplot(
+  object,
+  obs_vars = names(object$mkinmod$map),
+  xlim = c(0, 1.1 * max(object$data$predicted)),
+  xlab = "Predicted",
+  ylab = "Squared residual",
+  maxy = "auto",
+  legend = TRUE,
+  lpos = "topright",
+  col_obs = "auto",
+  pch_obs = "auto",
+  frame = TRUE,
+  ...
+)
+
+ +
+

Arguments

+ + +
object
+

A fit represented in an mkinfit object.

+ + +
obs_vars
+

A character vector of names of the observed variables for +which residuals should be plotted. Defaults to all observed variables in +the model

+ + +
xlim
+

plot range in x direction.

+ + +
xlab
+

Label for the x axis.

+ + +
ylab
+

Label for the y axis.

+ + +
maxy
+

Maximum value of the residuals. This is used for the scaling of +the y axis and defaults to "auto".

+ + +
legend
+

Should a legend be plotted?

+ + +
lpos
+

Where should the legend be placed? Default is "topright". Will +be passed on to legend.

+ + +
col_obs
+

Colors for the observed variables.

+ + +
pch_obs
+

Symbols to be used for the observed variables.

+ + +
frame
+

Should a frame be drawn around the plots?

+ + +
...
+

further arguments passed to plot.

+ +
+
+

Value

+

Nothing is returned by this function, as it is called for its side +effect, namely to produce a plot.

+
+
+

See also

+

mkinplot, for a way to plot the data and the fitted +lines of the mkinfit object.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# \dontrun{
+model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+fit <- mkinfit(model, FOCUS_2006_D, error_model = "tc", quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+mkinerrplot(fit)
+
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinfit-1.png b/docs/dev/reference/mkinfit-1.png new file mode 100644 index 00000000..77f6e65c Binary files /dev/null and b/docs/dev/reference/mkinfit-1.png differ diff --git a/docs/dev/reference/mkinfit.html b/docs/dev/reference/mkinfit.html new file mode 100644 index 00000000..1c84b9b2 --- /dev/null +++ b/docs/dev/reference/mkinfit.html @@ -0,0 +1,679 @@ + +Fit a kinetic model to data with one or more state variables — mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

This function maximises the likelihood of the observed data using the Port +algorithm stats::nlminb(), and the specified initial or fixed +parameters and starting values. In each step of the optimisation, the +kinetic model is solved using the function mkinpredict(), except +if an analytical solution is implemented, in which case the model is solved +using the degradation function in the mkinmod object. The +parameters of the selected error model are fitted simultaneously with the +degradation model parameters, as both of them are arguments of the +likelihood function.

+
+ +
+

Usage

+
mkinfit(
+  mkinmod,
+  observed,
+  parms.ini = "auto",
+  state.ini = "auto",
+  err.ini = "auto",
+  fixed_parms = NULL,
+  fixed_initials = names(mkinmod$diffs)[-1],
+  from_max_mean = FALSE,
+  solution_type = c("auto", "analytical", "eigen", "deSolve"),
+  method.ode = "lsoda",
+  use_compiled = "auto",
+  control = list(eval.max = 300, iter.max = 200),
+  transform_rates = TRUE,
+  transform_fractions = TRUE,
+  quiet = FALSE,
+  atol = 1e-08,
+  rtol = 1e-10,
+  error_model = c("const", "obs", "tc"),
+  error_model_algorithm = c("auto", "d_3", "direct", "twostep", "threestep", "fourstep",
+    "IRLS", "OLS"),
+  reweight.tol = 1e-08,
+  reweight.max.iter = 10,
+  trace_parms = FALSE,
+  test_residuals = FALSE,
+  ...
+)
+
+ +
+

Arguments

+ + +
mkinmod
+

A list of class mkinmod, containing the kinetic +model to be fitted to the data, or one of the shorthand names ("SFO", +"FOMC", "DFOP", "HS", "SFORB", "IORE"). If a shorthand name is given, a +parent only degradation model is generated for the variable with the +highest value in observed.

+ + +
observed
+

A dataframe or an object coercible to a dataframe +(e.g. a tibble) with the observed data. The first column called +"name" must contain the name of the observed variable for each data point. +The second column must contain the times of observation, named "time". +The third column must be named "value" and contain the observed values. +Zero values in the "value" column will be removed, with a warning, in +order to avoid problems with fitting the two-component error model. This +is not expected to be a problem, because in general, values of zero are +not observed in degradation data, because there is a lower limit of +detection.

+ + +
parms.ini
+

A named vector of initial values for the parameters, +including parameters to be optimised and potentially also fixed parameters +as indicated by fixed_parms. If set to "auto", initial values for +rate constants are set to default values. Using parameter names that are +not in the model gives an error.

+

It is possible to only specify a subset of the parameters that the model +needs. You can use the parameter lists "bparms.ode" from a previously +fitted model, which contains the differential equation parameters from +this model. This works nicely if the models are nested. An example is +given below.

+ + +
state.ini
+

A named vector of initial values for the state variables of +the model. In case the observed variables are represented by more than one +model variable, the names will differ from the names of the observed +variables (see map component of mkinmod). The default +is to set the initial value of the first model variable to the mean of the +time zero values for the variable with the maximum observed value, and all +others to 0. If this variable has no time zero observations, its initial +value is set to 100.

+ + +
err.ini
+

A named vector of initial values for the error model +parameters to be optimised. If set to "auto", initial values are set to +default values. Otherwise, inital values for all error model parameters +must be given.

+ + +
fixed_parms
+

The names of parameters that should not be optimised but +rather kept at the values specified in parms.ini. Alternatively, +a named numeric vector of parameters to be fixed, regardless of the values +in parms.ini.

+ + +
fixed_initials
+

The names of model variables for which the initial +state at time 0 should be excluded from the optimisation. Defaults to all +state variables except for the first one.

+ + +
from_max_mean
+

If this is set to TRUE, and the model has only one +observed variable, then data before the time of the maximum observed value +(after averaging for each sampling time) are discarded, and this time is +subtracted from all remaining time values, so the time of the maximum +observed mean value is the new time zero.

+ + +
solution_type
+

If set to "eigen", the solution of the system of +differential equations is based on the spectral decomposition of the +coefficient matrix in cases that this is possible. If set to "deSolve", a +numerical ode solver from package deSolve is used. If +set to "analytical", an analytical solution of the model is used. This is +only implemented for relatively simple degradation models. The default is +"auto", which uses "analytical" if possible, otherwise "deSolve" if a +compiler is present, and "eigen" if no compiler is present and the model +can be expressed using eigenvalues and eigenvectors.

+ + +
method.ode
+

The solution method passed via mkinpredict() +to deSolve::ode() in case the solution type is "deSolve". The default +"lsoda" is performant, but sometimes fails to converge.

+ + +
use_compiled
+

If set to FALSE, no compiled version of the +mkinmod model is used in the calls to mkinpredict() even if a compiled +version is present.

+ + +
control
+

A list of control arguments passed to stats::nlminb().

+ + +
transform_rates
+

Boolean specifying if kinetic rate constants should +be transformed in the model specification used in the fitting for better +compliance with the assumption of normal distribution of the estimator. If +TRUE, also alpha and beta parameters of the FOMC model are +log-transformed, as well as k1 and k2 rate constants for the DFOP and HS +models and the break point tb of the HS model. If FALSE, zero is used as +a lower bound for the rates in the optimisation.

+ + +
transform_fractions
+

Boolean specifying if formation fractions +should be transformed in the model specification used in the fitting for +better compliance with the assumption of normal distribution of the +estimator. The default (TRUE) is to do transformations. If TRUE, +the g parameter of the DFOP model is also transformed. Transformations +are described in transform_odeparms.

+ + +
quiet
+

Suppress printing out the current value of the negative +log-likelihood after each improvement?

+ + +
atol
+

Absolute error tolerance, passed to deSolve::ode(). Default +is 1e-8, which is lower than the default in the deSolve::lsoda() +function which is used per default.

+ + +
rtol
+

Absolute error tolerance, passed to deSolve::ode(). Default +is 1e-10, much lower than in deSolve::lsoda().

+ + +
error_model
+

If the error model is "const", a constant standard +deviation is assumed.

+

If the error model is "obs", each observed variable is assumed to have its +own variance.

+

If the error model is "tc" (two-component error model), a two component +error model similar to the one described by Rocke and Lorenzato (1995) is +used for setting up the likelihood function. Note that this model +deviates from the model by Rocke and Lorenzato, as their model implies +that the errors follow a lognormal distribution for large values, not a +normal distribution as assumed by this method.

+ + +
error_model_algorithm
+

If "auto", the selected algorithm depends on +the error model. If the error model is "const", unweighted nonlinear +least squares fitting ("OLS") is selected. If the error model is "obs", or +"tc", the "d_3" algorithm is selected.

+

The algorithm "d_3" will directly minimize the negative log-likelihood +and independently also use the three step algorithm described below. +The fit with the higher likelihood is returned.

+

The algorithm "direct" will directly minimize the negative log-likelihood.

+

The algorithm "twostep" will minimize the negative log-likelihood after an +initial unweighted least squares optimisation step.

+

The algorithm "threestep" starts with unweighted least squares, then +optimizes only the error model using the degradation model parameters +found, and then minimizes the negative log-likelihood with free +degradation and error model parameters.

+

The algorithm "fourstep" starts with unweighted least squares, then +optimizes only the error model using the degradation model parameters +found, then optimizes the degradation model again with fixed error model +parameters, and finally minimizes the negative log-likelihood with free +degradation and error model parameters.

+

The algorithm "IRLS" (Iteratively Reweighted Least Squares) starts with +unweighted least squares, and then iterates optimization of the error +model parameters and subsequent optimization of the degradation model +using those error model parameters, until the error model parameters +converge.

+ + +
reweight.tol
+

Tolerance for the convergence criterion calculated from +the error model parameters in IRLS fits.

+ + +
reweight.max.iter
+

Maximum number of iterations in IRLS fits.

+ + +
trace_parms
+

Should a trace of the parameter values be listed?

+ + +
test_residuals
+

Should the residuals be tested for normal distribution?

+ + +
...
+

Further arguments that will be passed on to +deSolve::ode().

+ +
+
+

Value

+

A list with "mkinfit" in the class attribute.

+
+
+

Details

+

Per default, parameters in the kinetic models are internally transformed in +order to better satisfy the assumption of a normal distribution of their +estimators.

+
+
+

Note

+

When using the "IORE" submodel for metabolites, fitting with +"transform_rates = TRUE" (the default) often leads to failures of the +numerical ODE solver. In this situation it may help to switch off the +internal rate transformation.

+
+
+

References

+

Rocke DM and Lorenzato S (1995) A two-component model +for measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+

Ranke J and Meinecke S (2019) Error Models for the Kinetic Evaluation of Chemical +Degradation Data. Environments 6(12) 124 +doi:10.3390/environments6120124 +.

+
+
+

See also

+

summary.mkinfit, plot.mkinfit, parms and lrtest.

+

Comparisons of models fitted to the same data can be made using +AIC by virtue of the method logLik.mkinfit.

+

Fitting of several models to several datasets in a single call to +mmkin.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# Use shorthand notation for parent only degradation
+fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+summary(fit)
+#> mkin version used for fitting:    1.2.10 
+#> R version used for fitting:       4.4.2 
+#> Date of fit:     Fri Feb 14 07:30:02 2025 
+#> Date of summary: Fri Feb 14 07:30:02 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
+#> 
+#> Model predictions using solution type analytical 
+#> 
+#> Fitted using 222 model solutions performed in 0.014 s
+#> 
+#> Error model: Constant variance 
+#> 
+#> Error model algorithm: OLS 
+#> 
+#> Starting values for parameters to be optimised:
+#>          value   type
+#> parent_0  85.1  state
+#> alpha      1.0 deparm
+#> beta      10.0 deparm
+#> 
+#> Starting values for the transformed parameters actually optimised:
+#>               value lower upper
+#> parent_0  85.100000  -Inf   Inf
+#> log_alpha  0.000000  -Inf   Inf
+#> log_beta   2.302585  -Inf   Inf
+#> 
+#> Fixed parameter values:
+#> None
+#> 
+#> Results:
+#> 
+#>        AIC      BIC    logLik
+#>   44.68652 45.47542 -18.34326
+#> 
+#> Optimised, transformed parameters with symmetric confidence intervals:
+#>           Estimate Std. Error    Lower   Upper
+#> parent_0  85.87000     1.8070 81.23000 90.5200
+#> log_alpha  0.05192     0.1353 -0.29580  0.3996
+#> log_beta   0.65100     0.2287  0.06315  1.2390
+#> sigma      1.85700     0.4378  0.73200  2.9830
+#> 
+#> Parameter correlation:
+#>             parent_0  log_alpha   log_beta     sigma
+#> parent_0   1.000e+00 -1.565e-01 -3.142e-01 4.681e-08
+#> log_alpha -1.565e-01  1.000e+00  9.564e-01 1.013e-07
+#> log_beta  -3.142e-01  9.564e-01  1.000e+00 8.637e-08
+#> sigma      4.681e-08  1.013e-07  8.637e-08 1.000e+00
+#> 
+#> Backtransformed parameters:
+#> Confidence intervals for internally transformed parameters are asymmetric.
+#> t-test (unrealistically) based on the assumption of normal distribution
+#> for estimators of untransformed parameters.
+#>          Estimate t value    Pr(>t)   Lower  Upper
+#> parent_0   85.870  47.530 3.893e-08 81.2300 90.520
+#> alpha       1.053   7.393 3.562e-04  0.7439  1.491
+#> beta        1.917   4.373 3.601e-03  1.0650  3.451
+#> sigma       1.857   4.243 4.074e-03  0.7320  2.983
+#> 
+#> FOCUS Chi2 error levels in percent:
+#>          err.min n.optim df
+#> All data   6.657       3  6
+#> parent     6.657       3  6
+#> 
+#> Estimated disappearance times:
+#>         DT50  DT90 DT50back
+#> parent 1.785 15.15     4.56
+#> 
+#> Data:
+#>  time variable observed predicted residual
+#>     0   parent     85.1    85.875  -0.7749
+#>     1   parent     57.9    55.191   2.7091
+#>     3   parent     29.9    31.845  -1.9452
+#>     7   parent     14.6    17.012  -2.4124
+#>    14   parent      9.7     9.241   0.4590
+#>    28   parent      6.6     4.754   1.8460
+#>    63   parent      4.0     2.102   1.8977
+#>    91   parent      3.9     1.441   2.4590
+#>   119   parent      0.6     1.092  -0.4919
+
+# One parent compound, one metabolite, both single first order.
+# We remove zero values from FOCUS dataset D in order to avoid warnings
+FOCUS_D <- subset(FOCUS_2006_D, value != 0)
+# Use mkinsub for convenience in model formulation. Pathway to sink included per default.
+SFO_SFO <- mkinmod(
+  parent = mkinsub("SFO", "m1"),
+  m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+
+# Fit the model quietly to the FOCUS example dataset D using defaults
+fit <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE)
+plot_sep(fit)
+
+# As lower parent values appear to have lower variance, we try an alternative error model
+fit.tc <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc")
+# This avoids the warning, and the likelihood ratio test confirms it is preferable
+lrtest(fit.tc, fit)
+#> Likelihood ratio test
+#> 
+#> Model 1: SFO_SFO with error model tc and fixed parameter(s) m1_0
+#> Model 2: SFO_SFO with error model const and fixed parameter(s) m1_0
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1   6 -64.983                         
+#> 2   5 -97.224 -1 64.483  9.737e-16 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+# We can also allow for different variances of parent and metabolite as error model
+fit.obs <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "obs")
+# The two-component error model has significantly higher likelihood
+lrtest(fit.obs, fit.tc)
+#> Likelihood ratio test
+#> 
+#> Model 1: SFO_SFO with error model tc and fixed parameter(s) m1_0
+#> Model 2: SFO_SFO with error model obs and fixed parameter(s) m1_0
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)    
+#> 1   6 -64.983                         
+#> 2   6 -96.936  0 63.907  < 2.2e-16 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+parms(fit.tc)
+#>       parent_0       k_parent           k_m1 f_parent_to_m1      sigma_low 
+#>   1.007343e+02   1.005562e-01   5.166712e-03   5.083933e-01   3.049883e-03 
+#>       rsd_high 
+#>   7.928118e-02 
+endpoints(fit.tc)
+#> $ff
+#>   parent_m1 parent_sink 
+#>   0.5083933   0.4916067 
+#> 
+#> $distimes
+#>             DT50      DT90
+#> parent   6.89313  22.89848
+#> m1     134.15634 445.65771
+#> 
+
+# We can show a quick (only one replication) benchmark for this case, as we
+# have several alternative solution methods for the model. We skip
+# uncompiled deSolve, as it is so slow. More benchmarks are found in the
+# benchmark vignette
+# \dontrun{
+if(require(rbenchmark)) {
+  benchmark(replications = 1, order = "relative", columns = c("test", "relative", "elapsed"),
+    deSolve_compiled = mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc",
+      solution_type = "deSolve", use_compiled = TRUE),
+    eigen = mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc",
+      solution_type = "eigen"),
+    analytical = mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE, error_model = "tc",
+      solution_type = "analytical"))
+}
+#>               test relative elapsed
+#> 3       analytical    1.000   0.242
+#> 2            eigen    1.913   0.463
+#> 1 deSolve_compiled    1.917   0.464
+# }
+
+# Use stepwise fitting, using optimised parameters from parent only fit, FOMC-SFO
+# \dontrun{
+FOMC_SFO <- mkinmod(
+  parent = mkinsub("FOMC", "m1"),
+  m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE)
+# Again, we get a warning and try a more sophisticated error model
+fit.FOMC_SFO.tc <- mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE, error_model = "tc")
+# This model has a higher likelihood, but not significantly so
+lrtest(fit.tc, fit.FOMC_SFO.tc)
+#> Likelihood ratio test
+#> 
+#> Model 1: FOMC_SFO with error model tc and fixed parameter(s) m1_0
+#> Model 2: SFO_SFO with error model tc and fixed parameter(s) m1_0
+#>   #Df  LogLik Df  Chisq Pr(>Chisq)
+#> 1   7 -64.829                     
+#> 2   6 -64.983 -1 0.3075     0.5792
+# Also, the missing standard error for log_beta and the t-tests for alpha
+# and beta indicate overparameterisation
+summary(fit.FOMC_SFO.tc, data = FALSE)
+#> Warning: NaNs produced
+#> Warning: diag(V) had non-positive or NA entries; the non-finite result may be dubious
+#> mkin version used for fitting:    1.2.10 
+#> R version used for fitting:       4.4.2 
+#> Date of fit:     Fri Feb 14 07:30:07 2025 
+#> Date of summary: Fri Feb 14 07:30:07 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
+#> d_m1/dt = + f_parent_to_m1 * (alpha/beta) * 1/((time/beta) + 1) *
+#>            parent - k_m1 * m1
+#> 
+#> Model predictions using solution type deSolve 
+#> 
+#> Fitted using 4062 model solutions performed in 0.77 s
+#> 
+#> Error model: Two-component variance function 
+#> 
+#> Error model algorithm: d_3 
+#> Direct fitting and three-step fitting yield approximately the same likelihood 
+#> 
+#> Starting values for parameters to be optimised:
+#>                 value   type
+#> parent_0       100.75  state
+#> alpha            1.00 deparm
+#> beta            10.00 deparm
+#> k_m1             0.10 deparm
+#> f_parent_to_m1   0.50 deparm
+#> sigma_low        0.10  error
+#> rsd_high         0.10  error
+#> 
+#> Starting values for the transformed parameters actually optimised:
+#>                      value lower upper
+#> parent_0        100.750000  -Inf   Inf
+#> log_k_m1         -2.302585  -Inf   Inf
+#> f_parent_qlogis   0.000000  -Inf   Inf
+#> log_alpha         0.000000  -Inf   Inf
+#> log_beta          2.302585  -Inf   Inf
+#> sigma_low         0.100000     0   Inf
+#> rsd_high          0.100000     0   Inf
+#> 
+#> Fixed parameter values:
+#>      value  type
+#> m1_0     0 state
+#> 
+#> Results:
+#> 
+#>       AIC      BIC    logLik
+#>   143.658 155.1211 -64.82902
+#> 
+#> Optimised, transformed parameters with symmetric confidence intervals:
+#>                   Estimate Std. Error     Lower      Upper
+#> parent_0        101.600000  2.6400000 96.240000 107.000000
+#> log_k_m1         -5.284000  0.0929100 -5.474000  -5.095000
+#> f_parent_qlogis   0.001426  0.0766900 -0.155000   0.157800
+#> log_alpha         5.522000  0.0077320  5.506000   5.538000
+#> log_beta          7.806000        NaN       NaN        NaN
+#> sigma_low         0.002488  0.0002431  0.001992   0.002984
+#> rsd_high          0.079210  0.0093280  0.060180   0.098230
+#> 
+#> Parameter correlation:
+#>                  parent_0  log_k_m1 f_parent_qlogis log_alpha log_beta
+#> parent_0         1.000000 -0.095161        -0.76675   0.70542      NaN
+#> log_k_m1        -0.095161  1.000000         0.51429  -0.14382      NaN
+#> f_parent_qlogis -0.766750  0.514286         1.00000  -0.61393      NaN
+#> log_alpha        0.705417 -0.143821        -0.61393   1.00000      NaN
+#> log_beta              NaN       NaN             NaN       NaN        1
+#> sigma_low        0.016086  0.001583         0.01547   5.87036      NaN
+#> rsd_high         0.006618 -0.011695        -0.05356   0.04848      NaN
+#>                 sigma_low  rsd_high
+#> parent_0         0.016086  0.006618
+#> log_k_m1         0.001583 -0.011695
+#> f_parent_qlogis  0.015466 -0.053560
+#> log_alpha        5.870361  0.048483
+#> log_beta              NaN       NaN
+#> sigma_low        1.000000 -0.652545
+#> rsd_high        -0.652545  1.000000
+#> 
+#> Backtransformed parameters:
+#> Confidence intervals for internally transformed parameters are asymmetric.
+#> t-test (unrealistically) based on the assumption of normal distribution
+#> for estimators of untransformed parameters.
+#>                 Estimate t value    Pr(>t)     Lower     Upper
+#> parent_0       1.016e+02 32.7800 6.310e-26 9.624e+01 1.070e+02
+#> k_m1           5.072e-03 10.1200 1.216e-11 4.196e-03 6.130e-03
+#> f_parent_to_m1 5.004e-01 20.8300 4.316e-20 4.613e-01 5.394e-01
+#> alpha          2.502e+02  0.5624 2.889e-01 2.463e+02 2.542e+02
+#> beta           2.455e+03  0.5549 2.915e-01        NA        NA
+#> sigma_low      2.488e-03  0.4843 3.158e-01 1.992e-03 2.984e-03
+#> rsd_high       7.921e-02  8.4300 8.001e-10 6.018e-02 9.823e-02
+#> 
+#> FOCUS Chi2 error levels in percent:
+#>          err.min n.optim df
+#> All data   6.781       5 14
+#> parent     7.141       3  6
+#> m1         4.640       2  8
+#> 
+#> Resulting formation fractions:
+#>                 ff
+#> parent_m1   0.5004
+#> parent_sink 0.4996
+#> 
+#> Estimated disappearance times:
+#>           DT50  DT90 DT50back
+#> parent   6.812  22.7    6.834
+#> m1     136.661 454.0       NA
+
+# We can easily use starting parameters from the parent only fit (only for illustration)
+fit.FOMC = mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE, error_model = "tc")
+fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE,
+  parms.ini = fit.FOMC$bparms.ode, error_model = "tc")
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinmod.html b/docs/dev/reference/mkinmod.html new file mode 100644 index 00000000..d26086eb --- /dev/null +++ b/docs/dev/reference/mkinmod.html @@ -0,0 +1,382 @@ + +Function to set up a kinetic model with one or more state variables — mkinmod • mkin + Skip to contents + + +
+
+
+ +
+

This function is usually called using a call to mkinsub() for each observed +variable, specifying the corresponding submodel as well as outgoing pathways +(see examples).

+

Print mkinmod objects in a way that the user finds his way to get to its +components.

+
+ +
+

Usage

+
mkinmod(
+  ...,
+  use_of_ff = "max",
+  name = NULL,
+  speclist = NULL,
+  quiet = FALSE,
+  verbose = FALSE,
+  dll_dir = NULL,
+  unload = FALSE,
+  overwrite = FALSE
+)
+
+# S3 method for class 'mkinmod'
+print(x, ...)
+
+mkinsub(submodel, to = NULL, sink = TRUE, full_name = NA)
+
+ +
+

Arguments

+ + +
...
+

For each observed variable, a list as obtained by mkinsub() +has to be specified as an argument (see examples). Currently, single +first order kinetics "SFO", indeterminate order rate equation kinetics +"IORE", or single first order with reversible binding "SFORB" are +implemented for all variables, while "FOMC", "DFOP", "HS" and "logistic" +can additionally be chosen for the first variable which is assumed to be +the source compartment. +Additionally, mkinsub() has an argument to, specifying names of +variables to which a transfer is to be assumed in the model. +If the argument use_of_ff is set to "min" +and the model for the compartment is "SFO" or "SFORB", an +additional mkinsub() argument can be sink = FALSE, effectively +fixing the flux to sink to zero. +In print.mkinmod, this argument is currently not used.

+ + +
use_of_ff
+

Specification of the use of formation fractions in the +model equations and, if applicable, the coefficient matrix. If "max", +formation fractions are always used (default). If "min", a minimum use of +formation fractions is made, i.e. each first-order pathway to a metabolite +has its own rate constant.

+ + +
name
+

A name for the model. Should be a valid R object name.

+ + +
speclist
+

The specification of the observed variables and their +submodel types and pathways can be given as a single list using this +argument. Default is NULL.

+ + +
quiet
+

Should messages be suppressed?

+ + +
verbose
+

If TRUE, passed to inline::cfunction() if +applicable to give detailed information about the C function being built.

+ + +
dll_dir
+

Directory where an DLL object, if generated internally by +inline::cfunction(), should be saved. The DLL will only be stored in a +permanent location for use in future sessions, if 'dll_dir' and 'name' +are specified. This is helpful if fit objects are cached e.g. by knitr, +as the cache remains functional across sessions if the DLL is stored in +a user defined location.

+ + +
unload
+

If a DLL from the target location in 'dll_dir' is already +loaded, should that be unloaded first?

+ + +
overwrite
+

If a file exists at the target DLL location in 'dll_dir', +should this be overwritten?

+ + +
x
+

An mkinmod object.

+ + +
submodel
+

Character vector of length one to specify the submodel type. +See mkinmod for the list of allowed submodel names.

+ + +
to
+

Vector of the names of the state variable to which a +transformation shall be included in the model.

+ + +
sink
+

Should a pathway to sink be included in the model in addition to +the pathways to other state variables?

+ + +
full_name
+

An optional name to be used e.g. for plotting fits +performed with the model. You can use non-ASCII characters here, but then +your R code will not be portable, i.e. may produce unintended plot +results on other operating systems or system configurations.

+ +
+
+

Value

+

A list of class mkinmod for use with mkinfit(), +containing, among others,

+
diffs
+

A vector of string representations of differential equations, one for +each modelling variable.

+ +
map
+

A list containing named character vectors for each observed variable, +specifying the modelling variables by which it is represented.

+ +
use_of_ff
+

The content of use_of_ff is passed on in this list component.

+ +
deg_func
+

If generated, a function containing the solution of the degradation +model.

+ +
coefmat
+

The coefficient matrix, if the system of differential equations can be +represented by one.

+ +
cf
+

If generated, a compiled function calculating the derivatives as +returned by cfunction.

+ + +

A list for use with mkinmod.

+
+
+

Details

+

For the definition of model types and their parameters, the equations given +in the FOCUS and NAFTA guidance documents are used.

+

For kinetic models with more than one observed variable, a symbolic solution +of the system of differential equations is included in the resulting +mkinmod object in some cases, speeding up the solution.

+

If a C compiler is found by pkgbuild::has_compiler() and there +is more than one observed variable in the specification, C code is generated +for evaluating the differential equations, compiled using +inline::cfunction() and added to the resulting mkinmod object.

+
+
+

Note

+

The IORE submodel is not well tested for metabolites. When using this +model for metabolites, you may want to read the note in the help +page to mkinfit.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

NAFTA Technical Working Group on Pesticides (not dated) Guidance for +Evaluating and Calculating Degradation Kinetics in Environmental Media

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...)
+SFO <- mkinmod(parent = mkinsub("SFO"))
+
+# One parent compound, one metabolite, both single first order
+SFO_SFO <- mkinmod(
+  parent = mkinsub("SFO", "m1"),
+  m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+print(SFO_SFO)
+#> <mkinmod> model generated with
+#> Use of formation fractions $use_of_ff: max 
+#> Specification $spec:
+#> $parent
+#> $type: SFO; $to: m1; $sink: TRUE
+#> $m1
+#> $type: SFO; $sink: TRUE
+#> Coefficient matrix $coefmat available
+#> Compiled model $cf available
+#> Differential equations:
+#> d_parent/dt = - k_parent * parent
+#> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1
+
+# \dontrun{
+ fit_sfo_sfo <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, solution_type = "deSolve")
+#> Warning: Observations with value of zero were removed from the data
+
+ # Now supplying compound names used for plotting, and write to user defined location
+ # We need to choose a path outside the session tempdir because this gets removed
+ DLL_dir <- "~/.local/share/mkin"
+ if (!dir.exists(DLL_dir)) dir.create(DLL_dir)
+ SFO_SFO.2 <- mkinmod(
+   parent = mkinsub("SFO", "m1", full_name = "Test compound"),
+   m1 = mkinsub("SFO", full_name = "Metabolite M1"),
+   name = "SFO_SFO", dll_dir = DLL_dir, unload = TRUE, overwrite = TRUE)
+#> Temporary DLL for differentials generated and loaded
+#> Copied DLL from /tmp/RtmpSeNGYy/file226312370605e2.so to /home/jranke/.local/share/mkin/SFO_SFO.so
+# Now we can save the model and restore it in a new session
+saveRDS(SFO_SFO.2, file = "~/SFO_SFO.rds")
+# Terminate the R session here if you would like to check, and then do
+library(mkin)
+SFO_SFO.3 <- readRDS("~/SFO_SFO.rds")
+fit_sfo_sfo <- mkinfit(SFO_SFO.3, FOCUS_2006_D, quiet = TRUE, solution_type = "deSolve")
+#> Warning: Observations with value of zero were removed from the data
+
+# Show details of creating the C function
+SFO_SFO <- mkinmod(
+  parent = mkinsub("SFO", "m1"),
+  m1 = mkinsub("SFO"), verbose = TRUE)
+#> Program source:
+#>   1: #include <R.h>
+#>   2: 
+#>   3: 
+#>   4: static double parms [3];
+#>   5: #define k_parent parms[0]
+#>   6: #define f_parent_to_m1 parms[1]
+#>   7: #define k_m1 parms[2]
+#>   8: 
+#>   9: void initpar(void (* odeparms)(int *, double *)) {
+#>  10:     int N = 3;
+#>  11:     odeparms(&N, parms);
+#>  12: }
+#>  13: 
+#>  14: 
+#>  15: void diffs ( int * n, double * t, double * y, double * f, double * rpar, int * ipar ) {
+#>  16: 
+#>  17: f[0] = - k_parent * y[0];
+#>  18: f[1] = + f_parent_to_m1 * k_parent * y[0] - k_m1 * y[1];
+#>  19: }
+#> Temporary DLL for differentials generated and loaded
+
+# The symbolic solution which is available in this case is not
+# made for human reading but for speed of computation
+SFO_SFO$deg_func
+#> function (observed, odeini, odeparms) 
+#> {
+#>     predicted <- numeric(0)
+#>     with(as.list(odeparms), {
+#>         t <- observed[observed$name == "parent", "time"]
+#>         predicted <<- c(predicted, SFO.solution(t, odeini["parent"], 
+#>             k_parent))
+#>         t <- observed[observed$name == "m1", "time"]
+#>         predicted <<- c(predicted, (((k_m1 - k_parent) * odeini["m1"] - 
+#>             f_parent_to_m1 * k_parent * odeini["parent"]) * exp(-k_m1 * 
+#>             t) + f_parent_to_m1 * k_parent * odeini["parent"] * 
+#>             exp(-k_parent * t))/(k_m1 - k_parent))
+#>     })
+#>     return(predicted)
+#> }
+#> <environment: 0x5555577ec6d0>
+
+# If we have several parallel metabolites
+# (compare tests/testthat/test_synthetic_data_for_UBA_2014.R)
+m_synth_DFOP_par <- mkinmod(
+ parent = mkinsub("DFOP", c("M1", "M2")),
+ M1 = mkinsub("SFO"),
+ M2 = mkinsub("SFO"),
+ quiet = TRUE)
+
+fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par,
+  synthetic_data_for_UBA_2014[[12]]$data,
+  quiet = TRUE)
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinparplot-1.png b/docs/dev/reference/mkinparplot-1.png new file mode 100644 index 00000000..8d34b451 Binary files /dev/null and b/docs/dev/reference/mkinparplot-1.png differ diff --git a/docs/dev/reference/mkinparplot.html b/docs/dev/reference/mkinparplot.html new file mode 100644 index 00000000..e3f85961 --- /dev/null +++ b/docs/dev/reference/mkinparplot.html @@ -0,0 +1,128 @@ + +Function to plot the confidence intervals obtained using mkinfit — mkinparplot • mkin + Skip to contents + + +
+
+
+ +
+

This function plots the confidence intervals for the parameters fitted using +mkinfit.

+
+ +
+

Usage

+
mkinparplot(object)
+
+ +
+

Arguments

+ + +
object
+

A fit represented in an mkinfit object.

+ +
+
+

Value

+

Nothing is returned by this function, as it is called for its side +effect, namely to produce a plot.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# \dontrun{
+model <- mkinmod(
+  T245 = mkinsub("SFO", to = c("phenol"), sink = FALSE),
+  phenol = mkinsub("SFO", to = c("anisole")),
+  anisole = mkinsub("SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+fit <- mkinfit(model, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+mkinparplot(fit)
+
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinplot.html b/docs/dev/reference/mkinplot.html new file mode 100644 index 00000000..2505b060 --- /dev/null +++ b/docs/dev/reference/mkinplot.html @@ -0,0 +1,115 @@ + +Plot the observed data and the fitted model of an mkinfit object — mkinplot • mkin + Skip to contents + + +
+
+
+ +
+

Deprecated function. It now only calls the plot method +plot.mkinfit.

+
+ +
+

Usage

+
mkinplot(fit, ...)
+
+ +
+

Arguments

+ + +
fit
+

an object of class mkinfit.

+ + +
...
+

further arguments passed to plot.mkinfit.

+ +
+
+

Value

+

The function is called for its side effect.

+
+
+

Author

+

Johannes Ranke

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinpredict.html b/docs/dev/reference/mkinpredict.html new file mode 100644 index 00000000..e11dacdf --- /dev/null +++ b/docs/dev/reference/mkinpredict.html @@ -0,0 +1,390 @@ + +Produce predictions from a kinetic model using specific parameters — mkinpredict • mkin + Skip to contents + + +
+
+
+ +
+

This function produces a time series for all the observed variables in a +kinetic model as specified by mkinmod, using a specific set of +kinetic parameters and initial values for the state variables.

+
+ +
+

Usage

+
mkinpredict(x, odeparms, odeini, outtimes, ...)
+
+# S3 method for class 'mkinmod'
+mkinpredict(
+  x,
+  odeparms = c(k_parent_sink = 0.1),
+  odeini = c(parent = 100),
+  outtimes = seq(0, 120, by = 0.1),
+  solution_type = "deSolve",
+  use_compiled = "auto",
+  use_symbols = FALSE,
+  method.ode = "lsoda",
+  atol = 1e-08,
+  rtol = 1e-10,
+  maxsteps = 20000L,
+  map_output = TRUE,
+  na_stop = TRUE,
+  ...
+)
+
+# S3 method for class 'mkinfit'
+mkinpredict(
+  x,
+  odeparms = x$bparms.ode,
+  odeini = x$bparms.state,
+  outtimes = seq(0, 120, by = 0.1),
+  solution_type = "deSolve",
+  use_compiled = "auto",
+  method.ode = "lsoda",
+  atol = 1e-08,
+  rtol = 1e-10,
+  map_output = TRUE,
+  ...
+)
+
+ +
+

Arguments

+ + +
x
+

A kinetic model as produced by mkinmod, or a kinetic fit as +fitted by mkinfit. In the latter case, the fitted parameters are used for +the prediction.

+ + +
odeparms
+

A numeric vector specifying the parameters used in the +kinetic model, which is generally defined as a set of ordinary differential +equations.

+ + +
odeini
+

A numeric vector containing the initial values of the state +variables of the model. Note that the state variables can differ from the +observed variables, for example in the case of the SFORB model.

+ + +
outtimes
+

A numeric vector specifying the time points for which model +predictions should be generated.

+ + +
...
+

Further arguments passed to the ode solver in case such a +solver is used.

+ + +
solution_type
+

The method that should be used for producing the +predictions. This should generally be "analytical" if there is only one +observed variable, and usually "deSolve" in the case of several observed +variables. The third possibility "eigen" is fast in comparison to uncompiled +ODE models, but not applicable to some models, e.g. using FOMC for the +parent compound.

+ + +
use_compiled
+

If set to FALSE, no compiled version of the +mkinmod model is used, even if is present.

+ + +
use_symbols
+

If set to TRUE (default), symbol info present in +the mkinmod object is used if available for accessing compiled code

+ + +
method.ode
+

The solution method passed via mkinpredict to deSolve::ode() in +case the solution type is "deSolve" and we are not using compiled code. +When using compiled code, only lsoda is supported.

+ + +
atol
+

Absolute error tolerance, passed to the ode solver.

+ + +
rtol
+

Absolute error tolerance, passed to the ode solver.

+ + +
maxsteps
+

Maximum number of steps, passed to the ode solver.

+ + +
map_output
+

Boolean to specify if the output should list values for +the observed variables (default) or for all state variables (if set to +FALSE). Setting this to FALSE has no effect for analytical solutions, +as these always return mapped output.

+ + +
na_stop
+

Should it be an error if deSolve::ode() returns NaN values

+ +
+
+

Value

+

A matrix with the numeric solution in wide format

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+SFO <- mkinmod(degradinol = mkinsub("SFO"))
+# Compare solution types
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      solution_type = "analytical")
+#>    time  degradinol
+#> 0     0 100.0000000
+#> 1     1  74.0818221
+#> 2     2  54.8811636
+#> 3     3  40.6569660
+#> 4     4  30.1194212
+#> 5     5  22.3130160
+#> 6     6  16.5298888
+#> 7     7  12.2456428
+#> 8     8   9.0717953
+#> 9     9   6.7205513
+#> 10   10   4.9787068
+#> 11   11   3.6883167
+#> 12   12   2.7323722
+#> 13   13   2.0241911
+#> 14   14   1.4995577
+#> 15   15   1.1108997
+#> 16   16   0.8229747
+#> 17   17   0.6096747
+#> 18   18   0.4516581
+#> 19   19   0.3345965
+#> 20   20   0.2478752
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      solution_type = "deSolve")
+#>    time  degradinol
+#> 0     0 100.0000000
+#> 1     1  74.0818221
+#> 2     2  54.8811636
+#> 3     3  40.6569660
+#> 4     4  30.1194212
+#> 5     5  22.3130160
+#> 6     6  16.5298888
+#> 7     7  12.2456428
+#> 8     8   9.0717953
+#> 9     9   6.7205513
+#> 10   10   4.9787068
+#> 11   11   3.6883167
+#> 12   12   2.7323722
+#> 13   13   2.0241911
+#> 14   14   1.4995577
+#> 15   15   1.1108996
+#> 16   16   0.8229747
+#> 17   17   0.6096747
+#> 18   18   0.4516581
+#> 19   19   0.3345965
+#> 20   20   0.2478752
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      solution_type = "deSolve", use_compiled = FALSE)
+#>    time  degradinol
+#> 0     0 100.0000000
+#> 1     1  74.0818221
+#> 2     2  54.8811636
+#> 3     3  40.6569660
+#> 4     4  30.1194212
+#> 5     5  22.3130160
+#> 6     6  16.5298888
+#> 7     7  12.2456428
+#> 8     8   9.0717953
+#> 9     9   6.7205513
+#> 10   10   4.9787068
+#> 11   11   3.6883167
+#> 12   12   2.7323722
+#> 13   13   2.0241911
+#> 14   14   1.4995577
+#> 15   15   1.1108996
+#> 16   16   0.8229747
+#> 17   17   0.6096747
+#> 18   18   0.4516581
+#> 19   19   0.3345965
+#> 20   20   0.2478752
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      solution_type = "eigen")
+#>    time  degradinol
+#> 0     0 100.0000000
+#> 1     1  74.0818221
+#> 2     2  54.8811636
+#> 3     3  40.6569660
+#> 4     4  30.1194212
+#> 5     5  22.3130160
+#> 6     6  16.5298888
+#> 7     7  12.2456428
+#> 8     8   9.0717953
+#> 9     9   6.7205513
+#> 10   10   4.9787068
+#> 11   11   3.6883167
+#> 12   12   2.7323722
+#> 13   13   2.0241911
+#> 14   14   1.4995577
+#> 15   15   1.1108997
+#> 16   16   0.8229747
+#> 17   17   0.6096747
+#> 18   18   0.4516581
+#> 19   19   0.3345965
+#> 20   20   0.2478752
+
+# Compare integration methods to analytical solution
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      solution_type = "analytical")[21,]
+#>       time degradinol 
+#> 20.0000000  0.2478752 
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      method = "lsoda", use_compiled = FALSE)[21,]
+#>       time degradinol 
+#> 20.0000000  0.2478752 
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      method = "ode45", use_compiled = FALSE)[21,]
+#>       time degradinol 
+#> 20.0000000  0.2478752 
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20,
+      method = "rk4", use_compiled = FALSE)[21,]
+#>       time degradinol 
+#> 20.0000000  0.2480043 
+# rk4 is not as precise here
+
+# The number of output times used to make a lot of difference until the
+# default for atol was adjusted
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100),
+      seq(0, 20, by = 0.1))[201,]
+#>       time degradinol 
+#> 20.0000000  0.2478752 
+mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100),
+      seq(0, 20, by = 0.01))[2001,]
+#>       time degradinol 
+#> 20.0000000  0.2478752 
+
+# Comparison of the performance of solution types
+SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"),
+                  m1 = list(type = "SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+if(require(rbenchmark)) {
+  benchmark(replications = 10, order = "relative", columns = c("test", "relative", "elapsed"),
+    eigen = mkinpredict(SFO_SFO,
+      c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01),
+      c(parent = 100, m1 = 0), seq(0, 20, by = 0.1),
+      solution_type = "eigen")[201,],
+    deSolve_compiled = mkinpredict(SFO_SFO,
+      c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01),
+      c(parent = 100, m1 = 0), seq(0, 20, by = 0.1),
+      solution_type = "deSolve")[201,],
+    deSolve = mkinpredict(SFO_SFO,
+      c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01),
+      c(parent = 100, m1 = 0), seq(0, 20, by = 0.1),
+      solution_type = "deSolve", use_compiled = FALSE)[201,],
+    analytical = mkinpredict(SFO_SFO,
+      c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01),
+      c(parent = 100, m1 = 0), seq(0, 20, by = 0.1),
+      solution_type = "analytical", use_compiled = FALSE)[201,])
+}
+#>               test relative elapsed
+#> 2 deSolve_compiled      1.0   0.002
+#> 4       analytical      1.0   0.002
+#> 1            eigen      4.0   0.008
+#> 3          deSolve     30.5   0.061
+
+# \dontrun{
+  # Predict from a fitted model
+  f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE)
+  f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE, solution_type = "deSolve")
+  head(mkinpredict(f))
+#> Error in !is.null(x$symbols) & use_symbols: operations are possible only for numeric, logical or complex types
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinpredict.mkinfit.html b/docs/dev/reference/mkinpredict.mkinfit.html new file mode 100644 index 00000000..5f03c04c --- /dev/null +++ b/docs/dev/reference/mkinpredict.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mkinpredict.mkinmod.html b/docs/dev/reference/mkinpredict.mkinmod.html new file mode 100644 index 00000000..5f03c04c --- /dev/null +++ b/docs/dev/reference/mkinpredict.mkinmod.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mkinresplot-1.png b/docs/dev/reference/mkinresplot-1.png new file mode 100644 index 00000000..29da1fda Binary files /dev/null and b/docs/dev/reference/mkinresplot-1.png differ diff --git a/docs/dev/reference/mkinresplot.html b/docs/dev/reference/mkinresplot.html new file mode 100644 index 00000000..b9de393d --- /dev/null +++ b/docs/dev/reference/mkinresplot.html @@ -0,0 +1,203 @@ + +Function to plot residuals stored in an mkin object — mkinresplot • mkin + Skip to contents + + +
+
+
+ +
+

This function plots the residuals for the specified subset of the observed +variables from an mkinfit object. A combined plot of the fitted model and +the residuals can be obtained using plot.mkinfit using the +argument show_residuals = TRUE.

+
+ +
+

Usage

+
mkinresplot(
+  object,
+  obs_vars = names(object$mkinmod$map),
+  xlim = c(0, 1.1 * max(object$data$time)),
+  standardized = FALSE,
+  xlab = "Time",
+  ylab = ifelse(standardized, "Standardized residual", "Residual"),
+  maxabs = "auto",
+  legend = TRUE,
+  lpos = "topright",
+  col_obs = "auto",
+  pch_obs = "auto",
+  frame = TRUE,
+  ...
+)
+
+ +
+

Arguments

+ + +
object
+

A fit represented in an mkinfit object.

+ + +
obs_vars
+

A character vector of names of the observed variables for +which residuals should be plotted. Defaults to all observed variables in +the model

+ + +
xlim
+

plot range in x direction.

+ + +
standardized
+

Should the residuals be standardized by dividing by the +standard deviation given by the error model of the fit?

+ + +
xlab
+

Label for the x axis.

+ + +
ylab
+

Label for the y axis.

+ + +
maxabs
+

Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".

+ + +
legend
+

Should a legend be plotted?

+ + +
lpos
+

Where should the legend be placed? Default is "topright". Will +be passed on to legend.

+ + +
col_obs
+

Colors for the observed variables.

+ + +
pch_obs
+

Symbols to be used for the observed variables.

+ + +
frame
+

Should a frame be drawn around the plots?

+ + +
...
+

further arguments passed to plot.

+ +
+
+

Value

+

Nothing is returned by this function, as it is called for its side +effect, namely to produce a plot.

+
+
+

See also

+

mkinplot, for a way to plot the data and the fitted +lines of the mkinfit object, and plot_res for a function +combining the plot of the fit and the residual plot.

+
+
+

Author

+

Johannes Ranke and Katrin Lindenberger

+
+ +
+

Examples

+

+model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+fit <- mkinfit(model, FOCUS_2006_D, quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+mkinresplot(fit, "m1")
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/mkinsub.html b/docs/dev/reference/mkinsub.html new file mode 100644 index 00000000..0ffb4f23 --- /dev/null +++ b/docs/dev/reference/mkinsub.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/mmkin-1.png b/docs/dev/reference/mmkin-1.png new file mode 100644 index 00000000..060775ff Binary files /dev/null and b/docs/dev/reference/mmkin-1.png differ diff --git a/docs/dev/reference/mmkin-2.png b/docs/dev/reference/mmkin-2.png new file mode 100644 index 00000000..242a50fa Binary files /dev/null and b/docs/dev/reference/mmkin-2.png differ diff --git a/docs/dev/reference/mmkin-3.png b/docs/dev/reference/mmkin-3.png new file mode 100644 index 00000000..ef013dea Binary files /dev/null and b/docs/dev/reference/mmkin-3.png differ diff --git a/docs/dev/reference/mmkin-4.png b/docs/dev/reference/mmkin-4.png new file mode 100644 index 00000000..c08d231d Binary files /dev/null and b/docs/dev/reference/mmkin-4.png differ diff --git a/docs/dev/reference/mmkin-5.png b/docs/dev/reference/mmkin-5.png new file mode 100644 index 00000000..fe5797b4 Binary files /dev/null and b/docs/dev/reference/mmkin-5.png differ diff --git a/docs/dev/reference/mmkin.html b/docs/dev/reference/mmkin.html new file mode 100644 index 00000000..c2bbd3c4 --- /dev/null +++ b/docs/dev/reference/mmkin.html @@ -0,0 +1,239 @@ + +Fit one or more kinetic models with one or more state variables to one or more datasets — mmkin • mkin + Skip to contents + + +
+
+
+ +
+

This function calls mkinfit on all combinations of models and +datasets specified in its first two arguments.

+
+ +
+

Usage

+
mmkin(
+  models = c("SFO", "FOMC", "DFOP"),
+  datasets,
+  cores = if (Sys.info()["sysname"] == "Windows") 1 else parallel::detectCores(),
+  cluster = NULL,
+  ...
+)
+
+# S3 method for class 'mmkin'
+print(x, ...)
+
+ +
+

Arguments

+ + +
models
+

Either a character vector of shorthand names like +c("SFO", "FOMC", "DFOP", "HS", "SFORB"), or an optionally named +list of mkinmod objects.

+ + +
datasets
+

An optionally named list of datasets suitable as observed +data for mkinfit.

+ + +
cores
+

The number of cores to be used for multicore processing. This +is only used when the cluster argument is NULL. On Windows +machines, cores > 1 is not supported, you need to use the cluster +argument to use multiple logical processors. Per default, all cores +detected by parallel::detectCores() are used, except on Windows where +the default is 1.

+ + +
cluster
+

A cluster as returned by makeCluster to be used +for parallel execution.

+ + +
...
+

Not used.

+ + +
x
+

An mmkin object.

+ +
+
+

Value

+

A two-dimensional array of mkinfit +objects and/or try-errors that can be indexed using the model names for the +first index (row index) and the dataset names for the second index (column +index).

+
+
+

See also

+

[.mmkin for subsetting, plot.mmkin for +plotting.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# \dontrun{
+m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
+                           M1 = mkinsub("SFO", "M2"),
+                           M2 = mkinsub("SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+m_synth_FOMC_lin <- mkinmod(parent = mkinsub("FOMC", "M1"),
+                            M1 = mkinsub("SFO", "M2"),
+                            M2 = mkinsub("SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+models <- list(SFO_lin = m_synth_SFO_lin, FOMC_lin = m_synth_FOMC_lin)
+datasets <- lapply(synthetic_data_for_UBA_2014[1:3], function(x) x$data)
+names(datasets) <- paste("Dataset", 1:3)
+
+time_default <- system.time(fits.0 <- mmkin(models, datasets, quiet = TRUE))
+time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE))
+
+time_default
+#>    user  system elapsed 
+#>   1.522   0.957   0.720 
+time_1
+#>    user  system elapsed 
+#>   1.991   0.024   2.015 
+
+endpoints(fits.0[["SFO_lin", 2]])
+#> $ff
+#>   parent_M1 parent_sink       M1_M2     M1_sink 
+#>   0.7340481   0.2659519   0.7505690   0.2494310 
+#> 
+#> $distimes
+#>              DT50       DT90
+#> parent  0.8777689   2.915885
+#> M1      2.3257403   7.725942
+#> M2     33.7201060 112.015767
+#> 
+
+# plot.mkinfit handles rows or columns of mmkin result objects
+plot(fits.0[1, ])
+
+plot(fits.0[1, ], obs_var = c("M1", "M2"))
+
+plot(fits.0[, 1])
+
+# Use double brackets to extract a single mkinfit object, which will be plotted
+# by plot.mkinfit and can be plotted using plot_sep
+plot(fits.0[[1, 1]], sep_obs = TRUE, show_residuals = TRUE, show_errmin = TRUE)
+
+plot_sep(fits.0[[1, 1]])
+# Plotting with mmkin (single brackets, extracting an mmkin object) does not
+# allow to plot the observed variables separately
+plot(fits.0[1, 1])
+
+
+# On Windows, we can use multiple cores by making a cluster first
+cl <- parallel::makePSOCKcluster(12)
+f <- mmkin(c("SFO", "FOMC", "DFOP"),
+  list(A = FOCUS_2006_A, B = FOCUS_2006_B, C = FOCUS_2006_C, D = FOCUS_2006_D),
+  cluster = cl, quiet = TRUE)
+print(f)
+#> <mmkin> object
+#> Status of individual fits:
+#> 
+#>       dataset
+#> model  A  B  C  D 
+#>   SFO  OK OK OK OK
+#>   FOMC C  OK OK OK
+#>   DFOP OK OK OK OK
+#> 
+#> C: Optimisation did not converge:
+#> false convergence (8)
+#> OK: No warnings
+# We get false convergence for the FOMC fit to FOCUS_2006_A because this
+# dataset is really SFO, and the FOMC fit is overparameterised
+parallel::stopCluster(cl)
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/multistart-1.png b/docs/dev/reference/multistart-1.png new file mode 100644 index 00000000..d326b0c4 Binary files /dev/null and b/docs/dev/reference/multistart-1.png differ diff --git a/docs/dev/reference/multistart-2.png b/docs/dev/reference/multistart-2.png new file mode 100644 index 00000000..b6ae3051 Binary files /dev/null and b/docs/dev/reference/multistart-2.png differ diff --git a/docs/dev/reference/multistart.html b/docs/dev/reference/multistart.html new file mode 100644 index 00000000..3db38d97 --- /dev/null +++ b/docs/dev/reference/multistart.html @@ -0,0 +1,212 @@ + +Perform a hierarchical model fit with multiple starting values — multistart • mkin + Skip to contents + + +
+
+
+ +
+

The purpose of this method is to check if a certain algorithm for fitting +nonlinear hierarchical models (also known as nonlinear mixed-effects models) +will reliably yield results that are sufficiently similar to each other, if +started with a certain range of reasonable starting parameters. It is +inspired by the article on practical identifiabiliy in the frame of nonlinear +mixed-effects models by Duchesne et al (2021).

+
+ +
+

Usage

+
multistart(
+  object,
+  n = 50,
+  cores = if (Sys.info()["sysname"] == "Windows") 1 else parallel::detectCores(),
+  cluster = NULL,
+  ...
+)
+
+# S3 method for class 'saem.mmkin'
+multistart(object, n = 50, cores = 1, cluster = NULL, ...)
+
+# S3 method for class 'multistart'
+print(x, ...)
+
+best(object, ...)
+
+# Default S3 method
+best(object, ...)
+
+which.best(object, ...)
+
+# Default S3 method
+which.best(object, ...)
+
+ +
+

Arguments

+ + +
object
+

The fit object to work with

+ + +
n
+

How many different combinations of starting parameters should be +used?

+ + +
cores
+

How many fits should be run in parallel (only on posix platforms)?

+ + +
cluster
+

A cluster as returned by parallel::makeCluster to be used +for parallel execution.

+ + +
...
+

Passed to the update function.

+ + +
x
+

The multistart object to print

+ +
+
+

Value

+

A list of saem.mmkin objects, with class attributes +'multistart.saem.mmkin' and 'multistart'.

+

The object with the highest likelihood

+

The index of the object with the highest likelihood

+
+
+

References

+

Duchesne R, Guillemin A, Gandrillon O, Crauste F. Practical +identifiability in the frame of nonlinear mixed effects models: the example +of the in vitro erythropoiesis. BMC Bioinformatics. 2021 Oct 4;22(1):478. +doi: 10.1186/s12859-021-04373-4.

+
+
+

See also

+ +
+ +
+

Examples

+
# \dontrun{
+library(mkin)
+dmta_ds <- lapply(1:7, function(i) {
+  ds_i <- dimethenamid_2018$ds[[i]]$data
+  ds_i[ds_i$name == "DMTAP", "name"] <-  "DMTA"
+  ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
+  ds_i
+})
+names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
+dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
+dmta_ds[["Elliot 1"]] <- dmta_ds[["Elliot 2"]] <- NULL
+
+f_mmkin <- mmkin("DFOP", dmta_ds, error_model = "tc", cores = 7, quiet = TRUE)
+f_saem_full <- saem(f_mmkin)
+f_saem_full_multi <- multistart(f_saem_full, n = 16, cores = 16)
+parplot(f_saem_full_multi, lpos = "topleft", las = 2)
+
+illparms(f_saem_full)
+#> [1] "sd(log_k2)"
+
+f_saem_reduced <- update(f_saem_full, no_random_effect = "log_k2")
+illparms(f_saem_reduced)
+# On Windows, we need to create a PSOCK cluster first and refer to it
+# in the call to multistart()
+library(parallel)
+cl <- makePSOCKcluster(12)
+f_saem_reduced_multi <- multistart(f_saem_reduced, n = 16, cluster = cl)
+parplot(f_saem_reduced_multi, lpos = "topright", ylim = c(0.5, 2), las = 2)
+
+stopCluster(cl)
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/multistart.saem.mmkin.html b/docs/dev/reference/multistart.saem.mmkin.html new file mode 100644 index 00000000..06f15f0c --- /dev/null +++ b/docs/dev/reference/multistart.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/nafta-1.png b/docs/dev/reference/nafta-1.png new file mode 100644 index 00000000..98d4246c Binary files /dev/null and b/docs/dev/reference/nafta-1.png differ diff --git a/docs/dev/reference/nafta.html b/docs/dev/reference/nafta.html new file mode 100644 index 00000000..f7b018e5 --- /dev/null +++ b/docs/dev/reference/nafta.html @@ -0,0 +1,215 @@ + +Evaluate parent kinetics using the NAFTA guidance — nafta • mkin + Skip to contents + + +
+
+
+ +
+

The function fits the SFO, IORE and DFOP models using mmkin +and returns an object of class nafta that has methods for printing +and plotting.

+

Print nafta objects. The results for the three models are printed in the +order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP.

+
+ +
+

Usage

+
nafta(ds, title = NA, quiet = FALSE, ...)
+
+# S3 method for class 'nafta'
+print(x, quiet = TRUE, digits = 3, ...)
+
+ +
+

Source

+

NAFTA (2011) Guidance for evaluating and calculating degradation +kinetics in environmental media. NAFTA Technical Working Group on +Pesticides +https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation +accessed 2019-02-22

+

US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to +Calculate Representative Half-life Values and Characterizing Pesticide +Degradation +https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance

+
+
+

Arguments

+ + +
ds
+

A dataframe that must contain one variable called "time" with the +time values specified by the time argument, one column called +"name" with the grouping of the observed values, and finally one column of +observed values called "value".

+ + +
title
+

Optional title of the dataset

+ + +
quiet
+

Should the evaluation text be shown?

+ + +
...
+

Further arguments passed to mmkin (not for the +printing method).

+ + +
x
+

An nafta object.

+ + +
digits
+

Number of digits to be used for printing parameters and +dissipation times.

+ +
+
+

Value

+

An list of class nafta. The list element named "mmkin" is the +mmkin object containing the fits of the three models. The +list element named "title" contains the title of the dataset used. The +list element "data" contains the dataset used in the fits.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1)
+#> The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
+#> The representative half-life of the IORE model is longer than the one corresponding
+#> to the terminal degradation rate found with the DFOP model.
+#> The representative half-life obtained from the DFOP model may be used
+  print(nafta_evaluation)
+#> Sums of squares:
+#>       SFO      IORE      DFOP 
+#> 1378.6832  615.7730  517.8836 
+#> 
+#> Critical sum of squares for checking the SFO model:
+#> [1] 717.4598
+#> 
+#> Parameters:
+#> $SFO
+#>          Estimate   Pr(>t)    Lower   Upper
+#> parent_0  83.7558 1.80e-14 77.18268 90.3288
+#> k_parent   0.0017 7.43e-05  0.00112  0.0026
+#> sigma      8.7518 1.22e-05  5.64278 11.8608
+#> 
+#> $IORE
+#>                Estimate Pr(>t)    Lower    Upper
+#> parent_0       9.69e+01     NA 8.88e+01 1.05e+02
+#> k__iore_parent 8.40e-14     NA 1.79e-18 3.94e-09
+#> N_parent       6.68e+00     NA 4.19e+00 9.17e+00
+#> sigma          5.85e+00     NA 3.76e+00 7.94e+00
+#> 
+#> $DFOP
+#>          Estimate   Pr(>t)    Lower    Upper
+#> parent_0 9.76e+01 1.94e-13 9.02e+01 1.05e+02
+#> k1       4.24e-02 5.92e-03 2.03e-02 8.88e-02
+#> k2       8.24e-04 6.48e-03 3.89e-04 1.75e-03
+#> g        2.88e-01 2.47e-05 1.95e-01 4.03e-01
+#> sigma    5.36e+00 2.22e-05 3.43e+00 7.30e+00
+#> 
+#> 
+#> DTx values:
+#>      DT50    DT90 DT50_rep
+#> SFO   407    1350      407
+#> IORE  541 5190000  1560000
+#> DFOP  429    2380      841
+#> 
+#> Representative half-life:
+#> [1] 841.41
+  plot(nafta_evaluation)
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/nlme-1.png b/docs/dev/reference/nlme-1.png new file mode 100644 index 00000000..9583da2a Binary files /dev/null and b/docs/dev/reference/nlme-1.png differ diff --git a/docs/dev/reference/nlme-2.png b/docs/dev/reference/nlme-2.png new file mode 100644 index 00000000..08e3b642 Binary files /dev/null and b/docs/dev/reference/nlme-2.png differ diff --git a/docs/dev/reference/nlme.html b/docs/dev/reference/nlme.html new file mode 100644 index 00000000..e3c13f48 --- /dev/null +++ b/docs/dev/reference/nlme.html @@ -0,0 +1,197 @@ + +Helper functions to create nlme models from mmkin row objects — nlme_function • mkin + Skip to contents + + +
+
+
+ +
+

These functions facilitate setting up a nonlinear mixed effects model for +an mmkin row object. An mmkin row object is essentially a list of mkinfit +objects that have been obtained by fitting the same model to a list of +datasets. They are used internally by the nlme.mmkin() method.

+
+ +
+

Usage

+
nlme_function(object)
+
+nlme_data(object)
+
+ +
+

Arguments

+ + +
object
+

An mmkin row object containing several fits of the same model to different datasets

+ +
+
+

Value

+

A function that can be used with nlme

+

A nlme::groupedData object

+
+
+

See also

+ +
+ +
+

Examples

+
sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+m_SFO <- mkinmod(parent = mkinsub("SFO"))
+d_SFO_1 <- mkinpredict(m_SFO,
+  c(k_parent = 0.1),
+  c(parent = 98), sampling_times)
+d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time")
+d_SFO_2 <- mkinpredict(m_SFO,
+  c(k_parent = 0.05),
+  c(parent = 102), sampling_times)
+d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time")
+d_SFO_3 <- mkinpredict(m_SFO,
+  c(k_parent = 0.02),
+  c(parent = 103), sampling_times)
+d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time")
+
+d1 <- add_err(d_SFO_1, function(value) 3, n = 1)
+d2 <- add_err(d_SFO_2, function(value) 2, n = 1)
+d3 <- add_err(d_SFO_3, function(value) 4, n = 1)
+ds <- c(d1 = d1, d2 = d2, d3 = d3)
+
+f <- mmkin("SFO", ds, cores = 1, quiet = TRUE)
+mean_dp <- mean_degparms(f)
+grouped_data <- nlme_data(f)
+nlme_f <- nlme_function(f)
+# These assignments are necessary for these objects to be
+# visible to nlme and augPred when evaluation is done by
+# pkgdown to generate the html docs.
+assign("nlme_f", nlme_f, globalenv())
+assign("grouped_data", grouped_data, globalenv())
+
+library(nlme)
+m_nlme <- nlme(value ~ nlme_f(name, time, parent_0, log_k_parent_sink),
+  data = grouped_data,
+  fixed = parent_0 + log_k_parent_sink ~ 1,
+  random = pdDiag(parent_0 + log_k_parent_sink ~ 1),
+  start = mean_dp)
+summary(m_nlme)
+#> Nonlinear mixed-effects model fit by maximum likelihood
+#>   Model: value ~ nlme_f(name, time, parent_0, log_k_parent_sink) 
+#>   Data: grouped_data 
+#>        AIC      BIC    logLik
+#>   266.6428 275.8935 -128.3214
+#> 
+#> Random effects:
+#>  Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1)
+#>  Level: ds
+#>  Structure: Diagonal
+#>             parent_0 log_k_parent_sink Residual
+#> StdDev: 0.0003775775         0.7058039 3.065183
+#> 
+#> Fixed effects:  parent_0 + log_k_parent_sink ~ 1 
+#>                       Value Std.Error DF   t-value p-value
+#> parent_0          101.18323 0.7900461 43 128.07257       0
+#> log_k_parent_sink  -3.08708 0.4171755 43  -7.39995       0
+#>  Correlation: 
+#>                   prnt_0
+#> log_k_parent_sink 0.031 
+#> 
+#> Standardized Within-Group Residuals:
+#>         Min          Q1         Med          Q3         Max 
+#> -2.38427070 -0.52059848  0.03593021  0.39987268  2.73188969 
+#> 
+#> Number of Observations: 47
+#> Number of Groups: 3 
+plot(augPred(m_nlme, level = 0:1), layout = c(3, 1))
+
+# augPred does not work on fits with more than one state
+# variable
+#
+# The procedure is greatly simplified by the nlme.mmkin function
+f_nlme <- nlme(f)
+plot(f_nlme)
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/nlme.mmkin-1.png b/docs/dev/reference/nlme.mmkin-1.png new file mode 100644 index 00000000..a940da0c Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-1.png differ diff --git a/docs/dev/reference/nlme.mmkin-2.png b/docs/dev/reference/nlme.mmkin-2.png new file mode 100644 index 00000000..b12ddb73 Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-2.png differ diff --git a/docs/dev/reference/nlme.mmkin-3.png b/docs/dev/reference/nlme.mmkin-3.png new file mode 100644 index 00000000..629fe7d2 Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-3.png differ diff --git a/docs/dev/reference/nlme.mmkin.html b/docs/dev/reference/nlme.mmkin.html new file mode 100644 index 00000000..40fb16d3 --- /dev/null +++ b/docs/dev/reference/nlme.mmkin.html @@ -0,0 +1,415 @@ + +Create an nlme model for an mmkin row object — nlme.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

This functions sets up a nonlinear mixed effects model for an mmkin row +object. An mmkin row object is essentially a list of mkinfit objects that +have been obtained by fitting the same model to a list of datasets.

+
+ +
+

Usage

+
# S3 method for class 'mmkin'
+nlme(
+  model,
+  data = "auto",
+  fixed = lapply(as.list(names(mean_degparms(model))), function(el) eval(parse(text =
+    paste(el, 1, sep = "~")))),
+  random = pdDiag(fixed),
+  groups,
+  start = mean_degparms(model, random = TRUE, test_log_parms = TRUE),
+  correlation = NULL,
+  weights = NULL,
+  subset,
+  method = c("ML", "REML"),
+  na.action = na.fail,
+  naPattern,
+  control = list(),
+  verbose = FALSE
+)
+
+# S3 method for class 'nlme.mmkin'
+print(x, digits = max(3, getOption("digits") - 3), ...)
+
+# S3 method for class 'nlme.mmkin'
+update(object, ...)
+
+ +
+

Arguments

+ + +
model
+

An mmkin row object.

+ + +
data
+

Ignored, data are taken from the mmkin model

+ + +
fixed
+

Ignored, all degradation parameters fitted in the +mmkin model are used as fixed parameters

+ + +
random
+

If not specified, no correlations between random effects are +set up for the optimised degradation model parameters. This is +achieved by using the nlme::pdDiag method.

+ + +
groups
+

See the documentation of nlme

+ + +
start
+

If not specified, mean values of the fitted degradation +parameters taken from the mmkin object are used

+ + +
correlation
+

See the documentation of nlme

+ + +
weights
+

passed to nlme

+ + +
subset
+

passed to nlme

+ + +
method
+

passed to nlme

+ + +
na.action
+

passed to nlme

+ + +
naPattern
+

passed to nlme

+ + +
control
+

passed to nlme

+ + +
verbose
+

passed to nlme

+ + +
x
+

An nlme.mmkin object to print

+ + +
digits
+

Number of digits to use for printing

+ + +
...
+

Update specifications passed to update.nlme

+ + +
object
+

An nlme.mmkin object to update

+ +
+
+

Value

+

Upon success, a fitted 'nlme.mmkin' object, which is an nlme object +with additional elements. It also inherits from 'mixed.mmkin'.

+
+
+

Details

+

Note that the convergence of the nlme algorithms depends on the quality +of the data. In degradation kinetics, we often only have few datasets +(e.g. data for few soils) and complicated degradation models, which may +make it impossible to obtain convergence with nlme.

+
+
+

Note

+

As the object inherits from nlme::nlme, there is a wealth of +methods that will automatically work on 'nlme.mmkin' objects, such as +nlme::intervals(), nlme::anova.lme() and nlme::coef.lme().

+
+ + +
+

Examples

+
ds <- lapply(experimental_data_for_UBA_2019[6:10],
+ function(x) subset(x$data[c("name", "time", "value")], name == "parent"))
+
+# \dontrun{
+  f <- mmkin(c("SFO", "DFOP"), ds, quiet = TRUE, cores = 1)
+  library(nlme)
+  f_nlme_sfo <- nlme(f["SFO", ])
+  f_nlme_dfop <- nlme(f["DFOP", ])
+  anova(f_nlme_sfo, f_nlme_dfop)
+#>             Model df      AIC      BIC    logLik   Test  L.Ratio p-value
+#> f_nlme_sfo      1  5 625.0539 637.5529 -307.5269                        
+#> f_nlme_dfop     2  9 495.1270 517.6253 -238.5635 1 vs 2 137.9269  <.0001
+  print(f_nlme_dfop)
+#> Kinetic nonlinear mixed-effects model fit by maximum likelihood
+#> 
+#> Structural model:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> 
+#> Data:
+#> 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#> Log-likelihood: -238.6
+#> 
+#> Fixed effects:
+#>  list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1) 
+#> parent_0   log_k1   log_k2 g_qlogis 
+#>  94.1702  -1.8002  -4.1474   0.0324 
+#> 
+#> Random effects:
+#>  Formula: list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1)
+#>  Level: ds
+#>  Structure: Diagonal
+#>         parent_0 log_k1 log_k2 g_qlogis Residual
+#> StdDev:    2.488 0.8447   1.33   0.4652    2.321
+#> 
+  plot(f_nlme_dfop)
+
+  endpoints(f_nlme_dfop)
+#> $distimes
+#>            DT50     DT90 DT50back  DT50_k1  DT50_k2
+#> parent 10.79857 100.7937 30.34192 4.193937 43.85442
+#> 
+
+  ds_2 <- lapply(experimental_data_for_UBA_2019[6:10],
+   function(x) x$data[c("name", "time", "value")])
+  m_sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"),
+    A1 = mkinsub("SFO"), use_of_ff = "min", quiet = TRUE)
+  m_sfo_sfo_ff <- mkinmod(parent = mkinsub("SFO", "A1"),
+    A1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE)
+  m_dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
+    A1 = mkinsub("SFO"), quiet = TRUE)
+
+  f_2 <- mmkin(list("SFO-SFO" = m_sfo_sfo,
+   "SFO-SFO-ff" = m_sfo_sfo_ff,
+   "DFOP-SFO" = m_dfop_sfo),
+    ds_2, quiet = TRUE)
+
+  f_nlme_sfo_sfo <- nlme(f_2["SFO-SFO", ])
+  plot(f_nlme_sfo_sfo)
+
+
+  # With formation fractions this does not coverge with defaults
+  # f_nlme_sfo_sfo_ff <- nlme(f_2["SFO-SFO-ff", ])
+  #plot(f_nlme_sfo_sfo_ff)
+
+  # For the following, we need to increase pnlsMaxIter and the tolerance
+  # to get convergence
+  f_nlme_dfop_sfo <- nlme(f_2["DFOP-SFO", ],
+    control = list(pnlsMaxIter = 120, tolerance = 5e-4))
+
+  plot(f_nlme_dfop_sfo)
+
+
+  anova(f_nlme_dfop_sfo, f_nlme_sfo_sfo)
+#>                 Model df       AIC      BIC    logLik   Test  L.Ratio p-value
+#> f_nlme_dfop_sfo     1 13  843.8547  884.620 -408.9273                        
+#> f_nlme_sfo_sfo      2  9 1085.1821 1113.404 -533.5910 1 vs 2 249.3274  <.0001
+
+  endpoints(f_nlme_sfo_sfo)
+#> $ff
+#> parent_sink   parent_A1     A1_sink 
+#>   0.5912432   0.4087568   1.0000000 
+#> 
+#> $distimes
+#>            DT50     DT90
+#> parent 19.13518  63.5657
+#> A1     66.02155 219.3189
+#> 
+  endpoints(f_nlme_dfop_sfo)
+#> $ff
+#>   parent_A1 parent_sink 
+#>   0.2768574   0.7231426 
+#> 
+#> $distimes
+#>             DT50     DT90 DT50back  DT50_k1  DT50_k2
+#> parent  11.07091 104.6320 31.49737 4.462383 46.20825
+#> A1     162.30550 539.1672       NA       NA       NA
+#> 
+
+  if (length(findFunction("varConstProp")) > 0) { # tc error model for nlme available
+    # Attempts to fit metabolite kinetics with the tc error model are possible,
+    # but need tweeking of control values and sometimes do not converge
+
+    f_tc <- mmkin(c("SFO", "DFOP"), ds, quiet = TRUE, error_model = "tc")
+    f_nlme_sfo_tc <- nlme(f_tc["SFO", ])
+    f_nlme_dfop_tc <- nlme(f_tc["DFOP", ])
+    AIC(f_nlme_sfo, f_nlme_sfo_tc, f_nlme_dfop, f_nlme_dfop_tc)
+    print(f_nlme_dfop_tc)
+  }
+#> Kinetic nonlinear mixed-effects model fit by maximum likelihood
+#> 
+#> Structural model:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> 
+#> Data:
+#> 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#> Log-likelihood: -238.4
+#> 
+#> Fixed effects:
+#>  list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1) 
+#> parent_0   log_k1   log_k2 g_qlogis 
+#> 94.04774 -1.82340 -4.16716  0.05685 
+#> 
+#> Random effects:
+#>  Formula: list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1)
+#>  Level: ds
+#>  Structure: Diagonal
+#>         parent_0 log_k1 log_k2 g_qlogis Residual
+#> StdDev:    2.474   0.85  1.337   0.4659        1
+#> 
+#> Variance function:
+#>  Structure: Constant plus proportion of variance covariate
+#>  Formula: ~fitted(.) 
+#>  Parameter estimates:
+#>      const       prop 
+#> 2.23222933 0.01262399 
+
+  f_2_obs <- update(f_2, error_model = "obs")
+  f_nlme_sfo_sfo_obs <- nlme(f_2_obs["SFO-SFO", ])
+  print(f_nlme_sfo_sfo_obs)
+#> Kinetic nonlinear mixed-effects model fit by maximum likelihood
+#> 
+#> Structural model:
+#> d_parent/dt = - k_parent_sink * parent - k_parent_A1 * parent
+#> d_A1/dt = + k_parent_A1 * parent - k_A1_sink * A1
+#> 
+#> Data:
+#> 170 observations of 2 variable(s) grouped in 5 datasets
+#> 
+#> Log-likelihood: -473
+#> 
+#> Fixed effects:
+#>  list(parent_0 ~ 1, log_k_parent_sink ~ 1, log_k_parent_A1 ~ 1,      log_k_A1_sink ~ 1) 
+#>          parent_0 log_k_parent_sink   log_k_parent_A1     log_k_A1_sink 
+#>            87.976            -3.670            -4.164            -4.645 
+#> 
+#> Random effects:
+#>  Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1, log_k_parent_A1 ~ 1,      log_k_A1_sink ~ 1)
+#>  Level: ds
+#>  Structure: Diagonal
+#>         parent_0 log_k_parent_sink log_k_parent_A1 log_k_A1_sink Residual
+#> StdDev:    3.992             1.777           1.055        0.4821    6.483
+#> 
+#> Variance function:
+#>  Structure: Different standard deviations per stratum
+#>  Formula: ~1 | name 
+#>  Parameter estimates:
+#>    parent        A1 
+#> 1.0000000 0.2050005 
+  f_nlme_dfop_sfo_obs <- nlme(f_2_obs["DFOP-SFO", ],
+    control = list(pnlsMaxIter = 120, tolerance = 5e-4))
+
+  f_2_tc <- update(f_2, error_model = "tc")
+  # f_nlme_sfo_sfo_tc <- nlme(f_2_tc["SFO-SFO", ]) # No convergence with 50 iterations
+  # f_nlme_dfop_sfo_tc <- nlme(f_2_tc["DFOP-SFO", ],
+  #  control = list(pnlsMaxIter = 120, tolerance = 5e-4)) # Error in X[, fmap[[nm]]] <- gradnm
+
+  anova(f_nlme_dfop_sfo, f_nlme_dfop_sfo_obs)
+#>                     Model df      AIC     BIC    logLik   Test  L.Ratio p-value
+#> f_nlme_dfop_sfo         1 13 843.8547 884.620 -408.9273                        
+#> f_nlme_dfop_sfo_obs     2 14 817.5338 861.435 -394.7669 1 vs 2 28.32084  <.0001
+
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/nlme_data.html b/docs/dev/reference/nlme_data.html new file mode 100644 index 00000000..c1e64a4a --- /dev/null +++ b/docs/dev/reference/nlme_data.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/nobs.mkinfit.html b/docs/dev/reference/nobs.mkinfit.html new file mode 100644 index 00000000..809dafaf --- /dev/null +++ b/docs/dev/reference/nobs.mkinfit.html @@ -0,0 +1,109 @@ + +Number of observations on which an mkinfit object was fitted — nobs.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

Number of observations on which an mkinfit object was fitted

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+nobs(object, ...)
+
+ +
+

Arguments

+ + +
object
+

An mkinfit object

+ + +
...
+

For compatibility with the generic method

+ +
+
+

Value

+

The number of rows in the data included in the mkinfit object

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/parms.html b/docs/dev/reference/parms.html new file mode 100644 index 00000000..71a8737f --- /dev/null +++ b/docs/dev/reference/parms.html @@ -0,0 +1,250 @@ + +Extract model parameters — parms • mkin + Skip to contents + + +
+
+
+ +
+

This function returns degradation model parameters as well as error +model parameters per default, in order to avoid working with a fitted model +without considering the error structure that was assumed for the fit.

+
+ +
+

Usage

+
parms(object, ...)
+
+# S3 method for class 'mkinfit'
+parms(object, transformed = FALSE, errparms = TRUE, ...)
+
+# S3 method for class 'mmkin'
+parms(object, transformed = FALSE, errparms = TRUE, ...)
+
+# S3 method for class 'multistart'
+parms(object, exclude_failed = TRUE, ...)
+
+# S3 method for class 'saem.mmkin'
+parms(object, ci = FALSE, covariates = NULL, ...)
+
+ +
+

Arguments

+ + +
object
+

A fitted model object.

+ + +
...
+

Not used

+ + +
transformed
+

Should the parameters be returned as used internally +during the optimisation?

+ + +
errparms
+

Should the error model parameters be returned +in addition to the degradation parameters?

+ + +
exclude_failed
+

For multistart objects, should rows for failed fits +be removed from the returned parameter matrix?

+ + +
ci
+

Should a matrix with estimates and confidence interval boundaries +be returned? If FALSE (default), a vector of estimates is returned if no +covariates are given, otherwise a matrix of estimates is returned, with +each column corresponding to a row of the data frame holding the covariates

+ + +
covariates
+

A data frame holding covariate values for which to +return parameter values. Only has an effect if 'ci' is FALSE.

+ +
+
+

Value

+

Depending on the object, a numeric vector of fitted model parameters, +a matrix (e.g. for mmkin row objects), or a list of matrices (e.g. for +mmkin objects with more than one row).

+
+
+

See also

+ +
+ +
+

Examples

+
# mkinfit objects
+fit <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE)
+parms(fit)
+#>   parent_0   k_parent      sigma 
+#> 82.4921598  0.3060633  4.6730124 
+parms(fit, transformed = TRUE)
+#>     parent_0 log_k_parent        sigma 
+#>    82.492160    -1.183963     4.673012 
+
+# mmkin objects
+ds <- lapply(experimental_data_for_UBA_2019[6:10],
+ function(x) subset(x$data[c("name", "time", "value")]))
+names(ds) <- paste("Dataset", 6:10)
+# \dontrun{
+fits <- mmkin(c("SFO", "FOMC", "DFOP"), ds, quiet = TRUE, cores = 1)
+parms(fits["SFO", ])
+#>            Dataset 6    Dataset 7  Dataset 8  Dataset 9  Dataset 10
+#> parent_0 88.52275400 82.666781678 86.8547308 91.7779306 82.14809450
+#> k_parent  0.05794659  0.009647805  0.2102974  0.1232258  0.00720421
+#> sigma     5.15274487  7.040168584  3.6769645  6.4669234  6.50457673
+parms(fits[, 2])
+#> $SFO
+#>             Dataset 7
+#> parent_0 82.666781678
+#> k_parent  0.009647805
+#> sigma     7.040168584
+#> 
+#> $FOMC
+#>           Dataset 7
+#> parent_0 92.6837649
+#> alpha     0.4967832
+#> beta     14.1451255
+#> sigma     1.9167519
+#> 
+#> $DFOP
+#>             Dataset 7
+#> parent_0 91.058971584
+#> k1        0.044946770
+#> k2        0.002868336
+#> g         0.526942414
+#> sigma     2.221302196
+#> 
+parms(fits)
+#> $SFO
+#>            Dataset 6    Dataset 7  Dataset 8  Dataset 9  Dataset 10
+#> parent_0 88.52275400 82.666781678 86.8547308 91.7779306 82.14809450
+#> k_parent  0.05794659  0.009647805  0.2102974  0.1232258  0.00720421
+#> sigma     5.15274487  7.040168584  3.6769645  6.4669234  6.50457673
+#> 
+#> $FOMC
+#>          Dataset 6  Dataset 7 Dataset 8 Dataset 9 Dataset 10
+#> parent_0 95.558575 92.6837649 90.719787 98.383939 94.8481458
+#> alpha     1.338667  0.4967832  1.639099  1.074460  0.2805272
+#> beta     13.033315 14.1451255  5.007077  4.397126  6.9052224
+#> sigma     1.847671  1.9167519  1.066063  3.146056  1.6222778
+#> 
+#> $DFOP
+#>            Dataset 6    Dataset 7   Dataset 8   Dataset 9   Dataset 10
+#> parent_0 96.55213663 91.058971584 90.34509493 98.14858820 94.311323735
+#> k1        0.21954588  0.044946770  0.41232288  0.31697588  0.080663857
+#> k2        0.02957934  0.002868336  0.07581766  0.03260384  0.003425417
+#> g         0.44845068  0.526942414  0.66091967  0.65322767  0.342652880
+#> sigma     1.35690468  2.221302196  1.34169076  2.87159846  1.942067831
+#> 
+parms(fits, transformed = TRUE)
+#> $SFO
+#>              Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10
+#> parent_0     88.522754 82.666782 86.854731 91.777931  82.148095
+#> log_k_parent -2.848234 -4.641025 -1.559232 -2.093737  -4.933090
+#> sigma         5.152745  7.040169  3.676964  6.466923   6.504577
+#> 
+#> $FOMC
+#>            Dataset 6  Dataset 7  Dataset 8   Dataset 9 Dataset 10
+#> parent_0  95.5585751 92.6837649 90.7197870 98.38393898  94.848146
+#> log_alpha  0.2916741 -0.6996015  0.4941466  0.07181816  -1.271085
+#> log_beta   2.5675088  2.6493701  1.6108523  1.48095106   1.932278
+#> sigma      1.8476712  1.9167519  1.0660627  3.14605557   1.622278
+#> 
+#> $DFOP
+#>           Dataset 6  Dataset 7  Dataset 8  Dataset 9 Dataset 10
+#> parent_0 96.5521366 91.0589716 90.3450949 98.1485882 94.3113237
+#> log_k1   -1.5161940 -3.1022764 -0.8859486 -1.1489296 -2.5174647
+#> log_k2   -3.5206791 -5.8540232 -2.5794240 -3.4233253 -5.6765322
+#> g_qlogis -0.2069326  0.1078741  0.6673953  0.6332573 -0.6514943
+#> sigma     1.3569047  2.2213022  1.3416908  2.8715985  1.9420678
+#> 
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/parms.mkinfit.html b/docs/dev/reference/parms.mkinfit.html new file mode 100644 index 00000000..fee7b266 --- /dev/null +++ b/docs/dev/reference/parms.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/parms.mmkin.html b/docs/dev/reference/parms.mmkin.html new file mode 100644 index 00000000..fee7b266 --- /dev/null +++ b/docs/dev/reference/parms.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/parms.multistart.html b/docs/dev/reference/parms.multistart.html new file mode 100644 index 00000000..fee7b266 --- /dev/null +++ b/docs/dev/reference/parms.multistart.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/parms.saem.mmkin.html b/docs/dev/reference/parms.saem.mmkin.html new file mode 100644 index 00000000..fee7b266 --- /dev/null +++ b/docs/dev/reference/parms.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/parplot.html b/docs/dev/reference/parplot.html new file mode 100644 index 00000000..4a11710f --- /dev/null +++ b/docs/dev/reference/parplot.html @@ -0,0 +1,161 @@ + +Plot parameter variability of multistart objects — parplot • mkin + Skip to contents + + +
+
+
+ +
+

Produces a boxplot with all parameters from the multiple runs, scaled +either by the parameters of the run with the highest likelihood, +or by their medians as proposed in the paper by Duchesne et al. (2021).

+
+ +
+

Usage

+
parplot(object, ...)
+
+# S3 method for class 'multistart.saem.mmkin'
+parplot(
+  object,
+  llmin = -Inf,
+  llquant = NA,
+  scale = c("best", "median"),
+  lpos = "bottomleft",
+  main = "",
+  ...
+)
+
+ +
+

Arguments

+ + +
object
+

The multistart object

+ + +
...
+

Passed to boxplot

+ + +
llmin
+

The minimum likelihood of objects to be shown

+ + +
llquant
+

Fractional value for selecting only the fits with higher +likelihoods. Overrides 'llmin'.

+ + +
scale
+

By default, scale parameters using the best +available fit. +If 'median', parameters are scaled using the median parameters from all fits.

+ + +
lpos
+

Positioning of the legend.

+ + +
main
+

Title of the plot

+ +
+
+

Details

+

Starting values of degradation model parameters and error model parameters +are shown as green circles. The results obtained in the original run +are shown as red circles.

+
+
+

References

+

Duchesne R, Guillemin A, Gandrillon O, Crauste F. Practical +identifiability in the frame of nonlinear mixed effects models: the example +of the in vitro erythropoiesis. BMC Bioinformatics. 2021 Oct 4;22(1):478. +doi: 10.1186/s12859-021-04373-4.

+
+
+

See also

+ +
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/parplot.multistart.saem.mmkin.html b/docs/dev/reference/parplot.multistart.saem.mmkin.html new file mode 100644 index 00000000..d795c84e --- /dev/null +++ b/docs/dev/reference/parplot.multistart.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/plot.mixed.mmkin-1.png b/docs/dev/reference/plot.mixed.mmkin-1.png new file mode 100644 index 00000000..61b47f93 Binary files /dev/null and b/docs/dev/reference/plot.mixed.mmkin-1.png differ diff --git a/docs/dev/reference/plot.mixed.mmkin-2.png b/docs/dev/reference/plot.mixed.mmkin-2.png new file mode 100644 index 00000000..9229163a Binary files /dev/null and b/docs/dev/reference/plot.mixed.mmkin-2.png differ diff --git a/docs/dev/reference/plot.mixed.mmkin-3.png b/docs/dev/reference/plot.mixed.mmkin-3.png new file mode 100644 index 00000000..749efd4b Binary files /dev/null and b/docs/dev/reference/plot.mixed.mmkin-3.png differ diff --git a/docs/dev/reference/plot.mixed.mmkin-4.png b/docs/dev/reference/plot.mixed.mmkin-4.png new file mode 100644 index 00000000..336a80de Binary files /dev/null and b/docs/dev/reference/plot.mixed.mmkin-4.png differ diff --git a/docs/dev/reference/plot.mixed.mmkin.html b/docs/dev/reference/plot.mixed.mmkin.html new file mode 100644 index 00000000..06afd21f --- /dev/null +++ b/docs/dev/reference/plot.mixed.mmkin.html @@ -0,0 +1,294 @@ + +Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object — plot.mixed.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object

+
+ +
+

Usage

+
# S3 method for class 'mixed.mmkin'
+plot(
+  x,
+  i = 1:ncol(x$mmkin),
+  obs_vars = names(x$mkinmod$map),
+  standardized = TRUE,
+  covariates = NULL,
+  covariate_quantiles = c(0.5, 0.05, 0.95),
+  xlab = "Time",
+  xlim = range(x$data$time),
+  resplot = c("predicted", "time"),
+  pop_curves = "auto",
+  pred_over = NULL,
+  test_log_parms = FALSE,
+  conf.level = 0.6,
+  default_log_parms = NA,
+  ymax = "auto",
+  maxabs = "auto",
+  ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)),
+  nrow.legend = ceiling((length(i) + 1)/ncol.legend),
+  rel.height.legend = 0.02 + 0.07 * nrow.legend,
+  rel.height.bottom = 1.1,
+  pch_ds = c(1:25, 33, 35:38, 40:41, 47:57, 60:90)[1:length(i)],
+  col_ds = pch_ds + 1,
+  lty_ds = col_ds,
+  frame = TRUE,
+  ...
+)
+
+ +
+

Arguments

+ + +
x
+

An object of class mixed.mmkin, saem.mmkin or nlme.mmkin

+ + +
i
+

A numeric index to select datasets for which to plot the individual predictions, +in case plots get too large

+ + +
obs_vars
+

A character vector of names of the observed variables for +which the data and the model should be plotted. Defauls to all observed +variables in the model.

+ + +
standardized
+

Should the residuals be standardized? Only takes effect if +resplot = "time".

+ + +
covariates
+

Data frame with covariate values for all variables in +any covariate models in the object. If given, it overrides 'covariate_quantiles'. +Each line in the data frame will result in a line drawn for the population. +Rownames are used in the legend to label the lines.

+ + +
covariate_quantiles
+

This argument only has an effect if the fitted +object has covariate models. If so, the default is to show three population +curves, for the 5th percentile, the 50th percentile and the 95th percentile +of the covariate values used for fitting the model.

+ + +
xlab
+

Label for the x axis.

+ + +
xlim
+

Plot range in x direction.

+ + +
resplot
+

Should the residuals plotted against time or against +predicted values?

+ + +
pop_curves
+

Per default, one population curve is drawn in case +population parameters are fitted by the model, e.g. for saem objects. +In case there is a covariate model, the behaviour depends on the value +of 'covariates'

+ + +
pred_over
+

Named list of alternative predictions as obtained +from mkinpredict with a compatible mkinmod.

+ + +
test_log_parms
+

Passed to mean_degparms in the case of an +mixed.mmkin object

+ + +
conf.level
+

Passed to mean_degparms in the case of an +mixed.mmkin object

+ + +
default_log_parms
+

Passed to mean_degparms in the case of an +mixed.mmkin object

+ + +
ymax
+

Vector of maximum y axis values

+ + +
maxabs
+

Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".

+ + +
ncol.legend
+

Number of columns to use in the legend

+ + +
nrow.legend
+

Number of rows to use in the legend

+ + +
rel.height.legend
+

The relative height of the legend shown on top

+ + +
rel.height.bottom
+

The relative height of the bottom plot row

+ + +
pch_ds
+

Symbols to be used for plotting the data.

+ + +
col_ds
+

Colors used for plotting the observed data and the +corresponding model prediction lines for the different datasets.

+ + +
lty_ds
+

Line types to be used for the model predictions.

+ + +
frame
+

Should a frame be drawn around the plots?

+ + +
...
+

Further arguments passed to plot.

+ +
+
+

Value

+

The function is called for its side effect.

+
+
+

Note

+

Covariate models are currently only supported for saem.mmkin objects.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+
ds <- lapply(experimental_data_for_UBA_2019[6:10],
+ function(x) x$data[c("name", "time", "value")])
+names(ds) <- paste0("ds ", 6:10)
+dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
+  A1 = mkinsub("SFO"), quiet = TRUE)
+# \dontrun{
+f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE)
+plot(f[, 3:4], standardized = TRUE)
+
+
+# For this fit we need to increase pnlsMaxiter, and we increase the
+# tolerance in order to speed up the fit for this example evaluation
+# It still takes 20 seconds to run
+f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
+plot(f_nlme)
+
+
+f_saem <- saem(f, transformations = "saemix")
+plot(f_saem)
+
+
+f_obs <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE, error_model = "obs")
+f_nlmix <- nlmix(f_obs)
+#> Error in nlmix(f_obs): could not find function "nlmix"
+plot(f_nlmix)
+#> Error: object 'f_nlmix' not found
+
+# We can overlay the two variants if we generate predictions
+pred_nlme <- mkinpredict(dfop_sfo,
+  f_nlme$bparms.optim[-1],
+  c(parent = f_nlme$bparms.optim[[1]], A1 = 0),
+  seq(0, 180, by = 0.2))
+plot(f_saem, pred_over = list(nlme = pred_nlme))
+
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/plot.mkinfit-1.png b/docs/dev/reference/plot.mkinfit-1.png new file mode 100644 index 00000000..0a120916 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-1.png differ diff --git a/docs/dev/reference/plot.mkinfit-2.png b/docs/dev/reference/plot.mkinfit-2.png new file mode 100644 index 00000000..d3a39657 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-2.png differ diff --git a/docs/dev/reference/plot.mkinfit-3.png b/docs/dev/reference/plot.mkinfit-3.png new file mode 100644 index 00000000..3a74e51e Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-3.png differ diff --git a/docs/dev/reference/plot.mkinfit-4.png b/docs/dev/reference/plot.mkinfit-4.png new file mode 100644 index 00000000..0027f3eb Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-4.png differ diff --git a/docs/dev/reference/plot.mkinfit-5.png b/docs/dev/reference/plot.mkinfit-5.png new file mode 100644 index 00000000..9112cbb9 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-5.png differ diff --git a/docs/dev/reference/plot.mkinfit-6.png b/docs/dev/reference/plot.mkinfit-6.png new file mode 100644 index 00000000..6127d2f7 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-6.png differ diff --git a/docs/dev/reference/plot.mkinfit-7.png b/docs/dev/reference/plot.mkinfit-7.png new file mode 100644 index 00000000..2b92c212 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-7.png differ diff --git a/docs/dev/reference/plot.mkinfit.html b/docs/dev/reference/plot.mkinfit.html new file mode 100644 index 00000000..ffebd25d --- /dev/null +++ b/docs/dev/reference/plot.mkinfit.html @@ -0,0 +1,321 @@ + +Plot the observed data and the fitted model of an mkinfit object — plot.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

Solves the differential equations with the optimised and fixed parameters +from a previous successful call to mkinfit and plots the +observed data together with the solution of the fitted model.

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+plot(
+  x,
+  fit = x,
+  obs_vars = names(fit$mkinmod$map),
+  xlab = "Time",
+  ylab = "Residue",
+  xlim = range(fit$data$time),
+  ylim = "default",
+  col_obs = 1:length(obs_vars),
+  pch_obs = col_obs,
+  lty_obs = rep(1, length(obs_vars)),
+  add = FALSE,
+  legend = !add,
+  show_residuals = FALSE,
+  show_errplot = FALSE,
+  maxabs = "auto",
+  sep_obs = FALSE,
+  rel.height.middle = 0.9,
+  row_layout = FALSE,
+  lpos = "topright",
+  inset = c(0.05, 0.05),
+  show_errmin = FALSE,
+  errmin_digits = 3,
+  frame = TRUE,
+  ...
+)
+
+plot_sep(
+  fit,
+  show_errmin = TRUE,
+  show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE, "standardized"),
+  ...
+)
+
+plot_res(
+  fit,
+  sep_obs = FALSE,
+  show_errmin = sep_obs,
+  standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE),
+  ...
+)
+
+plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...)
+
+ +
+

Arguments

+ + +
x
+

Alias for fit introduced for compatibility with the generic S3 +method.

+ + +
fit
+

An object of class mkinfit.

+ + +
obs_vars
+

A character vector of names of the observed variables for +which the data and the model should be plotted. Defauls to all observed +variables in the model.

+ + +
xlab
+

Label for the x axis.

+ + +
ylab
+

Label for the y axis.

+ + +
xlim
+

Plot range in x direction.

+ + +
ylim
+

Plot range in y direction. If given as a list, plot ranges +for the different plot rows can be given for row layout.

+ + +
col_obs
+

Colors used for plotting the observed data and the +corresponding model prediction lines.

+ + +
pch_obs
+

Symbols to be used for plotting the data.

+ + +
lty_obs
+

Line types to be used for the model predictions.

+ + +
add
+

Should the plot be added to an existing plot?

+ + +
legend
+

Should a legend be added to the plot?

+ + +
show_residuals
+

Should residuals be shown? If only one plot of the +fits is shown, the residual plot is in the lower third of the plot. +Otherwise, i.e. if "sep_obs" is given, the residual plots will be located +to the right of the plots of the fitted curves. If this is set to +'standardized', a plot of the residuals divided by the standard deviation +given by the fitted error model will be shown.

+ + +
show_errplot
+

Should squared residuals and the error model be shown? +If only one plot of the fits is shown, this plot is in the lower third of +the plot. Otherwise, i.e. if "sep_obs" is given, the residual plots will +be located to the right of the plots of the fitted curves.

+ + +
maxabs
+

Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".

+ + +
sep_obs
+

Should the observed variables be shown in separate subplots? +If yes, residual plots requested by "show_residuals" will be shown next +to, not below the plot of the fits.

+ + +
rel.height.middle
+

The relative height of the middle plot, if more +than two rows of plots are shown.

+ + +
row_layout
+

Should we use a row layout where the residual plot or the +error model plot is shown to the right?

+ + +
lpos
+

Position(s) of the legend(s). Passed to legend as +the first argument. If not length one, this should be of the same length +as the obs_var argument.

+ + +
inset
+

Passed to legend if applicable.

+ + +
show_errmin
+

Should the FOCUS chi2 error value be shown in the upper +margin of the plot?

+ + +
errmin_digits
+

The number of significant digits for rounding the FOCUS +chi2 error percentage.

+ + +
frame
+

Should a frame be drawn around the plots?

+ + +
...
+

Further arguments passed to plot.

+ + +
standardized
+

When calling 'plot_res', should the residuals be +standardized in the residual plot?

+ +
+
+

Value

+

The function is called for its side effect.

+
+
+

Details

+

If the current plot device is a tikz device, then +latex is being used for the formatting of the chi2 error level, if +show_errmin = TRUE.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+# One parent compound, one metabolite, both single first order, path from
+# parent to sink included
+# \dontrun{
+SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"),
+                   m1 = mkinsub("SFO", full = "Metabolite M1" ))
+#> Temporary DLL for differentials generated and loaded
+fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc")
+#> Warning: Observations with value of zero were removed from the data
+plot(fit)
+
+plot_res(fit)
+
+plot_res(fit, standardized = FALSE)
+
+plot_err(fit)
+
+
+# Show the observed variables separately, with residuals
+plot(fit, sep_obs = TRUE, show_residuals = TRUE, lpos = c("topright", "bottomright"),
+     show_errmin = TRUE)
+
+
+# The same can be obtained with less typing, using the convenience function plot_sep
+plot_sep(fit, lpos = c("topright", "bottomright"))
+
+
+# Show the observed variables separately, with the error model
+plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"),
+     show_errmin = TRUE)
+
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/plot.mmkin-1.png b/docs/dev/reference/plot.mmkin-1.png new file mode 100644 index 00000000..58051871 Binary files /dev/null and b/docs/dev/reference/plot.mmkin-1.png differ diff --git a/docs/dev/reference/plot.mmkin-2.png b/docs/dev/reference/plot.mmkin-2.png new file mode 100644 index 00000000..eff04808 Binary files /dev/null and b/docs/dev/reference/plot.mmkin-2.png differ diff --git a/docs/dev/reference/plot.mmkin-3.png b/docs/dev/reference/plot.mmkin-3.png new file mode 100644 index 00000000..781c6351 Binary files /dev/null and b/docs/dev/reference/plot.mmkin-3.png differ diff --git a/docs/dev/reference/plot.mmkin-4.png b/docs/dev/reference/plot.mmkin-4.png new file mode 100644 index 00000000..ffbc6cab Binary files /dev/null and b/docs/dev/reference/plot.mmkin-4.png differ diff --git a/docs/dev/reference/plot.mmkin-5.png b/docs/dev/reference/plot.mmkin-5.png new file mode 100644 index 00000000..37bbac8b Binary files /dev/null and b/docs/dev/reference/plot.mmkin-5.png differ diff --git a/docs/dev/reference/plot.mmkin.html b/docs/dev/reference/plot.mmkin.html new file mode 100644 index 00000000..1f7907e9 --- /dev/null +++ b/docs/dev/reference/plot.mmkin.html @@ -0,0 +1,222 @@ + +Plot model fits (observed and fitted) and the residuals for a row or column of an mmkin object — plot.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

When x is a row selected from an mmkin object ([.mmkin), the +same model fitted for at least one dataset is shown. When it is a column, +the fit of at least one model to the same dataset is shown.

+
+ +
+

Usage

+
# S3 method for class 'mmkin'
+plot(
+  x,
+  main = "auto",
+  legends = 1,
+  resplot = c("time", "errmod"),
+  ylab = "Residue",
+  standardized = FALSE,
+  show_errmin = TRUE,
+  errmin_var = "All data",
+  errmin_digits = 3,
+  cex = 0.7,
+  rel.height.middle = 0.9,
+  ymax = "auto",
+  ...
+)
+
+ +
+

Arguments

+ + +
x
+

An object of class mmkin, with either one row or one +column.

+ + +
main
+

The main title placed on the outer margin of the plot.

+ + +
legends
+

An index for the fits for which legends should be shown.

+ + +
resplot
+

Should the residuals plotted against time, using +mkinresplot, or as squared residuals against predicted +values, with the error model, using mkinerrplot.

+ + +
ylab
+

Label for the y axis.

+ + +
standardized
+

Should the residuals be standardized? This option +is passed to mkinresplot, it only takes effect if +resplot = "time".

+ + +
show_errmin
+

Should the chi2 error level be shown on top of the plots +to the left?

+ + +
errmin_var
+

The variable for which the FOCUS chi2 error value should +be shown.

+ + +
errmin_digits
+

The number of significant digits for rounding the FOCUS +chi2 error percentage.

+ + +
cex
+

Passed to the plot functions and mtext.

+ + +
rel.height.middle
+

The relative height of the middle plot, if more +than two rows of plots are shown.

+ + +
ymax
+

Maximum y axis value for plot.mkinfit.

+ + +
...
+

Further arguments passed to plot.mkinfit and +mkinresplot.

+ +
+
+

Value

+

The function is called for its side effect.

+
+
+

Details

+

If the current plot device is a tikz device, then +latex is being used for the formatting of the chi2 error level.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  # \dontrun{
+  # Only use one core not to offend CRAN checks
+  fits <- mmkin(c("FOMC", "HS"),
+                list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), # named list for titles
+                cores = 1, quiet = TRUE, error_model = "tc")
+#> Warning: Optimisation did not converge:
+#> iteration limit reached without convergence (10)
+  plot(fits[, "FOCUS C"])
+
+  plot(fits["FOMC", ])
+
+  plot(fits["FOMC", ], show_errmin = FALSE)
+
+
+  # We can also plot a single fit, if we like the way plot.mmkin works, but then the plot
+  # height should be smaller than the plot width (this is not possible for the html pages
+  # generated by pkgdown, as far as I know).
+  plot(fits["FOMC", "FOCUS C"]) # same as plot(fits[1, 2])
+
+
+  # Show the error models
+  plot(fits["FOMC", ], resplot = "errmod")
+
+  # }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/plot.nafta.html b/docs/dev/reference/plot.nafta.html new file mode 100644 index 00000000..16bf0942 --- /dev/null +++ b/docs/dev/reference/plot.nafta.html @@ -0,0 +1,128 @@ + +Plot the results of the three models used in the NAFTA scheme. — plot.nafta • mkin + Skip to contents + + +
+
+
+ +
+

The plots are ordered with increasing complexity of the model in this +function (SFO, then IORE, then DFOP).

+
+ +
+

Usage

+
# S3 method for class 'nafta'
+plot(x, legend = FALSE, main = "auto", ...)
+
+ +
+

Arguments

+ + +
x
+

An object of class nafta.

+ + +
legend
+

Should a legend be added?

+ + +
main
+

Possibility to override the main title of the plot.

+ + +
...
+

Further arguments passed to plot.mmkin.

+ +
+
+

Value

+

The function is called for its side effect.

+
+
+

Details

+

Calls plot.mmkin.

+
+
+

Author

+

Johannes Ranke

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/plot_err.html b/docs/dev/reference/plot_err.html new file mode 100644 index 00000000..2885b160 --- /dev/null +++ b/docs/dev/reference/plot_err.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/plot_res.html b/docs/dev/reference/plot_res.html new file mode 100644 index 00000000..2885b160 --- /dev/null +++ b/docs/dev/reference/plot_res.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/plot_sep.html b/docs/dev/reference/plot_sep.html new file mode 100644 index 00000000..2885b160 --- /dev/null +++ b/docs/dev/reference/plot_sep.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.illparms.mhmkin.html b/docs/dev/reference/print.illparms.mhmkin.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/print.illparms.mhmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.illparms.mkinfit.html b/docs/dev/reference/print.illparms.mkinfit.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/print.illparms.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.illparms.mmkin.html b/docs/dev/reference/print.illparms.mmkin.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/print.illparms.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.illparms.saem.mmkin.html b/docs/dev/reference/print.illparms.saem.mmkin.html new file mode 100644 index 00000000..efbcc181 --- /dev/null +++ b/docs/dev/reference/print.illparms.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.mhmkin.html b/docs/dev/reference/print.mhmkin.html new file mode 100644 index 00000000..19cc9c91 --- /dev/null +++ b/docs/dev/reference/print.mhmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.mixed.mmkin.html b/docs/dev/reference/print.mixed.mmkin.html new file mode 100644 index 00000000..7b45f95d --- /dev/null +++ b/docs/dev/reference/print.mixed.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.mkinds.html b/docs/dev/reference/print.mkinds.html new file mode 100644 index 00000000..69424352 --- /dev/null +++ b/docs/dev/reference/print.mkinds.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.mkindsg.html b/docs/dev/reference/print.mkindsg.html new file mode 100644 index 00000000..66f9a81d --- /dev/null +++ b/docs/dev/reference/print.mkindsg.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.mkinmod.html b/docs/dev/reference/print.mkinmod.html new file mode 100644 index 00000000..0ffb4f23 --- /dev/null +++ b/docs/dev/reference/print.mkinmod.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.mmkin.html b/docs/dev/reference/print.mmkin.html new file mode 100644 index 00000000..9ea1bd04 --- /dev/null +++ b/docs/dev/reference/print.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.multistart.html b/docs/dev/reference/print.multistart.html new file mode 100644 index 00000000..06f15f0c --- /dev/null +++ b/docs/dev/reference/print.multistart.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.nafta.html b/docs/dev/reference/print.nafta.html new file mode 100644 index 00000000..e9563e53 --- /dev/null +++ b/docs/dev/reference/print.nafta.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.nlme.mmkin.html b/docs/dev/reference/print.nlme.mmkin.html new file mode 100644 index 00000000..dc3bfe09 --- /dev/null +++ b/docs/dev/reference/print.nlme.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.saem.mmkin.html b/docs/dev/reference/print.saem.mmkin.html new file mode 100644 index 00000000..fb5a153f --- /dev/null +++ b/docs/dev/reference/print.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.status.mhmkin.html b/docs/dev/reference/print.status.mhmkin.html new file mode 100644 index 00000000..9451cf16 --- /dev/null +++ b/docs/dev/reference/print.status.mhmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.status.mmkin.html b/docs/dev/reference/print.status.mmkin.html new file mode 100644 index 00000000..9451cf16 --- /dev/null +++ b/docs/dev/reference/print.status.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.summary.mkinfit.html b/docs/dev/reference/print.summary.mkinfit.html new file mode 100644 index 00000000..e8ff4c3c --- /dev/null +++ b/docs/dev/reference/print.summary.mkinfit.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.summary.mmkin.html b/docs/dev/reference/print.summary.mmkin.html new file mode 100644 index 00000000..2ec58ffd --- /dev/null +++ b/docs/dev/reference/print.summary.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.summary.nlme.mmkin.html b/docs/dev/reference/print.summary.nlme.mmkin.html new file mode 100644 index 00000000..b6c51558 --- /dev/null +++ b/docs/dev/reference/print.summary.nlme.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/print.summary.saem.mmkin.html b/docs/dev/reference/print.summary.saem.mmkin.html new file mode 100644 index 00000000..280587f2 --- /dev/null +++ b/docs/dev/reference/print.summary.saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/read_spreadsheet.html b/docs/dev/reference/read_spreadsheet.html new file mode 100644 index 00000000..d9c6ca2d --- /dev/null +++ b/docs/dev/reference/read_spreadsheet.html @@ -0,0 +1,155 @@ + +Read datasets and relevant meta information from a spreadsheet file — read_spreadsheet • mkin + Skip to contents + + +
+
+
+ +
+

This function imports one dataset from each sheet of a spreadsheet file. +These sheets are selected based on the contents of a sheet 'Datasets', with +a column called 'Dataset Number', containing numbers identifying the dataset +sheets to be read in. In the second column there must be a grouping +variable, which will often be named 'Soil'. Optionally, time normalization +factors can be given in columns named 'Temperature' and 'Moisture'.

+
+ +
+

Usage

+
read_spreadsheet(
+  path,
+  valid_datasets = "all",
+  parent_only = FALSE,
+  normalize = TRUE
+)
+
+ +
+

Arguments

+ + +
path
+

Absolute or relative path to the spreadsheet file

+ + +
valid_datasets
+

Optional numeric index of the valid datasets, default is +to use all datasets

+ + +
parent_only
+

Should only the parent data be used?

+ + +
normalize
+

Should the time scale be normalized using temperature +and moisture normalisation factors in the sheet 'Datasets'?

+ +
+
+

Details

+

There must be a sheet 'Compounds', with columns 'Name' and 'Acronym'. +The first row read after the header read in from this sheet is assumed +to contain name and acronym of the parent compound.

+

The dataset sheets should be named using the dataset numbers read in from +the 'Datasets' sheet, i.e. '1', '2', ... . In each dataset sheet, the name +of the observed variable (e.g. the acronym of the parent compound or +one of its transformation products) should be in the first column, +the time values should be in the second colum, and the observed value +in the third column.

+

In case relevant covariate data are available, they should be given +in a sheet 'Covariates', containing one line for each value of the grouping +variable specified in 'Datasets'. These values should be in the first +column and the column must have the same name as the second column in +'Datasets'. Covariates will be read in from columns four and higher. +Their names should preferably not contain special characters like spaces, +so they can be easily used for specifying covariate models.

+

A similar data structure is defined as the R6 class mkindsg, but +is probably more complicated to use.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/reexports.html b/docs/dev/reference/reexports.html new file mode 100644 index 00000000..e0763155 --- /dev/null +++ b/docs/dev/reference/reexports.html @@ -0,0 +1,118 @@ + +Objects exported from other packages — reexports • mkin + Skip to contents + + +
+
+
+ +
+

These objects are imported from other packages. Follow the links +below to see their documentation.

+
lmtest
+

lrtest

+ + +
nlme
+

intervals, nlme

+ + +
+ + + +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/residuals.mkinfit.html b/docs/dev/reference/residuals.mkinfit.html new file mode 100644 index 00000000..cd5c7aff --- /dev/null +++ b/docs/dev/reference/residuals.mkinfit.html @@ -0,0 +1,121 @@ + +Extract residuals from an mkinfit model — residuals.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

Extract residuals from an mkinfit model

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+residuals(object, standardized = FALSE, ...)
+
+ +
+

Arguments

+ + +
object
+

A mkinfit object

+ + +
standardized
+

Should the residuals be standardized by dividing by the +standard deviation obtained from the fitted error model?

+ + +
...
+

Not used

+ +
+ +
+

Examples

+
f <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE)
+residuals(f)
+#> [1]  0.09726374 -0.13912142 -0.15351210  0.73388322 -0.08657004 -0.93204702
+#> [7] -0.03269080  1.45347823 -0.88423697
+residuals(f, standardized = TRUE)
+#> [1]  0.13969917 -0.19981904 -0.22048826  1.05407091 -0.12433989 -1.33869208
+#> [7] -0.04695355  2.08761977 -1.27002287
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/saem-1.png b/docs/dev/reference/saem-1.png new file mode 100644 index 00000000..1fa206c4 Binary files /dev/null and b/docs/dev/reference/saem-1.png differ diff --git a/docs/dev/reference/saem-2.png b/docs/dev/reference/saem-2.png new file mode 100644 index 00000000..e5c62c35 Binary files /dev/null and b/docs/dev/reference/saem-2.png differ diff --git a/docs/dev/reference/saem-3.png b/docs/dev/reference/saem-3.png new file mode 100644 index 00000000..09eb2d40 Binary files /dev/null and b/docs/dev/reference/saem-3.png differ diff --git a/docs/dev/reference/saem-4.png b/docs/dev/reference/saem-4.png new file mode 100644 index 00000000..87ebc56f Binary files /dev/null and b/docs/dev/reference/saem-4.png differ diff --git a/docs/dev/reference/saem.html b/docs/dev/reference/saem.html new file mode 100644 index 00000000..25eb03c7 --- /dev/null +++ b/docs/dev/reference/saem.html @@ -0,0 +1,731 @@ + +Fit nonlinear mixed models with SAEM — saem • mkin + Skip to contents + + +
+
+
+ +
+

This function uses saemix::saemix() as a backend for fitting nonlinear mixed +effects models created from mmkin row objects using the Stochastic Approximation +Expectation Maximisation algorithm (SAEM).

+
+ +
+

Usage

+
saem(object, ...)
+
+# S3 method for class 'mmkin'
+saem(
+  object,
+  transformations = c("mkin", "saemix"),
+  error_model = "auto",
+  degparms_start = numeric(),
+  test_log_parms = TRUE,
+  conf.level = 0.6,
+  solution_type = "auto",
+  covariance.model = "auto",
+  omega.init = "auto",
+  covariates = NULL,
+  covariate_models = NULL,
+  no_random_effect = NULL,
+  error.init = c(1, 1),
+  nbiter.saemix = c(300, 100),
+  control = list(displayProgress = FALSE, print = FALSE, nbiter.saemix = nbiter.saemix,
+    save = FALSE, save.graphs = FALSE),
+  verbose = FALSE,
+  quiet = FALSE,
+  ...
+)
+
+# S3 method for class 'saem.mmkin'
+print(x, digits = max(3, getOption("digits") - 3), ...)
+
+saemix_model(
+  object,
+  solution_type = "auto",
+  transformations = c("mkin", "saemix"),
+  error_model = "auto",
+  degparms_start = numeric(),
+  covariance.model = "auto",
+  no_random_effect = NULL,
+  omega.init = "auto",
+  covariates = NULL,
+  covariate_models = NULL,
+  error.init = numeric(),
+  test_log_parms = FALSE,
+  conf.level = 0.6,
+  verbose = FALSE,
+  ...
+)
+
+saemix_data(object, covariates = NULL, verbose = FALSE, ...)
+
+ +
+

Arguments

+ + +
object
+

An mmkin row object containing several fits of the same +mkinmod model to different datasets

+ + +
...
+

Further parameters passed to saemix::saemixModel.

+ + +
transformations
+

Per default, all parameter transformations are done +in mkin. If this argument is set to 'saemix', parameter transformations +are done in 'saemix' for the supported cases, i.e. (as of version 1.1.2) +SFO, FOMC, DFOP and HS without fixing parent_0, and SFO or DFOP with +one SFO metabolite.

+ + +
error_model
+

Possibility to override the error model used in the mmkin object

+ + +
degparms_start
+

Parameter values given as a named numeric vector will +be used to override the starting values obtained from the 'mmkin' object.

+ + +
test_log_parms
+

If TRUE, an attempt is made to use more robust starting +values for population parameters fitted as log parameters in mkin (like +rate constants) by only considering rate constants that pass the t-test +when calculating mean degradation parameters using mean_degparms.

+ + +
conf.level
+

Possibility to adjust the required confidence level +for parameter that are tested if requested by 'test_log_parms'.

+ + +
solution_type
+

Possibility to specify the solution type in case the +automatic choice is not desired

+ + +
covariance.model
+

Will be passed to saemix::saemixModel(). Per +default, uncorrelated random effects are specified for all degradation +parameters.

+ + +
omega.init
+

Will be passed to saemix::saemixModel(). If using +mkin transformations and the default covariance model with optionally +excluded random effects, the variances of the degradation parameters +are estimated using mean_degparms, with testing of untransformed +log parameters for significant difference from zero. If not using +mkin transformations or a custom covariance model, the default +initialisation of saemix::saemixModel is used for omega.init.

+ + +
covariates
+

A data frame with covariate data for use in +'covariate_models', with dataset names as row names.

+ + +
covariate_models
+

A list containing linear model formulas with one explanatory +variable, i.e. of the type 'parameter ~ covariate'. Covariates must be available +in the 'covariates' data frame.

+ + +
no_random_effect
+

Character vector of degradation parameters for +which there should be no variability over the groups. Only used +if the covariance model is not explicitly specified.

+ + +
error.init
+

Will be passed to saemix::saemixModel().

+ + +
nbiter.saemix
+

Convenience option to increase the number of +iterations

+ + +
control
+

Passed to saemix::saemix.

+ + +
verbose
+

Should we print information about created objects of +type saemix::SaemixModel and saemix::SaemixData?

+ + +
quiet
+

Should we suppress the messages saemix prints at the beginning +and the end of the optimisation process?

+ + +
x
+

An saem.mmkin object to print

+ + +
digits
+

Number of digits to use for printing

+ +
+
+

Value

+

An S3 object of class 'saem.mmkin', containing the fitted +saemix::SaemixObject as a list component named 'so'. The +object also inherits from 'mixed.mmkin'.

+

An saemix::SaemixModel object.

+

An saemix::SaemixData object.

+
+
+

Details

+

An mmkin row object is essentially a list of mkinfit objects that have been +obtained by fitting the same model to a list of datasets using mkinfit.

+

Starting values for the fixed effects (population mean parameters, argument +psi0 of saemix::saemixModel() are the mean values of the parameters found +using mmkin.

+
+ + +
+

Examples

+
# \dontrun{
+ds <- lapply(experimental_data_for_UBA_2019[6:10],
+ function(x) subset(x$data[c("name", "time", "value")]))
+names(ds) <- paste("Dataset", 6:10)
+f_mmkin_parent_p0_fixed <- mmkin("FOMC", ds,
+  state.ini = c(parent = 100), fixed_initials = "parent", quiet = TRUE)
+f_saem_p0_fixed <- saem(f_mmkin_parent_p0_fixed)
+
+f_mmkin_parent <- mmkin(c("SFO", "FOMC", "DFOP"), ds, quiet = TRUE)
+f_saem_sfo <- saem(f_mmkin_parent["SFO", ])
+f_saem_fomc <- saem(f_mmkin_parent["FOMC", ])
+f_saem_dfop <- saem(f_mmkin_parent["DFOP", ])
+anova(f_saem_sfo, f_saem_fomc, f_saem_dfop)
+#> Data: 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#>             npar    AIC    BIC     Lik
+#> f_saem_sfo     5 624.33 622.38 -307.17
+#> f_saem_fomc    7 467.85 465.11 -226.92
+#> f_saem_dfop    9 493.76 490.24 -237.88
+anova(f_saem_sfo, f_saem_dfop, test = TRUE)
+#> Data: 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#>             npar    AIC    BIC     Lik  Chisq Df Pr(>Chisq)    
+#> f_saem_sfo     5 624.33 622.38 -307.17                         
+#> f_saem_dfop    9 493.76 490.24 -237.88 138.57  4  < 2.2e-16 ***
+#> ---
+#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+illparms(f_saem_dfop)
+#> [1] "sd(g_qlogis)"
+f_saem_dfop_red <- update(f_saem_dfop, no_random_effect = "g_qlogis")
+anova(f_saem_dfop, f_saem_dfop_red, test = TRUE)
+#> Data: 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#>                 npar    AIC    BIC     Lik Chisq Df Pr(>Chisq)
+#> f_saem_dfop_red    8 488.68 485.55 -236.34                    
+#> f_saem_dfop        9 493.76 490.24 -237.88     0  1          1
+
+anova(f_saem_sfo, f_saem_fomc, f_saem_dfop)
+#> Data: 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#>             npar    AIC    BIC     Lik
+#> f_saem_sfo     5 624.33 622.38 -307.17
+#> f_saem_fomc    7 467.85 465.11 -226.92
+#> f_saem_dfop    9 493.76 490.24 -237.88
+# The returned saem.mmkin object contains an SaemixObject, therefore we can use
+# functions from saemix
+library(saemix)
+#> Loading required package: npde
+#> Package saemix, version 3.3, March 2024
+#>   please direct bugs, questions and feedback to emmanuelle.comets@inserm.fr
+#> 
+#> Attaching package: ‘saemix’
+#> The following objects are masked from ‘package:npde’:
+#> 
+#>     kurtosis, skewness
+compare.saemix(f_saem_sfo$so, f_saem_fomc$so, f_saem_dfop$so)
+#> Likelihoods calculated by importance sampling
+#>        AIC      BIC
+#> 1 624.3316 622.3788
+#> 2 467.8472 465.1132
+#> 3 493.7592 490.2441
+plot(f_saem_fomc$so, plot.type = "convergence")
+
+plot(f_saem_fomc$so, plot.type = "individual.fit")
+#> Simulating data using nsim = 1000 simulated datasets
+#> Computing WRES and npde .
+
+plot(f_saem_fomc$so, plot.type = "npde")
+#> Simulating data using nsim = 1000 simulated datasets
+#> Computing WRES and npde .
+#> Please use npdeSaemix to obtain VPC and npde
+plot(f_saem_fomc$so, plot.type = "vpc")
+
+
+f_mmkin_parent_tc <- update(f_mmkin_parent, error_model = "tc")
+f_saem_fomc_tc <- saem(f_mmkin_parent_tc["FOMC", ])
+anova(f_saem_fomc, f_saem_fomc_tc, test = TRUE)
+#> Data: 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#>                npar    AIC    BIC     Lik Chisq Df Pr(>Chisq)
+#> f_saem_fomc       7 467.85 465.11 -226.92                    
+#> f_saem_fomc_tc    8 469.90 466.77 -226.95     0  1          1
+
+sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"),
+  A1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+fomc_sfo <- mkinmod(parent = mkinsub("FOMC", "A1"),
+  A1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
+  A1 = mkinsub("SFO"))
+#> Temporary DLL for differentials generated and loaded
+# The following fit uses analytical solutions for SFO-SFO and DFOP-SFO,
+# and compiled ODEs for FOMC that are much slower
+f_mmkin <- mmkin(list(
+    "SFO-SFO" = sfo_sfo, "FOMC-SFO" = fomc_sfo, "DFOP-SFO" = dfop_sfo),
+  ds, quiet = TRUE)
+# saem fits of SFO-SFO and DFOP-SFO to these data take about five seconds
+# each on this system, as we use analytical solutions written for saemix.
+# When using the analytical solutions written for mkin this took around
+# four minutes
+f_saem_sfo_sfo <- saem(f_mmkin["SFO-SFO", ])
+f_saem_dfop_sfo <- saem(f_mmkin["DFOP-SFO", ])
+# We can use print, plot and summary methods to check the results
+print(f_saem_dfop_sfo)
+#> Kinetic nonlinear mixed-effects model fit by SAEM
+#> Structural model:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> d_A1/dt = + f_parent_to_A1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g)
+#>            * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+#>            exp(-k2 * time))) * parent - k_A1 * A1
+#> 
+#> Data:
+#> 170 observations of 2 variable(s) grouped in 5 datasets
+#> 
+#> Likelihood computed by importance sampling
+#>     AIC   BIC logLik
+#>   839.2 834.1 -406.6
+#> 
+#> Fitted parameters:
+#>                    estimate    lower   upper
+#> parent_0           93.70402 91.04104 96.3670
+#> log_k_A1           -5.83760 -7.66452 -4.0107
+#> f_parent_qlogis    -0.95718 -1.35955 -0.5548
+#> log_k1             -2.35514 -3.39402 -1.3163
+#> log_k2             -3.79634 -5.64009 -1.9526
+#> g_qlogis           -0.02108 -0.66463  0.6225
+#> a.1                 1.88191  1.66491  2.0989
+#> SD.parent_0         2.81628  0.78922  4.8433
+#> SD.log_k_A1         1.78751  0.42105  3.1540
+#> SD.f_parent_qlogis  0.45016  0.16116  0.7391
+#> SD.log_k1           1.06923  0.31676  1.8217
+#> SD.log_k2           2.03768  0.70938  3.3660
+#> SD.g_qlogis         0.44024 -0.09262  0.9731
+plot(f_saem_dfop_sfo)
+
+summary(f_saem_dfop_sfo, data = TRUE)
+#> saemix version used for fitting:      3.3 
+#> mkin version used for pre-fitting:  1.2.10 
+#> R version used for fitting:         4.4.2 
+#> Date of fit:     Fri Feb 14 07:32:13 2025 
+#> Date of summary: Fri Feb 14 07:32:13 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> d_A1/dt = + f_parent_to_A1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g)
+#>            * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+#>            exp(-k2 * time))) * parent - k_A1 * A1
+#> 
+#> Data:
+#> 170 observations of 2 variable(s) grouped in 5 datasets
+#> 
+#> Model predictions using solution type analytical 
+#> 
+#> Fitted in 3.605 s
+#> Using 300, 100 iterations and 10 chains
+#> 
+#> Variance model: Constant variance 
+#> 
+#> Starting values for degradation parameters:
+#>        parent_0        log_k_A1 f_parent_qlogis          log_k1          log_k2 
+#>         93.8102         -5.3734         -0.9711         -1.8799         -4.2708 
+#>        g_qlogis 
+#>          0.1356 
+#> 
+#> Fixed degradation parameter values:
+#> None
+#> 
+#> Starting values for random effects (square root of initial entries in omega):
+#>                 parent_0 log_k_A1 f_parent_qlogis log_k1 log_k2 g_qlogis
+#> parent_0           4.941    0.000          0.0000  0.000  0.000   0.0000
+#> log_k_A1           0.000    2.551          0.0000  0.000  0.000   0.0000
+#> f_parent_qlogis    0.000    0.000          0.7251  0.000  0.000   0.0000
+#> log_k1             0.000    0.000          0.0000  1.449  0.000   0.0000
+#> log_k2             0.000    0.000          0.0000  0.000  2.228   0.0000
+#> g_qlogis           0.000    0.000          0.0000  0.000  0.000   0.7814
+#> 
+#> Starting values for error model parameters:
+#> a.1 
+#>   1 
+#> 
+#> Results:
+#> 
+#> Likelihood computed by importance sampling
+#>     AIC   BIC logLik
+#>   839.2 834.1 -406.6
+#> 
+#> Optimised parameters:
+#>                        est.    lower   upper
+#> parent_0           93.70402 91.04104 96.3670
+#> log_k_A1           -5.83760 -7.66452 -4.0107
+#> f_parent_qlogis    -0.95718 -1.35955 -0.5548
+#> log_k1             -2.35514 -3.39402 -1.3163
+#> log_k2             -3.79634 -5.64009 -1.9526
+#> g_qlogis           -0.02108 -0.66463  0.6225
+#> a.1                 1.88191  1.66491  2.0989
+#> SD.parent_0         2.81628  0.78922  4.8433
+#> SD.log_k_A1         1.78751  0.42105  3.1540
+#> SD.f_parent_qlogis  0.45016  0.16116  0.7391
+#> SD.log_k1           1.06923  0.31676  1.8217
+#> SD.log_k2           2.03768  0.70938  3.3660
+#> SD.g_qlogis         0.44024 -0.09262  0.9731
+#> 
+#> Correlation: 
+#>                 parnt_0 lg_k_A1 f_prnt_ log_k1  log_k2 
+#> log_k_A1        -0.0147                                
+#> f_parent_qlogis -0.0269  0.0573                        
+#> log_k1           0.0263 -0.0011 -0.0040                
+#> log_k2           0.0020  0.0065 -0.0002 -0.0776        
+#> g_qlogis        -0.0248 -0.0180 -0.0004 -0.0903 -0.0603
+#> 
+#> Random effects:
+#>                      est.    lower  upper
+#> SD.parent_0        2.8163  0.78922 4.8433
+#> SD.log_k_A1        1.7875  0.42105 3.1540
+#> SD.f_parent_qlogis 0.4502  0.16116 0.7391
+#> SD.log_k1          1.0692  0.31676 1.8217
+#> SD.log_k2          2.0377  0.70938 3.3660
+#> SD.g_qlogis        0.4402 -0.09262 0.9731
+#> 
+#> Variance model:
+#>      est. lower upper
+#> a.1 1.882 1.665 2.099
+#> 
+#> Backtransformed parameters:
+#>                     est.     lower    upper
+#> parent_0       93.704015 9.104e+01 96.36699
+#> k_A1            0.002916 4.692e-04  0.01812
+#> f_parent_to_A1  0.277443 2.043e-01  0.36475
+#> k1              0.094880 3.357e-02  0.26813
+#> k2              0.022453 3.553e-03  0.14191
+#> g               0.494731 3.397e-01  0.65078
+#> 
+#> Resulting formation fractions:
+#>                 ff
+#> parent_A1   0.2774
+#> parent_sink 0.7226
+#> 
+#> Estimated disappearance times:
+#>         DT50   DT90 DT50back DT50_k1 DT50_k2
+#> parent  14.0  72.38    21.79   7.306   30.87
+#> A1     237.7 789.68       NA      NA      NA
+#> 
+#> Data:
+#>          ds   name time observed predicted residual   std standardized
+#>   Dataset 6 parent    0     97.2  95.70025  1.49975 1.882      0.79693
+#>   Dataset 6 parent    0     96.4  95.70025  0.69975 1.882      0.37183
+#>   Dataset 6 parent    3     71.1  71.44670 -0.34670 1.882     -0.18423
+#>   Dataset 6 parent    3     69.2  71.44670 -2.24670 1.882     -1.19384
+#>   Dataset 6 parent    6     58.1  56.59283  1.50717 1.882      0.80087
+#>   Dataset 6 parent    6     56.6  56.59283  0.00717 1.882      0.00381
+#>   Dataset 6 parent   10     44.4  44.56648 -0.16648 1.882     -0.08847
+#>   Dataset 6 parent   10     43.4  44.56648 -1.16648 1.882     -0.61984
+#>   Dataset 6 parent   20     33.3  29.76020  3.53980 1.882      1.88096
+#>   Dataset 6 parent   20     29.2  29.76020 -0.56020 1.882     -0.29767
+#>   Dataset 6 parent   34     17.6  19.39208 -1.79208 1.882     -0.95226
+#>   Dataset 6 parent   34     18.0  19.39208 -1.39208 1.882     -0.73971
+#>   Dataset 6 parent   55     10.5  10.55761 -0.05761 1.882     -0.03061
+#>   Dataset 6 parent   55      9.3  10.55761 -1.25761 1.882     -0.66826
+#>   Dataset 6 parent   90      4.5   3.84742  0.65258 1.882      0.34676
+#>   Dataset 6 parent   90      4.7   3.84742  0.85258 1.882      0.45304
+#>   Dataset 6 parent  112      3.0   2.03997  0.96003 1.882      0.51013
+#>   Dataset 6 parent  112      3.4   2.03997  1.36003 1.882      0.72268
+#>   Dataset 6 parent  132      2.3   1.14585  1.15415 1.882      0.61328
+#>   Dataset 6 parent  132      2.7   1.14585  1.55415 1.882      0.82583
+#>   Dataset 6     A1    3      4.3   4.86054 -0.56054 1.882     -0.29786
+#>   Dataset 6     A1    3      4.6   4.86054 -0.26054 1.882     -0.13844
+#>   Dataset 6     A1    6      7.0   7.74179 -0.74179 1.882     -0.39417
+#>   Dataset 6     A1    6      7.2   7.74179 -0.54179 1.882     -0.28789
+#>   Dataset 6     A1   10      8.2   9.94048 -1.74048 1.882     -0.92485
+#>   Dataset 6     A1   10      8.0   9.94048 -1.94048 1.882     -1.03112
+#>   Dataset 6     A1   20     11.0  12.19109 -1.19109 1.882     -0.63291
+#>   Dataset 6     A1   20     13.7  12.19109  1.50891 1.882      0.80180
+#>   Dataset 6     A1   34     11.5  13.10706 -1.60706 1.882     -0.85395
+#>   Dataset 6     A1   34     12.7  13.10706 -0.40706 1.882     -0.21630
+#>   Dataset 6     A1   55     14.9  13.06131  1.83869 1.882      0.97703
+#>   Dataset 6     A1   55     14.5  13.06131  1.43869 1.882      0.76448
+#>   Dataset 6     A1   90     12.1  11.54495  0.55505 1.882      0.29494
+#>   Dataset 6     A1   90     12.3  11.54495  0.75505 1.882      0.40122
+#>   Dataset 6     A1  112      9.9  10.31533 -0.41533 1.882     -0.22070
+#>   Dataset 6     A1  112     10.2  10.31533 -0.11533 1.882     -0.06128
+#>   Dataset 6     A1  132      8.8   9.20222 -0.40222 1.882     -0.21373
+#>   Dataset 6     A1  132      7.8   9.20222 -1.40222 1.882     -0.74510
+#>   Dataset 7 parent    0     93.6  90.82357  2.77643 1.882      1.47532
+#>   Dataset 7 parent    0     92.3  90.82357  1.47643 1.882      0.78453
+#>   Dataset 7 parent    3     87.0  84.73448  2.26552 1.882      1.20384
+#>   Dataset 7 parent    3     82.2  84.73448 -2.53448 1.882     -1.34675
+#>   Dataset 7 parent    7     74.0  77.65013 -3.65013 1.882     -1.93958
+#>   Dataset 7 parent    7     73.9  77.65013 -3.75013 1.882     -1.99272
+#>   Dataset 7 parent   14     64.2  67.60639 -3.40639 1.882     -1.81007
+#>   Dataset 7 parent   14     69.5  67.60639  1.89361 1.882      1.00621
+#>   Dataset 7 parent   30     54.0  52.53663  1.46337 1.882      0.77760
+#>   Dataset 7 parent   30     54.6  52.53663  2.06337 1.882      1.09642
+#>   Dataset 7 parent   60     41.1  39.42728  1.67272 1.882      0.88884
+#>   Dataset 7 parent   60     38.4  39.42728 -1.02728 1.882     -0.54587
+#>   Dataset 7 parent   90     32.5  33.76360 -1.26360 1.882     -0.67144
+#>   Dataset 7 parent   90     35.5  33.76360  1.73640 1.882      0.92268
+#>   Dataset 7 parent  120     28.1  30.39975 -2.29975 1.882     -1.22203
+#>   Dataset 7 parent  120     29.0  30.39975 -1.39975 1.882     -0.74379
+#>   Dataset 7 parent  180     26.5  25.62379  0.87621 1.882      0.46559
+#>   Dataset 7 parent  180     27.6  25.62379  1.97621 1.882      1.05010
+#>   Dataset 7     A1    3      3.9   2.70005  1.19995 1.882      0.63762
+#>   Dataset 7     A1    3      3.1   2.70005  0.39995 1.882      0.21252
+#>   Dataset 7     A1    7      6.9   5.83475  1.06525 1.882      0.56605
+#>   Dataset 7     A1    7      6.6   5.83475  0.76525 1.882      0.40663
+#>   Dataset 7     A1   14     10.4  10.26142  0.13858 1.882      0.07364
+#>   Dataset 7     A1   14      8.3  10.26142 -1.96142 1.882     -1.04225
+#>   Dataset 7     A1   30     14.4  16.82999 -2.42999 1.882     -1.29123
+#>   Dataset 7     A1   30     13.7  16.82999 -3.12999 1.882     -1.66319
+#>   Dataset 7     A1   60     22.1  22.32486 -0.22486 1.882     -0.11949
+#>   Dataset 7     A1   60     22.3  22.32486 -0.02486 1.882     -0.01321
+#>   Dataset 7     A1   90     27.5  24.45927  3.04073 1.882      1.61576
+#>   Dataset 7     A1   90     25.4  24.45927  0.94073 1.882      0.49988
+#>   Dataset 7     A1  120     28.0  25.54862  2.45138 1.882      1.30260
+#>   Dataset 7     A1  120     26.6  25.54862  1.05138 1.882      0.55868
+#>   Dataset 7     A1  180     25.8  26.82277 -1.02277 1.882     -0.54347
+#>   Dataset 7     A1  180     25.3  26.82277 -1.52277 1.882     -0.80916
+#>   Dataset 8 parent    0     91.9  91.16791  0.73209 1.882      0.38901
+#>   Dataset 8 parent    0     90.8  91.16791 -0.36791 1.882     -0.19550
+#>   Dataset 8 parent    1     64.9  67.58358 -2.68358 1.882     -1.42598
+#>   Dataset 8 parent    1     66.2  67.58358 -1.38358 1.882     -0.73520
+#>   Dataset 8 parent    3     43.5  41.62086  1.87914 1.882      0.99853
+#>   Dataset 8 parent    3     44.1  41.62086  2.47914 1.882      1.31735
+#>   Dataset 8 parent    8     18.3  19.60116 -1.30116 1.882     -0.69140
+#>   Dataset 8 parent    8     18.1  19.60116 -1.50116 1.882     -0.79768
+#>   Dataset 8 parent   14     10.2  10.63101 -0.43101 1.882     -0.22903
+#>   Dataset 8 parent   14     10.8  10.63101  0.16899 1.882      0.08980
+#>   Dataset 8 parent   27      4.9   3.12435  1.77565 1.882      0.94354
+#>   Dataset 8 parent   27      3.3   3.12435  0.17565 1.882      0.09334
+#>   Dataset 8 parent   48      1.6   0.43578  1.16422 1.882      0.61864
+#>   Dataset 8 parent   48      1.5   0.43578  1.06422 1.882      0.56550
+#>   Dataset 8 parent   70      1.1   0.05534  1.04466 1.882      0.55510
+#>   Dataset 8 parent   70      0.9   0.05534  0.84466 1.882      0.44883
+#>   Dataset 8     A1    1      9.6   7.63450  1.96550 1.882      1.04442
+#>   Dataset 8     A1    1      7.7   7.63450  0.06550 1.882      0.03481
+#>   Dataset 8     A1    3     15.0  15.52593 -0.52593 1.882     -0.27947
+#>   Dataset 8     A1    3     15.1  15.52593 -0.42593 1.882     -0.22633
+#>   Dataset 8     A1    8     21.2  20.32192  0.87808 1.882      0.46659
+#>   Dataset 8     A1    8     21.1  20.32192  0.77808 1.882      0.41345
+#>   Dataset 8     A1   14     19.7  20.09721 -0.39721 1.882     -0.21107
+#>   Dataset 8     A1   14     18.9  20.09721 -1.19721 1.882     -0.63617
+#>   Dataset 8     A1   27     17.5  16.37477  1.12523 1.882      0.59792
+#>   Dataset 8     A1   27     15.9  16.37477 -0.47477 1.882     -0.25228
+#>   Dataset 8     A1   48      9.5  10.13141 -0.63141 1.882     -0.33551
+#>   Dataset 8     A1   48      9.8  10.13141 -0.33141 1.882     -0.17610
+#>   Dataset 8     A1   70      6.2   5.81827  0.38173 1.882      0.20284
+#>   Dataset 8     A1   70      6.1   5.81827  0.28173 1.882      0.14970
+#>   Dataset 9 parent    0     99.8  97.48728  2.31272 1.882      1.22892
+#>   Dataset 9 parent    0     98.3  97.48728  0.81272 1.882      0.43186
+#>   Dataset 9 parent    1     77.1  79.29476 -2.19476 1.882     -1.16624
+#>   Dataset 9 parent    1     77.2  79.29476 -2.09476 1.882     -1.11310
+#>   Dataset 9 parent    3     59.0  55.67060  3.32940 1.882      1.76915
+#>   Dataset 9 parent    3     58.1  55.67060  2.42940 1.882      1.29092
+#>   Dataset 9 parent    8     27.4  31.57871 -4.17871 1.882     -2.22046
+#>   Dataset 9 parent    8     29.2  31.57871 -2.37871 1.882     -1.26398
+#>   Dataset 9 parent   14     19.1  22.51546 -3.41546 1.882     -1.81489
+#>   Dataset 9 parent   14     29.6  22.51546  7.08454 1.882      3.76454
+#>   Dataset 9 parent   27     10.1  14.09074 -3.99074 1.882     -2.12057
+#>   Dataset 9 parent   27     18.2  14.09074  4.10926 1.882      2.18355
+#>   Dataset 9 parent   48      4.5   6.95747 -2.45747 1.882     -1.30584
+#>   Dataset 9 parent   48      9.1   6.95747  2.14253 1.882      1.13848
+#>   Dataset 9 parent   70      2.3   3.32472 -1.02472 1.882     -0.54451
+#>   Dataset 9 parent   70      2.9   3.32472 -0.42472 1.882     -0.22569
+#>   Dataset 9 parent   91      2.0   1.64300  0.35700 1.882      0.18970
+#>   Dataset 9 parent   91      1.8   1.64300  0.15700 1.882      0.08343
+#>   Dataset 9 parent  120      2.0   0.62073  1.37927 1.882      0.73291
+#>   Dataset 9 parent  120      2.2   0.62073  1.57927 1.882      0.83918
+#>   Dataset 9     A1    1      4.2   3.64568  0.55432 1.882      0.29455
+#>   Dataset 9     A1    1      3.9   3.64568  0.25432 1.882      0.13514
+#>   Dataset 9     A1    3      7.4   8.30173 -0.90173 1.882     -0.47916
+#>   Dataset 9     A1    3      7.9   8.30173 -0.40173 1.882     -0.21347
+#>   Dataset 9     A1    8     14.5  12.71589  1.78411 1.882      0.94803
+#>   Dataset 9     A1    8     13.7  12.71589  0.98411 1.882      0.52293
+#>   Dataset 9     A1   14     14.2  13.90452  0.29548 1.882      0.15701
+#>   Dataset 9     A1   14     12.2  13.90452 -1.70452 1.882     -0.90574
+#>   Dataset 9     A1   27     13.7  14.15523 -0.45523 1.882     -0.24190
+#>   Dataset 9     A1   27     13.2  14.15523 -0.95523 1.882     -0.50759
+#>   Dataset 9     A1   48     13.6  13.31038  0.28962 1.882      0.15389
+#>   Dataset 9     A1   48     15.4  13.31038  2.08962 1.882      1.11037
+#>   Dataset 9     A1   70     10.4  11.85965 -1.45965 1.882     -0.77562
+#>   Dataset 9     A1   70     11.6  11.85965 -0.25965 1.882     -0.13797
+#>   Dataset 9     A1   91     10.0  10.36294 -0.36294 1.882     -0.19286
+#>   Dataset 9     A1   91      9.5  10.36294 -0.86294 1.882     -0.45855
+#>   Dataset 9     A1  120      9.1   8.43003  0.66997 1.882      0.35601
+#>   Dataset 9     A1  120      9.0   8.43003  0.56997 1.882      0.30287
+#>  Dataset 10 parent    0     96.1  93.95603  2.14397 1.882      1.13925
+#>  Dataset 10 parent    0     94.3  93.95603  0.34397 1.882      0.18278
+#>  Dataset 10 parent    8     73.9  77.70592 -3.80592 1.882     -2.02237
+#>  Dataset 10 parent    8     73.9  77.70592 -3.80592 1.882     -2.02237
+#>  Dataset 10 parent   14     69.4  70.04570 -0.64570 1.882     -0.34311
+#>  Dataset 10 parent   14     73.1  70.04570  3.05430 1.882      1.62298
+#>  Dataset 10 parent   21     65.6  64.01710  1.58290 1.882      0.84111
+#>  Dataset 10 parent   21     65.3  64.01710  1.28290 1.882      0.68170
+#>  Dataset 10 parent   41     55.9  54.98434  0.91566 1.882      0.48656
+#>  Dataset 10 parent   41     54.4  54.98434 -0.58434 1.882     -0.31050
+#>  Dataset 10 parent   63     47.0  49.87137 -2.87137 1.882     -1.52577
+#>  Dataset 10 parent   63     49.3  49.87137 -0.57137 1.882     -0.30361
+#>  Dataset 10 parent   91     44.7  45.06727 -0.36727 1.882     -0.19516
+#>  Dataset 10 parent   91     46.7  45.06727  1.63273 1.882      0.86759
+#>  Dataset 10 parent  120     42.1  40.76402  1.33598 1.882      0.70991
+#>  Dataset 10 parent  120     41.3  40.76402  0.53598 1.882      0.28481
+#>  Dataset 10     A1    8      3.3   4.14599 -0.84599 1.882     -0.44954
+#>  Dataset 10     A1    8      3.4   4.14599 -0.74599 1.882     -0.39640
+#>  Dataset 10     A1   14      3.9   6.08478 -2.18478 1.882     -1.16093
+#>  Dataset 10     A1   14      2.9   6.08478 -3.18478 1.882     -1.69231
+#>  Dataset 10     A1   21      6.4   7.59411 -1.19411 1.882     -0.63452
+#>  Dataset 10     A1   21      7.2   7.59411 -0.39411 1.882     -0.20942
+#>  Dataset 10     A1   41      9.1   9.78292 -0.68292 1.882     -0.36289
+#>  Dataset 10     A1   41      8.5   9.78292 -1.28292 1.882     -0.68171
+#>  Dataset 10     A1   63     11.7  10.93274  0.76726 1.882      0.40770
+#>  Dataset 10     A1   63     12.0  10.93274  1.06726 1.882      0.56711
+#>  Dataset 10     A1   91     13.3  11.93986  1.36014 1.882      0.72274
+#>  Dataset 10     A1   91     13.2  11.93986  1.26014 1.882      0.66961
+#>  Dataset 10     A1  120     14.3  12.79238  1.50762 1.882      0.80111
+#>  Dataset 10     A1  120     12.1  12.79238 -0.69238 1.882     -0.36791
+
+# The following takes about 6 minutes
+f_saem_dfop_sfo_deSolve <- saem(f_mmkin["DFOP-SFO", ], solution_type = "deSolve",
+  nbiter.saemix = c(200, 80))
+#> DINTDY-  T (=R1) illegal      
+#> In above message, R1 = 70
+#>  
+#>       T not in interval TCUR - HU (= R1) to TCUR (=R2)      
+#> In above message, R1 = 53.1042, R2 = 56.6326
+#>  
+#> DINTDY-  T (=R1) illegal      
+#> In above message, R1 = 91
+#>  
+#>       T not in interval TCUR - HU (= R1) to TCUR (=R2)      
+#> In above message, R1 = 53.1042, R2 = 56.6326
+#>  
+#> DLSODA-  Trouble in DINTDY.  ITASK = I1, TOUT = R1
+#> In above message, I1 = 1
+#>  
+#> In above message, R1 = 91
+#>  
+#> Error in deSolve::lsoda(y = odeini, times = outtimes, func = lsoda_func,  : 
+#>   illegal input detected before taking any integration steps - see written message
+
+#anova(
+#  f_saem_dfop_sfo,
+#  f_saem_dfop_sfo_deSolve))
+
+# If the model supports it, we can also use eigenvalue based solutions, which
+# take a similar amount of time
+#f_saem_sfo_sfo_eigen <- saem(f_mmkin["SFO-SFO", ], solution_type = "eigen",
+#  control = list(nbiter.saemix = c(200, 80), nbdisplay = 10))
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/saem.mmkin.html b/docs/dev/reference/saem.mmkin.html new file mode 100644 index 00000000..fb5a153f --- /dev/null +++ b/docs/dev/reference/saem.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/saemix_data.html b/docs/dev/reference/saemix_data.html new file mode 100644 index 00000000..fb5a153f --- /dev/null +++ b/docs/dev/reference/saemix_data.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/saemix_model.html b/docs/dev/reference/saemix_model.html new file mode 100644 index 00000000..fb5a153f --- /dev/null +++ b/docs/dev/reference/saemix_model.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/schaefer07_complex_case-1.png b/docs/dev/reference/schaefer07_complex_case-1.png new file mode 100644 index 00000000..4a44d324 Binary files /dev/null and b/docs/dev/reference/schaefer07_complex_case-1.png differ diff --git a/docs/dev/reference/schaefer07_complex_case.html b/docs/dev/reference/schaefer07_complex_case.html new file mode 100644 index 00000000..7b54053f --- /dev/null +++ b/docs/dev/reference/schaefer07_complex_case.html @@ -0,0 +1,175 @@ + +Metabolism data set used for checking the software quality of KinGUI — schaefer07_complex_case • mkin + Skip to contents + + +
+
+
+ +
+

This dataset was used for a comparison of KinGUI and ModelMaker to check the + software quality of KinGUI in the original publication (Schäfer et al., 2007). + The results from the fitting are also included.

+
+ +
+

Usage

+
schaefer07_complex_case
+
+ +
+

Format

+

The data set is a data frame with 8 observations on the following 6 variables.

time
+

a numeric vector

+ +
parent
+

a numeric vector

+ +
A1
+

a numeric vector

+ +
B1
+

a numeric vector

+ +
C1
+

a numeric vector

+ +
A2
+

a numeric vector

+ + +

The results are a data frame with 14 results for different parameter values

+
+
+

References

+

Schäfer D, Mikolasch B, Rainbird P and Harvey B (2007). KinGUI: a new kinetic + software tool for evaluations according to FOCUS degradation kinetics. In: Del + Re AAM, Capri E, Fragoulis G and Trevisan M (Eds.). Proceedings of the XIII + Symposium Pesticide Chemistry, Piacenza, 2007, p. 916-923.

+
+ +
+

Examples

+
data <- mkin_wide_to_long(schaefer07_complex_case, time = "time")
+model <- mkinmod(
+  parent = list(type = "SFO", to = c("A1", "B1", "C1"), sink = FALSE),
+  A1 = list(type = "SFO", to = "A2"),
+  B1 = list(type = "SFO"),
+  C1 = list(type = "SFO"),
+  A2 = list(type = "SFO"), use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+  # \dontrun{
+    fit <- mkinfit(model, data, quiet = TRUE)
+    plot(fit)
+
+    endpoints(fit)
+#> $ff
+#>   parent_A1   parent_B1   parent_C1 parent_sink       A1_A2     A1_sink 
+#>   0.3809618   0.1954668   0.4235714   0.0000000   0.4479540   0.5520460 
+#> 
+#> $distimes
+#>            DT50      DT90
+#> parent 13.95078  46.34349
+#> A1     49.75347 165.27745
+#> B1     37.26905 123.80511
+#> C1     11.23129  37.30955
+#> A2     28.50690  94.69789
+#> 
+  # }
+ # Compare with the results obtained in the original publication
+ print(schaefer07_complex_results)
+#>         compound          parameter  KinGUI ModelMaker deviation
+#> 1         parent   degradation rate  0.0496     0.0506       2.0
+#> 2         parent               DT50 13.9900    13.6900       2.2
+#> 3  metabolite A1 formation fraction  0.3803     0.3696       2.9
+#> 4  metabolite A1   degradation rate  0.0139     0.0136       2.2
+#> 5  metabolite A1               DT50 49.9600    50.8900       1.8
+#> 6  metabolite B1 formation fraction  0.1866     0.1818       2.6
+#> 7  metabolite B1   degradation rate  0.0175     0.0172       1.7
+#> 8  metabolite B1               DT50 39.6100    40.2400       1.6
+#> 9  metabolite C1 formation fraction  0.4331     0.4486       3.5
+#> 10 metabolite C1   degradation rate  0.0638     0.0700       8.9
+#> 11 metabolite C1               DT50 10.8700     9.9000       9.8
+#> 12 metabolite A2 formation fraction  0.4529     0.4559       0.7
+#> 13 metabolite A2   degradation rate  0.0245     0.0244       0.4
+#> 14 metabolite A2               DT50 28.2400    28.4500       0.7
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/schaefer07_complex_results.html b/docs/dev/reference/schaefer07_complex_results.html new file mode 100644 index 00000000..d2396bcf --- /dev/null +++ b/docs/dev/reference/schaefer07_complex_results.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/set_nd_nq.html b/docs/dev/reference/set_nd_nq.html new file mode 100644 index 00000000..c282b58d --- /dev/null +++ b/docs/dev/reference/set_nd_nq.html @@ -0,0 +1,234 @@ + +Set non-detects and unquantified values in residue series without replicates — set_nd_nq • mkin + Skip to contents + + +
+
+
+ +
+

This function automates replacing unquantified values in residue time and +depth series. For time series, the function performs part of the residue +processing proposed in the FOCUS kinetics guidance for parent compounds +and metabolites. For two-dimensional residue series over time and depth, +it automates the proposal of Boesten et al (2015).

+
+ +
+

Usage

+
set_nd_nq(res_raw, lod, loq = NA, time_zero_presence = FALSE)
+
+set_nd_nq_focus(
+  res_raw,
+  lod,
+  loq = NA,
+  set_first_sample_nd = TRUE,
+  first_sample_nd_value = 0,
+  ignore_below_loq_after_first_nd = TRUE
+)
+
+ +
+

Arguments

+ + +
res_raw
+

Character vector of a residue time series, or matrix of +residue values with rows representing depth profiles for a specific sampling +time, and columns representing time series of residues at the same depth. +Values below the limit of detection (lod) have to be coded as "nd", values +between the limit of detection and the limit of quantification, if any, have +to be coded as "nq". Samples not analysed have to be coded as "na". All +values that are not "na", "nd" or "nq" have to be coercible to numeric

+ + +
lod
+

Limit of detection (numeric)

+ + +
loq
+

Limit of quantification(numeric). Must be specified if the FOCUS rule to +stop after the first non-detection is to be applied

+ + +
time_zero_presence
+

Do we assume that residues occur at time zero? +This only affects samples from the first sampling time that have been +reported as "nd" (not detected).

+ + +
set_first_sample_nd
+

Should the first sample be set to "first_sample_nd_value" +in case it is a non-detection?

+ + +
first_sample_nd_value
+

Value to be used for the first sample if it is a non-detection

+ + +
ignore_below_loq_after_first_nd
+

Should we ignore values below the LOQ after the first +non-detection that occurs after the quantified values?

+ +
+
+

Value

+

A numeric vector, if a vector was supplied, or a numeric matrix otherwise

+
+
+

Functions

+ +
  • set_nd_nq_focus(): Set non-detects in residue time series according to FOCUS rules

  • +
+
+

References

+

Boesten, J. J. T. I., van der Linden, A. M. A., Beltman, W. H. +J. and Pol, J. W. (2015). Leaching of plant protection products and their +transformation products; Proposals for improving the assessment of leaching +to groundwater in the Netherlands — Version 2. Alterra report 2630, Alterra +Wageningen UR (University & Research centre)

+

FOCUS (2014) Generic Guidance for Estimating Persistence and Degradation +Kinetics from Environmental Fate Studies on Pesticides in EU Registration, Version 1.1, +18 December 2014, p. 251

+
+ +
+

Examples

+
# FOCUS (2014) p. 75/76 and 131/132
+parent_1 <- c(.12, .09, .05, .03, "nd", "nd", "nd", "nd", "nd", "nd")
+set_nd_nq(parent_1, 0.02)
+#>  [1] 0.12 0.09 0.05 0.03 0.01   NA   NA   NA   NA   NA
+parent_2 <- c(.12, .09, .05, .03, "nd", "nd", .03, "nd", "nd", "nd")
+set_nd_nq(parent_2, 0.02)
+#>  [1] 0.12 0.09 0.05 0.03 0.01 0.01 0.03 0.01   NA   NA
+set_nd_nq_focus(parent_2, 0.02, loq = 0.05)
+#>  [1] 0.12 0.09 0.05 0.03 0.01   NA   NA   NA   NA   NA
+parent_3 <- c(.12, .09, .05, .03, "nd", "nd", .06, "nd", "nd", "nd")
+set_nd_nq(parent_3, 0.02)
+#>  [1] 0.12 0.09 0.05 0.03 0.01 0.01 0.06 0.01   NA   NA
+set_nd_nq_focus(parent_3, 0.02, loq = 0.05)
+#>  [1] 0.12 0.09 0.05 0.03 0.01 0.01 0.06 0.01   NA   NA
+metabolite <- c("nd", "nd", "nd", 0.03, 0.06, 0.10, 0.11, 0.10, 0.09, 0.05, 0.03, "nd", "nd")
+set_nd_nq(metabolite, 0.02)
+#>  [1]   NA   NA 0.01 0.03 0.06 0.10 0.11 0.10 0.09 0.05 0.03 0.01   NA
+set_nd_nq_focus(metabolite, 0.02, 0.05)
+#>  [1] 0.00   NA 0.01 0.03 0.06 0.10 0.11 0.10 0.09 0.05 0.03 0.01   NA
+#
+# Boesten et al. (2015), p. 57/58
+table_8 <- matrix(
+  c(10, 10, rep("nd", 4),
+    10, 10, rep("nq", 2), rep("nd", 2),
+    10, 10, 10, "nq", "nd", "nd",
+    "nq", 10, "nq", rep("nd", 3),
+    "nd", "nq", "nq", rep("nd", 3),
+    rep("nd", 6), rep("nd", 6)),
+  ncol = 6, byrow = TRUE)
+set_nd_nq(table_8, 0.5, 1.5, time_zero_presence = TRUE)
+#>       [,1]  [,2]  [,3] [,4] [,5] [,6]
+#> [1,] 10.00 10.00  0.25 0.25   NA   NA
+#> [2,] 10.00 10.00  1.00 1.00 0.25   NA
+#> [3,] 10.00 10.00 10.00 1.00 0.25   NA
+#> [4,]  1.00 10.00  1.00 0.25   NA   NA
+#> [5,]  0.25  1.00  1.00 0.25   NA   NA
+#> [6,]    NA  0.25  0.25   NA   NA   NA
+#> [7,]    NA    NA    NA   NA   NA   NA
+table_10 <- matrix(
+  c(10, 10, rep("nd", 4),
+    10, 10, rep("nd", 4),
+    10, 10, 10, rep("nd", 3),
+    "nd", 10, rep("nd", 4),
+    rep("nd", 18)),
+  ncol = 6, byrow = TRUE)
+set_nd_nq(table_10, 0.5, time_zero_presence = TRUE)
+#>       [,1]  [,2]  [,3] [,4] [,5] [,6]
+#> [1,] 10.00 10.00  0.25   NA   NA   NA
+#> [2,] 10.00 10.00  0.25   NA   NA   NA
+#> [3,] 10.00 10.00 10.00 0.25   NA   NA
+#> [4,]  0.25 10.00  0.25   NA   NA   NA
+#> [5,]    NA  0.25    NA   NA   NA   NA
+#> [6,]    NA    NA    NA   NA   NA   NA
+#> [7,]    NA    NA    NA   NA   NA   NA
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/set_nd_nq_focus.html b/docs/dev/reference/set_nd_nq_focus.html new file mode 100644 index 00000000..7a1908a6 --- /dev/null +++ b/docs/dev/reference/set_nd_nq_focus.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/sigma_twocomp-1.png b/docs/dev/reference/sigma_twocomp-1.png new file mode 100644 index 00000000..89500ee7 Binary files /dev/null and b/docs/dev/reference/sigma_twocomp-1.png differ diff --git a/docs/dev/reference/sigma_twocomp.html b/docs/dev/reference/sigma_twocomp.html new file mode 100644 index 00000000..12af9e8a --- /dev/null +++ b/docs/dev/reference/sigma_twocomp.html @@ -0,0 +1,169 @@ + +Two-component error model — sigma_twocomp • mkin + Skip to contents + + +
+
+
+ +
+

Function describing the standard deviation of the measurement error in +dependence of the measured value \(y\):

+
+ +
+

Usage

+
sigma_twocomp(y, sigma_low, rsd_high)
+
+ +
+

Arguments

+ + +
y
+

The magnitude of the observed value

+ + +
sigma_low
+

The asymptotic minimum of the standard deviation for low +observed values

+ + +
rsd_high
+

The coefficient describing the increase of the standard +deviation with the magnitude of the observed value

+ +
+
+

Value

+

The standard deviation of the response variable.

+
+
+

Details

+

$$\sigma = \sqrt{ \sigma_{low}^2 + y^2 * {rsd}_{high}^2}$$ sigma = +sqrt(sigma_low^2 + y^2 * rsd_high^2)

+

This is the error model used for example by Werner et al. (1978). The model +proposed by Rocke and Lorenzato (1995) can be written in this form as well, +but assumes approximate lognormal distribution of errors for high values of +y.

+
+
+

References

+

Werner, Mario, Brooks, Samuel H., and Knott, Lancaster B. (1978) +Additive, Multiplicative, and Mixed Analytical Errors. Clinical Chemistry +24(11), 1895-1898.

+

Rocke, David M. and Lorenzato, Stefan (1995) A two-component model for +measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+

Ranke J and Meinecke S (2019) Error Models for the Kinetic Evaluation of Chemical +Degradation Data. Environments 6(12) 124 +doi:10.3390/environments6120124 +.

+
+ +
+

Examples

+
times <- c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+d_pred <- data.frame(time = times, parent = 100 * exp(- 0.03 * times))
+set.seed(123456)
+d_syn <- add_err(d_pred, function(y) sigma_twocomp(y, 1, 0.07),
+  reps = 2, n = 1)[[1]]
+f_nls <- nls(value ~ SSasymp(time, 0, parent_0, lrc), data = d_syn,
+ start = list(parent_0 = 100, lrc = -3))
+library(nlme)
+f_gnls <- gnls(value ~ SSasymp(time, 0, parent_0, lrc),
+  data = d_syn, na.action = na.omit,
+  start = list(parent_0 = 100, lrc = -3))
+if (length(findFunction("varConstProp")) > 0) {
+  f_gnls_tc <- update(f_gnls, weights = varConstProp())
+  f_gnls_tc_sf <- update(f_gnls_tc, control = list(sigma = 1))
+}
+f_mkin <- mkinfit("SFO", d_syn, error_model = "const", quiet = TRUE)
+f_mkin_tc <- mkinfit("SFO", d_syn, error_model = "tc", quiet = TRUE)
+plot_res(f_mkin_tc, standardized = TRUE)
+
+AIC(f_nls, f_gnls, f_gnls_tc, f_gnls_tc_sf, f_mkin, f_mkin_tc)
+#>              df      AIC
+#> f_nls         3 114.4817
+#> f_gnls        3 114.4817
+#> f_gnls_tc     5 103.6447
+#> f_gnls_tc_sf  4 101.6447
+#> f_mkin        3 114.4817
+#> f_mkin_tc     4 101.6446
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/status.html b/docs/dev/reference/status.html new file mode 100644 index 00000000..e6388137 --- /dev/null +++ b/docs/dev/reference/status.html @@ -0,0 +1,145 @@ + +Method to get status information for fit array objects — status • mkin + Skip to contents + + +
+
+
+ +
+

Method to get status information for fit array objects

+
+ +
+

Usage

+
status(object, ...)
+
+# S3 method for class 'mmkin'
+status(object, ...)
+
+# S3 method for class 'status.mmkin'
+print(x, ...)
+
+# S3 method for class 'mhmkin'
+status(object, ...)
+
+# S3 method for class 'status.mhmkin'
+print(x, ...)
+
+ +
+

Arguments

+ + +
object
+

The object to investigate

+ + +
...
+

For potential future extensions

+ + +
x
+

The object to be printed

+ +
+
+

Value

+

An object with the same dimensions as the fit array +suitable printing method.

+
+ +
+

Examples

+
# \dontrun{
+fits <- mmkin(
+  c("SFO", "FOMC"),
+  list("FOCUS A" = FOCUS_2006_A,
+       "FOCUS B" = FOCUS_2006_C),
+  quiet = TRUE)
+status(fits)
+#>       dataset
+#> model  FOCUS A FOCUS B
+#>   SFO  OK      OK     
+#>   FOMC C       OK     
+#> 
+#> C: Optimisation did not converge:
+#> false convergence (8)
+#> OK: No warnings
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/status.mhmkin.html b/docs/dev/reference/status.mhmkin.html new file mode 100644 index 00000000..9451cf16 --- /dev/null +++ b/docs/dev/reference/status.mhmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/status.mmkin.html b/docs/dev/reference/status.mmkin.html new file mode 100644 index 00000000..9451cf16 --- /dev/null +++ b/docs/dev/reference/status.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/summary.mkinfit.html b/docs/dev/reference/summary.mkinfit.html new file mode 100644 index 00000000..63a08d05 --- /dev/null +++ b/docs/dev/reference/summary.mkinfit.html @@ -0,0 +1,290 @@ + +Summary method for class "mkinfit" — summary.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

Lists model equations, initial parameter values, optimised parameters with +some uncertainty statistics, the chi2 error levels calculated according to +FOCUS guidance (2006) as defined therein, formation fractions, DT50 values +and optionally the data, consisting of observed, predicted and residual +values.

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+summary(object, data = TRUE, distimes = TRUE, alpha = 0.05, ...)
+
+# S3 method for class 'summary.mkinfit'
+print(x, digits = max(3, getOption("digits") - 3), ...)
+
+ +
+

Arguments

+ + +
object
+

an object of class mkinfit.

+ + +
data
+

logical, indicating whether the data should be included in the +summary.

+ + +
distimes
+

logical, indicating whether DT50 and DT90 values should be +included.

+ + +
alpha
+

error level for confidence interval estimation from t +distribution

+ + +
...
+

optional arguments passed to methods like print.

+ + +
x
+

an object of class summary.mkinfit.

+ + +
digits
+

Number of digits to use for printing

+ +
+
+

Value

+

The summary function returns a list with components, among others

+
version, Rversion
+

The mkin and R versions used

+ +
date.fit, date.summary
+

The dates where the fit and the summary were +produced

+ +
diffs
+

The differential equations used in the model

+ +
use_of_ff
+

Was maximum or minimum use made of formation fractions

+ +
bpar
+

Optimised and backtransformed +parameters

+ +
data
+

The data (see Description above).

+ +
start
+

The starting values and bounds, if applicable, for optimised +parameters.

+ +
fixed
+

The values of fixed parameters.

+ +
errmin
+

The chi2 error levels for +each observed variable.

+ +
bparms.ode
+

All backtransformed ODE +parameters, for use as starting parameters for related models.

+ +
errparms
+

Error model parameters.

+ +
ff
+

The estimated formation fractions derived from the fitted +model.

+ +
distimes
+

The DT50 and DT90 values for each observed variable.

+ +
SFORB
+

If applicable, eigenvalues and fractional eigenvector component +g of SFORB systems in the model.

+ +

The print method is called for its side effect, i.e. printing the summary.

+
+
+

References

+

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+  summary(mkinfit("SFO", FOCUS_2006_A, quiet = TRUE))
+#> mkin version used for fitting:    1.2.10 
+#> R version used for fitting:       4.4.2 
+#> Date of fit:     Fri Feb 14 07:34:16 2025 
+#> Date of summary: Fri Feb 14 07:34:16 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - k_parent * parent
+#> 
+#> Model predictions using solution type analytical 
+#> 
+#> Fitted using 131 model solutions performed in 0.009 s
+#> 
+#> Error model: Constant variance 
+#> 
+#> Error model algorithm: OLS 
+#> 
+#> Starting values for parameters to be optimised:
+#>           value   type
+#> parent_0 101.24  state
+#> k_parent   0.10 deparm
+#> 
+#> Starting values for the transformed parameters actually optimised:
+#>                   value lower upper
+#> parent_0     101.240000  -Inf   Inf
+#> log_k_parent  -2.302585  -Inf   Inf
+#> 
+#> Fixed parameter values:
+#> None
+#> 
+#> Results:
+#> 
+#>        AIC     BIC    logLik
+#>   55.28197 55.5203 -24.64099
+#> 
+#> Optimised, transformed parameters with symmetric confidence intervals:
+#>              Estimate Std. Error  Lower   Upper
+#> parent_0      109.200    3.70400 99.630 118.700
+#> log_k_parent   -3.291    0.09176 -3.527  -3.055
+#> sigma           5.266    1.31600  1.882   8.649
+#> 
+#> Parameter correlation:
+#>               parent_0 log_k_parent     sigma
+#> parent_0     1.000e+00    5.428e-01 1.642e-07
+#> log_k_parent 5.428e-01    1.000e+00 2.507e-07
+#> sigma        1.642e-07    2.507e-07 1.000e+00
+#> 
+#> Backtransformed parameters:
+#> Confidence intervals for internally transformed parameters are asymmetric.
+#> t-test (unrealistically) based on the assumption of normal distribution
+#> for estimators of untransformed parameters.
+#>           Estimate t value    Pr(>t)   Lower     Upper
+#> parent_0 109.20000   29.47 4.218e-07 99.6300 118.70000
+#> k_parent   0.03722   10.90 5.650e-05  0.0294   0.04712
+#> sigma      5.26600    4.00 5.162e-03  1.8820   8.64900
+#> 
+#> FOCUS Chi2 error levels in percent:
+#>          err.min n.optim df
+#> All data   8.385       2  6
+#> parent     8.385       2  6
+#> 
+#> Estimated disappearance times:
+#>         DT50  DT90
+#> parent 18.62 61.87
+#> 
+#> Data:
+#>  time variable observed predicted residual
+#>     0   parent   101.24   109.153  -7.9132
+#>     3   parent    99.27    97.622   1.6484
+#>     7   parent    90.11    84.119   5.9913
+#>    14   parent    72.19    64.826   7.3641
+#>    30   parent    29.71    35.738  -6.0283
+#>    62   parent     5.98    10.862  -4.8818
+#>    90   parent     1.54     3.831  -2.2911
+#>   118   parent     0.39     1.351  -0.9613
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/summary.mmkin.html b/docs/dev/reference/summary.mmkin.html new file mode 100644 index 00000000..dad19e59 --- /dev/null +++ b/docs/dev/reference/summary.mmkin.html @@ -0,0 +1,155 @@ + +Summary method for class "mmkin" — summary.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Shows status information on the mkinfit objects contained in the object +and gives an overview of ill-defined parameters calculated by illparms.

+
+ +
+

Usage

+
# S3 method for class 'mmkin'
+summary(object, conf.level = 0.95, ...)
+
+# S3 method for class 'summary.mmkin'
+print(x, digits = max(3, getOption("digits") - 3), ...)
+
+ +
+

Arguments

+ + +
object
+

an object of class mmkin

+ + +
conf.level
+

confidence level for testing parameters

+ + +
...
+

optional arguments passed to methods like print.

+ + +
x
+

an object of class summary.mmkin.

+ + +
digits
+

number of digits to use for printing

+ +
+ +
+

Examples

+

+fits <- mmkin(
+  c("SFO", "FOMC"),
+  list("FOCUS A" = FOCUS_2006_A,
+       "FOCUS C" = FOCUS_2006_C),
+  quiet = TRUE, cores = 1)
+#> Warning: Optimisation did not converge:
+#> false convergence (8)
+  summary(fits)
+#> Error model: Constant variance 
+#> Fitted in 0.512 s
+#> 
+#> Status:
+#>       dataset
+#> model  FOCUS A FOCUS C
+#>   SFO  OK      OK     
+#>   FOMC C       OK     
+#> 
+#> C: Optimisation did not converge:
+#> false convergence (8)
+#> OK: No warnings
+#> 
+#> Ill-defined parameters:
+#>       dataset
+#> model  FOCUS A                      FOCUS C
+#>   SFO                                      
+#>   FOMC parent_0, alpha, beta, sigma        
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/summary.nlme.mmkin.html b/docs/dev/reference/summary.nlme.mmkin.html new file mode 100644 index 00000000..dd4c4771 --- /dev/null +++ b/docs/dev/reference/summary.nlme.mmkin.html @@ -0,0 +1,391 @@ + +Summary method for class "nlme.mmkin" — summary.nlme.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Lists model equations, initial parameter values, optimised parameters +for fixed effects (population), random effects (deviations from the +population mean) and residual error model, as well as the resulting +endpoints such as formation fractions and DT50 values. Optionally +(default is FALSE), the data are listed in full.

+
+ +
+

Usage

+
# S3 method for class 'nlme.mmkin'
+summary(
+  object,
+  data = FALSE,
+  verbose = FALSE,
+  distimes = TRUE,
+  alpha = 0.05,
+  ...
+)
+
+# S3 method for class 'summary.nlme.mmkin'
+print(x, digits = max(3, getOption("digits") - 3), verbose = x$verbose, ...)
+
+ +
+

Arguments

+ + +
object
+

an object of class nlme.mmkin

+ + +
data
+

logical, indicating whether the full data should be included in +the summary.

+ + +
verbose
+

Should the summary be verbose?

+ + +
distimes
+

logical, indicating whether DT50 and DT90 values should be +included.

+ + +
alpha
+

error level for confidence interval estimation from the t +distribution

+ + +
...
+

optional arguments passed to methods like print.

+ + +
x
+

an object of class summary.nlme.mmkin

+ + +
digits
+

Number of digits to use for printing

+ +
+
+

Value

+

The summary function returns a list based on the nlme object +obtained in the fit, with at least the following additional components

+
nlmeversion, mkinversion, Rversion
+

The nlme, mkin and R versions used

+ +
date.fit, date.summary
+

The dates where the fit and the summary were +produced

+ +
diffs
+

The differential equations used in the degradation model

+ +
use_of_ff
+

Was maximum or minimum use made of formation fractions

+ +
data
+

The data

+ +
confint_trans
+

Transformed parameters as used in the optimisation, with confidence intervals

+ +
confint_back
+

Backtransformed parameters, with confidence intervals if available

+ +
ff
+

The estimated formation fractions derived from the fitted +model.

+ +
distimes
+

The DT50 and DT90 values for each observed variable.

+ +
SFORB
+

If applicable, eigenvalues of SFORB components of the model.

+ +

The print method is called for its side effect, i.e. printing the summary.

+
+
+

Author

+

Johannes Ranke for the mkin specific parts +José Pinheiro and Douglas Bates for the components inherited from nlme

+
+ +
+

Examples

+

+# Generate five datasets following SFO kinetics
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+dt50_sfo_in_pop <- 50
+k_in_pop <- log(2) / dt50_sfo_in_pop
+set.seed(1234)
+k_in <- rlnorm(5, log(k_in_pop), 0.5)
+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)
+names(ds_sfo_mean) <- paste("ds", 1:5)
+
+set.seed(12345)
+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]]
+})
+
+# \dontrun{
+# Evaluate using mmkin and nlme
+library(nlme)
+f_mmkin <- mmkin("SFO", ds_sfo_syn, quiet = TRUE, error_model = "tc", cores = 1)
+#> Warning: Optimisation did not converge:
+#> iteration limit reached without convergence (10)
+f_nlme <- nlme(f_mmkin)
+summary(f_nlme, data = TRUE)
+#> nlme version used for fitting:      3.1.166 
+#> mkin version used for pre-fitting:  1.2.10 
+#> R version used for fitting:         4.4.2 
+#> Date of fit:     Fri Feb 14 07:34:18 2025 
+#> Date of summary: Fri Feb 14 07:34:18 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - k_parent * parent
+#> 
+#> Data:
+#> 90 observations of 1 variable(s) grouped in 5 datasets
+#> 
+#> Model predictions using solution type analytical 
+#> 
+#> Fitted in 0.187 s using 4 iterations
+#> 
+#> Variance model: Two-component variance function 
+#> 
+#> Mean of starting values for individual parameters:
+#>     parent_0 log_k_parent 
+#>      101.569       -4.454 
+#> 
+#> Fixed degradation parameter values:
+#> None
+#> 
+#> Results:
+#> 
+#>     AIC   BIC logLik
+#>   584.5 599.5 -286.2
+#> 
+#> Optimised, transformed parameters with symmetric confidence intervals:
+#>               lower    est.   upper
+#> parent_0     99.371 101.592 103.814
+#> log_k_parent -4.973  -4.449  -3.926
+#> 
+#> Correlation: 
+#>              parnt_0
+#> log_k_parent 0.0507 
+#> 
+#> Random effects:
+#>  Formula: list(parent_0 ~ 1, log_k_parent ~ 1)
+#>  Level: ds
+#>  Structure: Diagonal
+#>          parent_0 log_k_parent Residual
+#> StdDev: 6.921e-05       0.5863        1
+#> 
+#> Variance function:
+#>  Structure: Constant plus proportion of variance covariate
+#>  Formula: ~fitted(.) 
+#>  Parameter estimates:
+#>        const         prop 
+#> 0.0001208313 0.0789967985 
+#> 
+#> Backtransformed parameters with asymmetric confidence intervals:
+#>              lower      est.     upper
+#> parent_0 99.370882 101.59243 103.81398
+#> k_parent  0.006923   0.01168   0.01972
+#> 
+#> Estimated disappearance times:
+#>         DT50  DT90
+#> parent 59.32 197.1
+#> 
+#> Data:
+#>    ds   name time observed predicted  residual    std standardized
+#>  ds 1 parent    0    104.1   101.592   2.50757 8.0255     0.312451
+#>  ds 1 parent    0    105.0   101.592   3.40757 8.0255     0.424594
+#>  ds 1 parent    1     98.5   100.796  -2.29571 7.9625    -0.288313
+#>  ds 1 parent    1     96.1   100.796  -4.69571 7.9625    -0.589725
+#>  ds 1 parent    3    101.9    99.221   2.67904 7.8381     0.341796
+#>  ds 1 parent    3     85.2    99.221 -14.02096 7.8381    -1.788812
+#>  ds 1 parent    7     99.1    96.145   2.95512 7.5951     0.389081
+#>  ds 1 parent    7     93.0    96.145  -3.14488 7.5951    -0.414065
+#>  ds 1 parent   14     88.1    90.989  -2.88944 7.1879    -0.401987
+#>  ds 1 parent   14     84.1    90.989  -6.88944 7.1879    -0.958480
+#>  ds 1 parent   28     80.2    81.493  -1.29305 6.4377    -0.200857
+#>  ds 1 parent   28     91.3    81.493   9.80695 6.4377     1.523364
+#>  ds 1 parent   60     65.1    63.344   1.75642 5.0039     0.351008
+#>  ds 1 parent   60     65.8    63.344   2.45642 5.0039     0.490898
+#>  ds 1 parent   90     47.8    50.018  -2.21764 3.9512    -0.561252
+#>  ds 1 parent   90     53.5    50.018   3.48236 3.9512     0.881335
+#>  ds 1 parent  120     37.6    39.495  -1.89515 3.1200    -0.607423
+#>  ds 1 parent  120     39.3    39.495  -0.19515 3.1200    -0.062549
+#>  ds 2 parent    0    107.9   101.592   6.30757 8.0255     0.785943
+#>  ds 2 parent    0    102.1   101.592   0.50757 8.0255     0.063245
+#>  ds 2 parent    1    103.8   100.058   3.74159 7.9043     0.473361
+#>  ds 2 parent    1    108.6   100.058   8.54159 7.9043     1.080626
+#>  ds 2 parent    3     91.0    97.060  -6.05952 7.6674    -0.790297
+#>  ds 2 parent    3     84.9    97.060 -12.15952 7.6674    -1.585874
+#>  ds 2 parent    7     79.3    91.329 -12.02867 7.2147    -1.667251
+#>  ds 2 parent    7    100.9    91.329   9.57133 7.2147     1.326647
+#>  ds 2 parent   14     77.3    82.102  -4.80185 6.4858    -0.740366
+#>  ds 2 parent   14     83.5    82.102   1.39815 6.4858     0.215571
+#>  ds 2 parent   28     66.8    66.351   0.44945 5.2415     0.085748
+#>  ds 2 parent   28     63.3    66.351  -3.05055 5.2415    -0.582002
+#>  ds 2 parent   60     40.8    40.775   0.02474 3.2211     0.007679
+#>  ds 2 parent   60     44.8    40.775   4.02474 3.2211     1.249485
+#>  ds 2 parent   90     27.8    25.832   1.96762 2.0407     0.964198
+#>  ds 2 parent   90     27.0    25.832   1.16762 2.0407     0.572171
+#>  ds 2 parent  120     15.2    16.366  -1.16561 1.2928    -0.901595
+#>  ds 2 parent  120     15.5    16.366  -0.86561 1.2928    -0.669547
+#>  ds 3 parent    0     97.7   101.592  -3.89243 8.0255    -0.485009
+#>  ds 3 parent    0     88.2   101.592 -13.39243 8.0255    -1.668740
+#>  ds 3 parent    1    109.9    99.218  10.68196 7.8379     1.362858
+#>  ds 3 parent    1     97.8    99.218  -1.41804 7.8379    -0.180921
+#>  ds 3 parent    3    100.5    94.634   5.86555 7.4758     0.784603
+#>  ds 3 parent    3     77.4    94.634 -17.23445 7.4758    -2.305360
+#>  ds 3 parent    7     78.3    86.093  -7.79273 6.8011    -1.145813
+#>  ds 3 parent    7     90.3    86.093   4.20727 6.8011     0.618620
+#>  ds 3 parent   14     76.0    72.958   3.04222 5.7634     0.527848
+#>  ds 3 parent   14     79.1    72.958   6.14222 5.7634     1.065722
+#>  ds 3 parent   28     46.0    52.394  -6.39404 4.1390    -1.544842
+#>  ds 3 parent   28     53.4    52.394   1.00596 4.1390     0.243046
+#>  ds 3 parent   60     25.1    24.582   0.51786 1.9419     0.266676
+#>  ds 3 parent   60     21.4    24.582  -3.18214 1.9419    -1.638664
+#>  ds 3 parent   90     11.0    12.092  -1.09202 0.9552    -1.143199
+#>  ds 3 parent   90     14.2    12.092   2.10798 0.9552     2.206777
+#>  ds 3 parent  120      5.8     5.948  -0.14810 0.4699    -0.315178
+#>  ds 3 parent  120      6.1     5.948   0.15190 0.4699     0.323282
+#>  ds 4 parent    0     95.3   101.592  -6.29243 8.0255    -0.784057
+#>  ds 4 parent    0    102.0   101.592   0.40757 8.0255     0.050784
+#>  ds 4 parent    1    104.4   101.125   3.27549 7.9885     0.410025
+#>  ds 4 parent    1    105.4   101.125   4.27549 7.9885     0.535205
+#>  ds 4 parent    3    113.7   100.195  13.50487 7.9151     1.706218
+#>  ds 4 parent    3     82.3   100.195 -17.89513 7.9151    -2.260886
+#>  ds 4 parent    7     98.1    98.362  -0.26190 7.7703    -0.033706
+#>  ds 4 parent    7     87.8    98.362 -10.56190 7.7703    -1.359270
+#>  ds 4 parent   14     97.9    95.234   2.66590 7.5232     0.354357
+#>  ds 4 parent   14    104.8    95.234   9.56590 7.5232     1.271521
+#>  ds 4 parent   28     85.0    89.274  -4.27372 7.0523    -0.606001
+#>  ds 4 parent   28     77.2    89.274 -12.07372 7.0523    -1.712017
+#>  ds 4 parent   60     82.2    77.013   5.18661 6.0838     0.852526
+#>  ds 4 parent   60     86.1    77.013   9.08661 6.0838     1.493571
+#>  ds 4 parent   90     70.5    67.053   3.44692 5.2970     0.650733
+#>  ds 4 parent   90     61.7    67.053  -5.35308 5.2970    -1.010591
+#>  ds 4 parent  120     60.0    58.381   1.61905 4.6119     0.351058
+#>  ds 4 parent  120     56.4    58.381  -1.98095 4.6119    -0.429530
+#>  ds 5 parent    0     92.6   101.592  -8.99243 8.0255    -1.120485
+#>  ds 5 parent    0    116.5   101.592  14.90757 8.0255     1.857531
+#>  ds 5 parent    1    108.0    99.914   8.08560 7.8929     1.024413
+#>  ds 5 parent    1    104.9    99.914   4.98560 7.8929     0.631655
+#>  ds 5 parent    3    100.5    96.641   3.85898 7.6343     0.505477
+#>  ds 5 parent    3     89.5    96.641  -7.14102 7.6343    -0.935383
+#>  ds 5 parent    7     91.7    90.412   1.28752 7.1423     0.180267
+#>  ds 5 parent    7     95.1    90.412   4.68752 7.1423     0.656304
+#>  ds 5 parent   14     82.2    80.463   1.73715 6.3563     0.273295
+#>  ds 5 parent   14     84.5    80.463   4.03715 6.3563     0.635141
+#>  ds 5 parent   28     60.5    63.728  -3.22788 5.0343    -0.641178
+#>  ds 5 parent   28     72.8    63.728   9.07212 5.0343     1.802062
+#>  ds 5 parent   60     38.3    37.399   0.90061 2.9544     0.304835
+#>  ds 5 parent   60     40.7    37.399   3.30061 2.9544     1.117174
+#>  ds 5 parent   90     22.5    22.692  -0.19165 1.7926    -0.106913
+#>  ds 5 parent   90     20.8    22.692  -1.89165 1.7926    -1.055273
+#>  ds 5 parent  120     13.4    13.768  -0.36790 1.0876    -0.338259
+#>  ds 5 parent  120     13.8    13.768   0.03210 1.0876     0.029517
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/summary.saem.mmkin.html b/docs/dev/reference/summary.saem.mmkin.html new file mode 100644 index 00000000..e6138f37 --- /dev/null +++ b/docs/dev/reference/summary.saem.mmkin.html @@ -0,0 +1,631 @@ + +Summary method for class "saem.mmkin" — summary.saem.mmkin • mkin + Skip to contents + + +
+
+
+ +
+

Lists model equations, initial parameter values, optimised parameters +for fixed effects (population), random effects (deviations from the +population mean) and residual error model, as well as the resulting +endpoints such as formation fractions and DT50 values. Optionally +(default is FALSE), the data are listed in full.

+
+ +
+

Usage

+
# S3 method for class 'saem.mmkin'
+summary(
+  object,
+  data = FALSE,
+  verbose = FALSE,
+  covariates = NULL,
+  covariate_quantile = 0.5,
+  distimes = TRUE,
+  ...
+)
+
+# S3 method for class 'summary.saem.mmkin'
+print(x, digits = max(3, getOption("digits") - 3), verbose = x$verbose, ...)
+
+ +
+

Arguments

+ + +
object
+

an object of class saem.mmkin

+ + +
data
+

logical, indicating whether the full data should be included in +the summary.

+ + +
verbose
+

Should the summary be verbose?

+ + +
covariates
+

Numeric vector with covariate values for all variables in +any covariate models in the object. If given, it overrides 'covariate_quantile'.

+ + +
covariate_quantile
+

This argument only has an effect if the fitted +object has covariate models. If so, the default is to show endpoints +for the median of the covariate values (50th percentile).

+ + +
distimes
+

logical, indicating whether DT50 and DT90 values should be +included.

+ + +
...
+

optional arguments passed to methods like print.

+ + +
x
+

an object of class summary.saem.mmkin

+ + +
digits
+

Number of digits to use for printing

+ +
+
+

Value

+

The summary function returns a list based on the saemix::SaemixObject +obtained in the fit, with at least the following additional components

+
saemixversion, mkinversion, Rversion
+

The saemix, mkin and R versions used

+ +
date.fit, date.summary
+

The dates where the fit and the summary were +produced

+ +
diffs
+

The differential equations used in the degradation model

+ +
use_of_ff
+

Was maximum or minimum use made of formation fractions

+ +
data
+

The data

+ +
confint_trans
+

Transformed parameters as used in the optimisation, with confidence intervals

+ +
confint_back
+

Backtransformed parameters, with confidence intervals if available

+ +
confint_errmod
+

Error model parameters with confidence intervals

+ +
ff
+

The estimated formation fractions derived from the fitted +model.

+ +
distimes
+

The DT50 and DT90 values for each observed variable.

+ +
SFORB
+

If applicable, eigenvalues of SFORB components of the model.

+ +

The print method is called for its side effect, i.e. printing the summary.

+
+
+

Author

+

Johannes Ranke for the mkin specific parts +saemix authors for the parts inherited from saemix.

+
+ +
+

Examples

+
# Generate five datasets following DFOP-SFO kinetics
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "m1"),
+ m1 = mkinsub("SFO"), quiet = TRUE)
+set.seed(1234)
+k1_in <- rlnorm(5, log(0.1), 0.3)
+k2_in <- rlnorm(5, log(0.02), 0.3)
+g_in <- plogis(rnorm(5, qlogis(0.5), 0.3))
+f_parent_to_m1_in <- plogis(rnorm(5, qlogis(0.3), 0.3))
+k_m1_in <- rlnorm(5, log(0.02), 0.3)
+
+pred_dfop_sfo <- function(k1, k2, g, f_parent_to_m1, k_m1) {
+  mkinpredict(dfop_sfo,
+    c(k1 = k1, k2 = k2, g = g, f_parent_to_m1 = f_parent_to_m1, k_m1 = k_m1),
+    c(parent = 100, m1 = 0),
+    sampling_times)
+}
+
+ds_mean_dfop_sfo <- lapply(1:5, function(i) {
+  mkinpredict(dfop_sfo,
+    c(k1 = k1_in[i], k2 = k2_in[i], g = g_in[i],
+      f_parent_to_m1 = f_parent_to_m1_in[i], k_m1 = k_m1_in[i]),
+    c(parent = 100, m1 = 0),
+    sampling_times)
+})
+names(ds_mean_dfop_sfo) <- paste("ds", 1:5)
+
+ds_syn_dfop_sfo <- lapply(ds_mean_dfop_sfo, function(ds) {
+  add_err(ds,
+    sdfunc = function(value) sqrt(1^2 + value^2 * 0.07^2),
+    n = 1)[[1]]
+})
+
+# \dontrun{
+# Evaluate using mmkin and saem
+f_mmkin_dfop_sfo <- mmkin(list(dfop_sfo), ds_syn_dfop_sfo,
+  quiet = TRUE, error_model = "tc", cores = 5)
+f_saem_dfop_sfo <- saem(f_mmkin_dfop_sfo)
+print(f_saem_dfop_sfo)
+#> Kinetic nonlinear mixed-effects model fit by SAEM
+#> Structural model:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> d_m1/dt = + f_parent_to_m1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g)
+#>            * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+#>            exp(-k2 * time))) * parent - k_m1 * m1
+#> 
+#> Data:
+#> 171 observations of 2 variable(s) grouped in 5 datasets
+#> 
+#> Likelihood computed by importance sampling
+#>     AIC   BIC logLik
+#>   810.8 805.4 -391.4
+#> 
+#> Fitted parameters:
+#>                      estimate     lower     upper
+#> parent_0           100.966822  97.90584 104.02780
+#> log_k_m1            -4.076164  -4.17485  -3.97748
+#> f_parent_qlogis     -0.940902  -1.35358  -0.52823
+#> log_k1              -2.363988  -2.71690  -2.01107
+#> log_k2              -4.060016  -4.21743  -3.90260
+#> g_qlogis            -0.029999  -0.44766   0.38766
+#> a.1                  0.876272   0.67790   1.07464
+#> b.1                  0.079594   0.06521   0.09398
+#> SD.parent_0          0.076322 -76.45825  76.61089
+#> SD.log_k_m1          0.005052  -1.08943   1.09953
+#> SD.f_parent_qlogis   0.446968   0.16577   0.72816
+#> SD.log_k1            0.348786   0.09502   0.60255
+#> SD.log_k2            0.147456   0.03111   0.26380
+#> SD.g_qlogis          0.348244   0.02794   0.66854
+illparms(f_saem_dfop_sfo)
+#> [1] "sd(parent_0)" "sd(log_k_m1)"
+f_saem_dfop_sfo_2 <- update(f_saem_dfop_sfo,
+  no_random_effect = c("parent_0", "log_k_m1"))
+illparms(f_saem_dfop_sfo_2)
+intervals(f_saem_dfop_sfo_2)
+#> Approximate 95% confidence intervals
+#> 
+#>  Fixed effects:
+#>                      lower         est.        upper
+#> parent_0       98.04247057 101.09950884 104.15654711
+#> k_m1            0.01528983   0.01687734   0.01862969
+#> f_parent_to_m1  0.20447650   0.27932896   0.36887691
+#> k1              0.06779844   0.09638524   0.13702550
+#> k2              0.01495629   0.01741775   0.02028431
+#> g               0.37669311   0.48368409   0.59219202
+#> 
+#>  Random effects:
+#>                          lower      est.     upper
+#> sd(f_parent_qlogis) 0.16515113 0.4448330 0.7245148
+#> sd(log_k1)          0.08982399 0.3447403 0.5996565
+#> sd(log_k2)          0.02806780 0.1419560 0.2558443
+#> sd(g_qlogis)        0.04908644 0.3801993 0.7113121
+#> 
+#>  
+#>          lower       est.      upper
+#> a.1 0.67993373 0.87630147 1.07266921
+#> b.1 0.06522297 0.07920531 0.09318766
+summary(f_saem_dfop_sfo_2, data = TRUE)
+#> saemix version used for fitting:      3.3 
+#> mkin version used for pre-fitting:  1.2.10 
+#> R version used for fitting:         4.4.2 
+#> Date of fit:     Fri Feb 14 07:34:33 2025 
+#> Date of summary: Fri Feb 14 07:34:33 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
+#>            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
+#>            * parent
+#> d_m1/dt = + f_parent_to_m1 * ((k1 * g * exp(-k1 * time) + k2 * (1 - g)
+#>            * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+#>            exp(-k2 * time))) * parent - k_m1 * m1
+#> 
+#> Data:
+#> 171 observations of 2 variable(s) grouped in 5 datasets
+#> 
+#> Model predictions using solution type analytical 
+#> 
+#> Fitted in 8.903 s
+#> Using 300, 100 iterations and 10 chains
+#> 
+#> Variance model: Two-component variance function 
+#> 
+#> Starting values for degradation parameters:
+#>        parent_0        log_k_m1 f_parent_qlogis          log_k1          log_k2 
+#>       101.65645        -4.05368        -0.94311        -2.35943        -4.07006 
+#>        g_qlogis 
+#>        -0.01133 
+#> 
+#> Fixed degradation parameter values:
+#> None
+#> 
+#> Starting values for random effects (square root of initial entries in omega):
+#>                 parent_0 log_k_m1 f_parent_qlogis log_k1 log_k2 g_qlogis
+#> parent_0           6.742   0.0000          0.0000 0.0000 0.0000    0.000
+#> log_k_m1           0.000   0.2236          0.0000 0.0000 0.0000    0.000
+#> f_parent_qlogis    0.000   0.0000          0.5572 0.0000 0.0000    0.000
+#> log_k1             0.000   0.0000          0.0000 0.8031 0.0000    0.000
+#> log_k2             0.000   0.0000          0.0000 0.0000 0.2931    0.000
+#> g_qlogis           0.000   0.0000          0.0000 0.0000 0.0000    0.807
+#> 
+#> Starting values for error model parameters:
+#> a.1 b.1 
+#>   1   1 
+#> 
+#> Results:
+#> 
+#> Likelihood computed by importance sampling
+#>     AIC   BIC logLik
+#>   806.9 802.2 -391.5
+#> 
+#> Optimised parameters:
+#>                         est.    lower     upper
+#> parent_0           101.09951 98.04247 104.15655
+#> log_k_m1            -4.08178 -4.18057  -3.98300
+#> f_parent_qlogis     -0.94779 -1.35855  -0.53704
+#> log_k1              -2.33940 -2.69122  -1.98759
+#> log_k2              -4.05027 -4.20262  -3.89791
+#> g_qlogis            -0.06529 -0.50361   0.37303
+#> a.1                  0.87630  0.67993   1.07267
+#> b.1                  0.07921  0.06522   0.09319
+#> SD.f_parent_qlogis   0.44483  0.16515   0.72451
+#> SD.log_k1            0.34474  0.08982   0.59966
+#> SD.log_k2            0.14196  0.02807   0.25584
+#> SD.g_qlogis          0.38020  0.04909   0.71131
+#> 
+#> Correlation: 
+#>                 parnt_0 lg_k_m1 f_prnt_ log_k1  log_k2 
+#> log_k_m1        -0.4716                                
+#> f_parent_qlogis -0.2394  0.2617                        
+#> log_k1           0.1677 -0.1566 -0.0659                
+#> log_k2           0.0165  0.0638  0.0045  0.2013        
+#> g_qlogis         0.1118 -0.1118 -0.0340 -0.2324 -0.3419
+#> 
+#> Random effects:
+#>                      est.   lower  upper
+#> SD.f_parent_qlogis 0.4448 0.16515 0.7245
+#> SD.log_k1          0.3447 0.08982 0.5997
+#> SD.log_k2          0.1420 0.02807 0.2558
+#> SD.g_qlogis        0.3802 0.04909 0.7113
+#> 
+#> Variance model:
+#>        est.   lower   upper
+#> a.1 0.87630 0.67993 1.07267
+#> b.1 0.07921 0.06522 0.09319
+#> 
+#> Backtransformed parameters:
+#>                     est.    lower     upper
+#> parent_0       101.09951 98.04247 104.15655
+#> k_m1             0.01688  0.01529   0.01863
+#> f_parent_to_m1   0.27933  0.20448   0.36888
+#> k1               0.09639  0.06780   0.13703
+#> k2               0.01742  0.01496   0.02028
+#> g                0.48368  0.37669   0.59219
+#> 
+#> Resulting formation fractions:
+#>                 ff
+#> parent_m1   0.2793
+#> parent_sink 0.7207
+#> 
+#> Estimated disappearance times:
+#>         DT50   DT90 DT50back DT50_k1 DT50_k2
+#> parent 15.66  94.28    28.38   7.191    39.8
+#> m1     41.07 136.43       NA      NA      NA
+#> 
+#> Data:
+#>    ds   name time observed  predicted  residual    std standardized
+#>  ds 1 parent    0     89.8  1.011e+02 -11.29951 8.0554    -1.402721
+#>  ds 1 parent    0    104.1  1.011e+02   3.00049 8.0554     0.372481
+#>  ds 1 parent    1     88.7  9.624e+01  -7.53600 7.6726    -0.982195
+#>  ds 1 parent    1     95.5  9.624e+01  -0.73600 7.6726    -0.095925
+#>  ds 1 parent    3     81.8  8.736e+01  -5.55672 6.9744    -0.796732
+#>  ds 1 parent    3     94.5  8.736e+01   7.14328 6.9744     1.024217
+#>  ds 1 parent    7     71.5  7.251e+01  -1.00511 5.8093    -0.173019
+#>  ds 1 parent    7     70.3  7.251e+01  -2.20511 5.8093    -0.379585
+#>  ds 1 parent   14     54.2  5.356e+01   0.63921 4.3319     0.147560
+#>  ds 1 parent   14     49.6  5.356e+01  -3.96079 4.3319    -0.914340
+#>  ds 1 parent   28     31.5  3.175e+01  -0.25429 2.6634    -0.095475
+#>  ds 1 parent   28     28.8  3.175e+01  -2.95429 2.6634    -1.109218
+#>  ds 1 parent   60     12.1  1.281e+01  -0.71388 1.3409    -0.532390
+#>  ds 1 parent   60     13.6  1.281e+01   0.78612 1.3409     0.586271
+#>  ds 1 parent   90      6.2  6.405e+00  -0.20462 1.0125    -0.202083
+#>  ds 1 parent   90      8.3  6.405e+00   1.89538 1.0125     1.871910
+#>  ds 1 parent  120      2.2  3.329e+00  -1.12941 0.9151    -1.234165
+#>  ds 1 parent  120      2.4  3.329e+00  -0.92941 0.9151    -1.015615
+#>  ds 1     m1    1      0.3  1.177e+00  -0.87699 0.8812    -0.995168
+#>  ds 1     m1    1      0.2  1.177e+00  -0.97699 0.8812    -1.108644
+#>  ds 1     m1    3      2.2  3.268e+00  -1.06821 0.9137    -1.169063
+#>  ds 1     m1    3      3.0  3.268e+00  -0.26821 0.9137    -0.293536
+#>  ds 1     m1    7      6.5  6.555e+00  -0.05539 1.0186    -0.054377
+#>  ds 1     m1    7      5.0  6.555e+00  -1.55539 1.0186    -1.527022
+#>  ds 1     m1   14     10.2  1.017e+01   0.03108 1.1902     0.026117
+#>  ds 1     m1   14      9.5  1.017e+01  -0.66892 1.1902    -0.562010
+#>  ds 1     m1   28     12.2  1.270e+01  -0.50262 1.3342    -0.376708
+#>  ds 1     m1   28     13.4  1.270e+01   0.69738 1.3342     0.522686
+#>  ds 1     m1   60     11.8  1.078e+01   1.01734 1.2236     0.831403
+#>  ds 1     m1   60     13.2  1.078e+01   2.41734 1.2236     1.975530
+#>  ds 1     m1   90      6.6  7.686e+00  -1.08586 1.0670    -1.017675
+#>  ds 1     m1   90      9.3  7.686e+00   1.61414 1.0670     1.512779
+#>  ds 1     m1  120      3.5  5.205e+00  -1.70467 0.9684    -1.760250
+#>  ds 1     m1  120      5.4  5.205e+00   0.19533 0.9684     0.201701
+#>  ds 2 parent    0    118.0  1.011e+02  16.90049 8.0554     2.098026
+#>  ds 2 parent    0     99.8  1.011e+02  -1.29951 8.0554    -0.161321
+#>  ds 2 parent    1     90.2  9.574e+01  -5.53784 7.6334    -0.725473
+#>  ds 2 parent    1     94.6  9.574e+01  -1.13784 7.6334    -0.149060
+#>  ds 2 parent    3     96.1  8.638e+01   9.72233 6.8975     1.409551
+#>  ds 2 parent    3     78.4  8.638e+01  -7.97767 6.8975    -1.156610
+#>  ds 2 parent    7     77.9  7.194e+01   5.95854 5.7651     1.033547
+#>  ds 2 parent    7     77.7  7.194e+01   5.75854 5.7651     0.998856
+#>  ds 2 parent   14     56.0  5.558e+01   0.42141 4.4885     0.093888
+#>  ds 2 parent   14     54.7  5.558e+01  -0.87859 4.4885    -0.195742
+#>  ds 2 parent   28     36.6  3.852e+01  -1.92382 3.1746    -0.605999
+#>  ds 2 parent   28     36.8  3.852e+01  -1.72382 3.1746    -0.543000
+#>  ds 2 parent   60     22.1  2.108e+01   1.02043 1.8856     0.541168
+#>  ds 2 parent   60     24.7  2.108e+01   3.62043 1.8856     1.920034
+#>  ds 2 parent   90     12.4  1.250e+01  -0.09675 1.3220    -0.073184
+#>  ds 2 parent   90     10.8  1.250e+01  -1.69675 1.3220    -1.283492
+#>  ds 2 parent  120      6.8  7.426e+00  -0.62587 1.0554    -0.593027
+#>  ds 2 parent  120      7.9  7.426e+00   0.47413 1.0554     0.449242
+#>  ds 2     m1    1      1.3  1.417e+00  -0.11735 0.8835    -0.132825
+#>  ds 2     m1    3      3.7  3.823e+00  -0.12301 0.9271    -0.132673
+#>  ds 2     m1    3      4.7  3.823e+00   0.87699 0.9271     0.945909
+#>  ds 2     m1    7      8.1  7.288e+00   0.81180 1.0494     0.773619
+#>  ds 2     m1    7      7.9  7.288e+00   0.61180 1.0494     0.583025
+#>  ds 2     m1   14     10.1  1.057e+01  -0.46957 1.2119    -0.387459
+#>  ds 2     m1   14     10.3  1.057e+01  -0.26957 1.2119    -0.222432
+#>  ds 2     m1   28     10.7  1.234e+01  -1.63555 1.3124    -1.246185
+#>  ds 2     m1   28     12.2  1.234e+01  -0.13555 1.3124    -0.103281
+#>  ds 2     m1   60     10.7  1.065e+01   0.04641 1.2165     0.038151
+#>  ds 2     m1   60     12.5  1.065e+01   1.84641 1.2165     1.517773
+#>  ds 2     m1   90      9.1  8.177e+00   0.92337 1.0896     0.847403
+#>  ds 2     m1   90      7.4  8.177e+00  -0.77663 1.0896    -0.712734
+#>  ds 2     m1  120      6.1  5.966e+00   0.13404 0.9956     0.134631
+#>  ds 2     m1  120      4.5  5.966e+00  -1.46596 0.9956    -1.472460
+#>  ds 3 parent    0    106.2  1.011e+02   5.10049 8.0554     0.633175
+#>  ds 3 parent    0    106.9  1.011e+02   5.80049 8.0554     0.720073
+#>  ds 3 parent    1    107.4  9.365e+01  13.74627 7.4695     1.840332
+#>  ds 3 parent    1     96.1  9.365e+01   2.44627 7.4695     0.327504
+#>  ds 3 parent    3     79.4  8.139e+01  -1.99118 6.5059    -0.306058
+#>  ds 3 parent    3     82.6  8.139e+01   1.20882 6.5059     0.185803
+#>  ds 3 parent    7     63.9  6.445e+01  -0.54666 5.1792    -0.105549
+#>  ds 3 parent    7     62.4  6.445e+01  -2.04666 5.1792    -0.395170
+#>  ds 3 parent   14     51.0  4.830e+01   2.69944 3.9247     0.687800
+#>  ds 3 parent   14     47.1  4.830e+01  -1.20056 3.9247    -0.305896
+#>  ds 3 parent   28     36.1  3.426e+01   1.83885 2.8516     0.644839
+#>  ds 3 parent   28     36.6  3.426e+01   2.33885 2.8516     0.820177
+#>  ds 3 parent   60     20.1  1.968e+01   0.42208 1.7881     0.236053
+#>  ds 3 parent   60     19.8  1.968e+01   0.12208 1.7881     0.068273
+#>  ds 3 parent   90     11.3  1.194e+01  -0.64013 1.2893    -0.496496
+#>  ds 3 parent   90     10.7  1.194e+01  -1.24013 1.2893    -0.961865
+#>  ds 3 parent  120      8.2  7.247e+00   0.95264 1.0476     0.909381
+#>  ds 3 parent  120      7.3  7.247e+00   0.05264 1.0476     0.050254
+#>  ds 3     m1    0      0.8 -2.956e-12   0.80000 0.8763     0.912928
+#>  ds 3     m1    1      1.8  1.757e+00   0.04318 0.8873     0.048666
+#>  ds 3     m1    1      2.3  1.757e+00   0.54318 0.8873     0.612186
+#>  ds 3     m1    3      4.2  4.566e+00  -0.36607 0.9480    -0.386149
+#>  ds 3     m1    3      4.1  4.566e+00  -0.46607 0.9480    -0.491634
+#>  ds 3     m1    7      6.8  8.157e+00  -1.35680 1.0887    -1.246241
+#>  ds 3     m1    7     10.1  8.157e+00   1.94320 1.0887     1.784855
+#>  ds 3     m1   14     11.4  1.085e+01   0.55367 1.2272     0.451182
+#>  ds 3     m1   14     12.8  1.085e+01   1.95367 1.2272     1.592023
+#>  ds 3     m1   28     11.5  1.149e+01   0.01098 1.2633     0.008689
+#>  ds 3     m1   28     10.6  1.149e+01  -0.88902 1.2633    -0.703717
+#>  ds 3     m1   60      7.5  9.295e+00  -1.79500 1.1445    -1.568351
+#>  ds 3     m1   60      8.6  9.295e+00  -0.69500 1.1445    -0.607245
+#>  ds 3     m1   90      7.3  7.017e+00   0.28305 1.0377     0.272775
+#>  ds 3     m1   90      8.1  7.017e+00   1.08305 1.0377     1.043720
+#>  ds 3     m1  120      5.3  5.087e+00   0.21272 0.9645     0.220547
+#>  ds 3     m1  120      3.8  5.087e+00  -1.28728 0.9645    -1.334660
+#>  ds 4 parent    0    104.7  1.011e+02   3.60049 8.0554     0.446965
+#>  ds 4 parent    0     88.3  1.011e+02 -12.79951 8.0554    -1.588930
+#>  ds 4 parent    1     94.2  9.755e+01  -3.35176 7.7762    -0.431030
+#>  ds 4 parent    1     94.6  9.755e+01  -2.95176 7.7762    -0.379591
+#>  ds 4 parent    3     78.1  9.095e+01 -12.85198 7.2570    -1.770981
+#>  ds 4 parent    3     96.5  9.095e+01   5.54802 7.2570     0.764508
+#>  ds 4 parent    7     76.2  7.949e+01  -3.29267 6.3569    -0.517966
+#>  ds 4 parent    7     77.8  7.949e+01  -1.69267 6.3569    -0.266272
+#>  ds 4 parent   14     70.8  6.384e+01   6.95621 5.1321     1.355423
+#>  ds 4 parent   14     67.3  6.384e+01   3.45621 5.1321     0.673445
+#>  ds 4 parent   28     43.1  4.345e+01  -0.35291 3.5515    -0.099370
+#>  ds 4 parent   28     45.1  4.345e+01   1.64709 3.5515     0.463771
+#>  ds 4 parent   60     21.3  2.137e+01  -0.07478 1.9063    -0.039229
+#>  ds 4 parent   60     23.5  2.137e+01   2.12522 1.9063     1.114813
+#>  ds 4 parent   90     11.8  1.205e+01  -0.24925 1.2957    -0.192375
+#>  ds 4 parent   90     12.1  1.205e+01   0.05075 1.2957     0.039168
+#>  ds 4 parent  120      7.0  6.967e+00   0.03315 1.0356     0.032013
+#>  ds 4 parent  120      6.2  6.967e+00  -0.76685 1.0356    -0.740510
+#>  ds 4     m1    0      1.6  1.421e-13   1.60000 0.8763     1.825856
+#>  ds 4     m1    1      0.9  7.250e-01   0.17503 0.8782     0.199310
+#>  ds 4     m1    3      3.7  2.038e+00   1.66201 0.8910     1.865236
+#>  ds 4     m1    3      2.0  2.038e+00  -0.03799 0.8910    -0.042637
+#>  ds 4     m1    7      3.6  4.186e+00  -0.58623 0.9369    -0.625692
+#>  ds 4     m1    7      3.8  4.186e+00  -0.38623 0.9369    -0.412230
+#>  ds 4     m1   14      7.1  6.752e+00   0.34768 1.0266     0.338666
+#>  ds 4     m1   14      6.6  6.752e+00  -0.15232 1.0266    -0.148372
+#>  ds 4     m1   28      9.5  9.034e+00   0.46628 1.1313     0.412159
+#>  ds 4     m1   28      9.3  9.034e+00   0.26628 1.1313     0.235373
+#>  ds 4     m1   60      8.3  8.634e+00  -0.33359 1.1115    -0.300112
+#>  ds 4     m1   60      9.0  8.634e+00   0.36641 1.1115     0.329645
+#>  ds 4     m1   90      6.6  6.671e+00  -0.07091 1.0233    -0.069295
+#>  ds 4     m1   90      7.7  6.671e+00   1.02909 1.0233     1.005691
+#>  ds 4     m1  120      3.7  4.823e+00  -1.12301 0.9559    -1.174763
+#>  ds 4     m1  120      3.5  4.823e+00  -1.32301 0.9559    -1.383979
+#>  ds 5 parent    0    110.4  1.011e+02   9.30049 8.0554     1.154563
+#>  ds 5 parent    0    112.1  1.011e+02  11.00049 8.0554     1.365601
+#>  ds 5 parent    1     93.5  9.440e+01  -0.90098 7.5282    -0.119681
+#>  ds 5 parent    1     91.0  9.440e+01  -3.40098 7.5282    -0.451764
+#>  ds 5 parent    3     71.0  8.287e+01 -11.86698 6.6217    -1.792122
+#>  ds 5 parent    3     89.7  8.287e+01   6.83302 6.6217     1.031907
+#>  ds 5 parent    7     60.4  6.562e+01  -5.22329 5.2711    -0.990936
+#>  ds 5 parent    7     59.1  6.562e+01  -6.52329 5.2711    -1.237566
+#>  ds 5 parent   14     56.5  4.739e+01   9.10588 3.8548     2.362225
+#>  ds 5 parent   14     47.0  4.739e+01  -0.39412 3.8548    -0.102240
+#>  ds 5 parent   28     30.2  3.118e+01  -0.98128 2.6206    -0.374451
+#>  ds 5 parent   28     23.9  3.118e+01  -7.28128 2.6206    -2.778500
+#>  ds 5 parent   60     17.0  1.804e+01  -1.03959 1.6761    -0.620224
+#>  ds 5 parent   60     18.7  1.804e+01   0.66041 1.6761     0.394008
+#>  ds 5 parent   90     11.3  1.165e+01  -0.35248 1.2727    -0.276958
+#>  ds 5 parent   90     11.9  1.165e+01   0.24752 1.2727     0.194488
+#>  ds 5 parent  120      9.0  7.556e+00   1.44368 1.0612     1.360449
+#>  ds 5 parent  120      8.1  7.556e+00   0.54368 1.0612     0.512338
+#>  ds 5     m1    0      0.7 -1.421e-14   0.70000 0.8763     0.798812
+#>  ds 5     m1    1      3.0  3.160e+00  -0.15979 0.9113    -0.175340
+#>  ds 5     m1    1      2.6  3.160e+00  -0.55979 0.9113    -0.614254
+#>  ds 5     m1    3      5.1  8.448e+00  -3.34789 1.1026    -3.036487
+#>  ds 5     m1    3      7.5  8.448e+00  -0.94789 1.1026    -0.859720
+#>  ds 5     m1    7     16.5  1.581e+01   0.68760 1.5286     0.449839
+#>  ds 5     m1    7     19.0  1.581e+01   3.18760 1.5286     2.085373
+#>  ds 5     m1   14     22.9  2.218e+01   0.71983 1.9632     0.366658
+#>  ds 5     m1   14     23.2  2.218e+01   1.01983 1.9632     0.519469
+#>  ds 5     m1   28     22.2  2.425e+01  -2.05105 2.1113    -0.971479
+#>  ds 5     m1   28     24.4  2.425e+01   0.14895 2.1113     0.070552
+#>  ds 5     m1   60     15.5  1.876e+01  -3.25968 1.7250    -1.889646
+#>  ds 5     m1   60     19.8  1.876e+01   1.04032 1.7250     0.603074
+#>  ds 5     m1   90     14.9  1.365e+01   1.25477 1.3914     0.901806
+#>  ds 5     m1   90     14.2  1.365e+01   0.55477 1.3914     0.398714
+#>  ds 5     m1  120     10.9  9.726e+00   1.17443 1.1667     1.006587
+#>  ds 5     m1  120     10.4  9.726e+00   0.67443 1.1667     0.578044
+# Add a correlation between random effects of g and k2
+cov_model_3 <- f_saem_dfop_sfo_2$so@model@covariance.model
+cov_model_3["log_k2", "g_qlogis"] <- 1
+cov_model_3["g_qlogis", "log_k2"] <- 1
+f_saem_dfop_sfo_3 <- update(f_saem_dfop_sfo,
+  covariance.model = cov_model_3)
+intervals(f_saem_dfop_sfo_3)
+#> Approximate 95% confidence intervals
+#> 
+#>  Fixed effects:
+#>                      lower         est.        upper
+#> parent_0       98.42519529 101.51623115 104.60726702
+#> k_m1            0.01505059   0.01662123   0.01835577
+#> f_parent_to_m1  0.20100222   0.27477835   0.36332008
+#> k1              0.07347479   0.10139028   0.13991179
+#> k2              0.01469861   0.01771120   0.02134125
+#> g               0.35506898   0.46263682   0.57379888
+#> 
+#>  Random effects:
+#>                             lower       est.     upper
+#> sd(f_parent_qlogis)    0.16472883  0.4435866 0.7224443
+#> sd(log_k1)             0.05323856  0.2981783 0.5431180
+#> sd(log_k2)             0.05013379  0.1912531 0.3323723
+#> sd(g_qlogis)           0.04710647  0.3997298 0.7523531
+#> corr(log_k2,g_qlogis) -1.31087397 -0.5845703 0.1417334
+#> 
+#>  
+#>          lower       est.      upper
+#> a.1 0.67769608 0.87421677 1.07073746
+#> b.1 0.06525119 0.07925135 0.09325151
+# The correlation does not improve the fit judged by AIC and BIC, although
+# the likelihood is higher with the additional parameter
+anova(f_saem_dfop_sfo, f_saem_dfop_sfo_2, f_saem_dfop_sfo_3)
+#> Data: 171 observations of 2 variable(s) grouped in 5 datasets
+#> 
+#>                   npar    AIC    BIC     Lik
+#> f_saem_dfop_sfo_2   12 806.91 802.23 -391.46
+#> f_saem_dfop_sfo_3   13 807.96 802.88 -390.98
+#> f_saem_dfop_sfo     14 810.83 805.36 -391.41
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/summary_listing.html b/docs/dev/reference/summary_listing.html new file mode 100644 index 00000000..6e1bad37 --- /dev/null +++ b/docs/dev/reference/summary_listing.html @@ -0,0 +1,119 @@ + +Display the output of a summary function according to the output format — summary_listing • mkin + Skip to contents + + +
+
+
+ +
+

This function is intended for use in a R markdown code chunk with the chunk +option results = "asis".

+
+ +
+

Usage

+
summary_listing(object, caption = NULL, label = NULL, clearpage = TRUE)
+
+tex_listing(object, caption = NULL, label = NULL, clearpage = TRUE)
+
+html_listing(object, caption = NULL)
+
+ +
+

Arguments

+ + +
object
+

The object for which the summary is to be listed

+ + +
caption
+

An optional caption

+ + +
label
+

An optional label, ignored in html output

+ + +
clearpage
+

Should a new page be started after the listing? Ignored in html output

+ +
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/synthetic_data_for_UBA_2014-1.png b/docs/dev/reference/synthetic_data_for_UBA_2014-1.png new file mode 100644 index 00000000..c08d231d Binary files /dev/null and b/docs/dev/reference/synthetic_data_for_UBA_2014-1.png differ diff --git a/docs/dev/reference/synthetic_data_for_UBA_2014.html b/docs/dev/reference/synthetic_data_for_UBA_2014.html new file mode 100644 index 00000000..9080c32b --- /dev/null +++ b/docs/dev/reference/synthetic_data_for_UBA_2014.html @@ -0,0 +1,413 @@ + +Synthetic datasets for one parent compound with two metabolites — synthetic_data_for_UBA_2014 • mkin + Skip to contents + + +
+
+
+ +
+

The 12 datasets were generated using four different models and three different + variance components. The four models are either the SFO or the DFOP model with either + two sequential or two parallel metabolites.

+

Variance component 'a' is based on a normal distribution with standard deviation of 3, + Variance component 'b' is also based on a normal distribution, but with a standard deviation of 7. + Variance component 'c' is based on the error model from Rocke and Lorenzato (1995), with the + minimum standard deviation (for small y values) of 0.5, and a proportionality constant of 0.07 + for the increase of the standard deviation with y. Note that this is a simplified version + of the error model proposed by Rocke and Lorenzato (1995), as in their model the error of the + measured values approximates lognormal distribution for high values, whereas we are using + normally distributed error components all along.

+

Initial concentrations for metabolites and all values where adding the variance component resulted + in a value below the assumed limit of detection of 0.1 were set to NA.

+

As an example, the first dataset has the title SFO_lin_a and is based on the SFO model + with two sequential metabolites (linear pathway), with added variance component 'a'.

+

Compare also the code in the example section to see the degradation models.

+
+ +
+

Usage

+
synthetic_data_for_UBA_2014
+
+ +
+

Format

+

A list containing twelve datasets as an R6 class defined by mkinds, + each containing, among others, the following components

title
+

The name of the dataset, e.g. SFO_lin_a

+ +
data
+

A data frame with the data in the form expected by mkinfit

+ + +
+
+

Source

+

Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative + zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452

+

Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for + measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+
+ +
+

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")
+#> 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")
+#> 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")
+#> 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")
+#> 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)
+
+  summary(fit)
+#> mkin version used for fitting:    1.2.10 
+#> R version used for fitting:       4.4.2 
+#> Date of fit:     Fri Feb 14 07:34:43 2025 
+#> Date of summary: Fri Feb 14 07:34:43 2025 
+#> 
+#> Equations:
+#> d_parent/dt = - k_parent * parent
+#> d_M1/dt = + f_parent_to_M1 * k_parent * parent - k_M1 * M1
+#> d_M2/dt = + f_M1_to_M2 * k_M1 * M1 - k_M2 * M2
+#> 
+#> Model predictions using solution type deSolve 
+#> 
+#> Fitted using 848 model solutions performed in 0.17 s
+#> 
+#> Error model: Constant variance 
+#> 
+#> Error model algorithm: OLS 
+#> 
+#> Starting values for parameters to be optimised:
+#>                   value   type
+#> parent_0       101.3500  state
+#> k_parent         0.1000 deparm
+#> k_M1             0.1001 deparm
+#> k_M2             0.1002 deparm
+#> f_parent_to_M1   0.5000 deparm
+#> f_M1_to_M2       0.5000 deparm
+#> 
+#> Starting values for the transformed parameters actually optimised:
+#>                      value lower upper
+#> parent_0        101.350000  -Inf   Inf
+#> log_k_parent     -2.302585  -Inf   Inf
+#> log_k_M1         -2.301586  -Inf   Inf
+#> log_k_M2         -2.300587  -Inf   Inf
+#> f_parent_qlogis   0.000000  -Inf   Inf
+#> f_M1_qlogis       0.000000  -Inf   Inf
+#> 
+#> Fixed parameter values:
+#>      value  type
+#> M1_0     0 state
+#> M2_0     0 state
+#> 
+#> Results:
+#> 
+#>        AIC      BIC    logLik
+#>   188.7274 200.3723 -87.36368
+#> 
+#> Optimised, transformed parameters with symmetric confidence intervals:
+#>                 Estimate Std. Error   Lower    Upper
+#> parent_0        102.1000    1.57000 98.8600 105.3000
+#> log_k_parent     -0.3020    0.03885 -0.3812  -0.2229
+#> log_k_M1         -1.2070    0.07123 -1.3520  -1.0620
+#> log_k_M2         -3.9010    0.06571 -4.0350  -3.7670
+#> f_parent_qlogis   1.2010    0.23530  0.7216   1.6800
+#> f_M1_qlogis       0.9589    0.24890  0.4520   1.4660
+#> sigma             2.2730    0.25740  1.7490   2.7970
+#> 
+#> Parameter correlation:
+#>                   parent_0 log_k_parent   log_k_M1   log_k_M2 f_parent_qlogis
+#> parent_0         1.000e+00    3.933e-01 -1.605e-01  2.819e-02      -4.624e-01
+#> log_k_parent     3.933e-01    1.000e+00 -4.082e-01  7.166e-02      -5.682e-01
+#> log_k_M1        -1.605e-01   -4.082e-01  1.000e+00 -3.929e-01       7.478e-01
+#> 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           -1.377e-08    7.536e-10  1.089e-08 -4.422e-08       7.124e-09
+#>                 f_M1_qlogis      sigma
+#> parent_0          1.614e-01 -1.377e-08
+#> log_k_parent      4.102e-01  7.536e-10
+#> log_k_M1         -8.109e-01  1.089e-08
+#> log_k_M2          5.419e-01 -4.422e-08
+#> f_parent_qlogis  -8.605e-01  7.124e-09
+#> f_M1_qlogis       1.000e+00 -2.685e-08
+#> sigma            -2.685e-08  1.000e+00
+#> 
+#> Backtransformed parameters:
+#> Confidence intervals for internally transformed parameters are asymmetric.
+#> t-test (unrealistically) based on the assumption of normal distribution
+#> for estimators of untransformed parameters.
+#>                 Estimate t value    Pr(>t)    Lower     Upper
+#> parent_0       102.10000  65.000 7.281e-36 98.86000 105.30000
+#> k_parent         0.73930  25.740 2.948e-23  0.68310   0.80020
+#> k_M1             0.29920  14.040 1.577e-15  0.25880   0.34590
+#> k_M2             0.02023  15.220 1.653e-16  0.01769   0.02312
+#> f_parent_to_M1   0.76870  18.370 7.295e-19  0.67300   0.84290
+#> f_M1_to_M2       0.72290  14.500 6.418e-16  0.61110   0.81240
+#> sigma            2.27300   8.832 2.161e-10  1.74900   2.79700
+#> 
+#> FOCUS Chi2 error levels in percent:
+#>          err.min n.optim df
+#> All data   8.454       6 17
+#> parent     8.660       2  6
+#> M1        10.583       2  5
+#> M2         3.586       2  6
+#> 
+#> Resulting formation fractions:
+#>                 ff
+#> parent_M1   0.7687
+#> parent_sink 0.2313
+#> M1_M2       0.7229
+#> M1_sink     0.2771
+#> 
+#> Estimated disappearance times:
+#>           DT50    DT90
+#> parent  0.9376   3.114
+#> M1      2.3170   7.697
+#> M2     34.2689 113.839
+#> 
+#> Data:
+#>  time variable observed  predicted residual
+#>     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
+#>     3   parent      7.6  1.111e+01 -3.50773
+#>     7   parent      1.1  5.772e-01  0.52283
+#>     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.532e-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
+#>     3       M1     39.8  3.937e+01  0.42973
+#>     7       M1     15.1  1.549e+01 -0.38715
+#>     7       M1     17.8  1.549e+01  2.31285
+#>    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.672e-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
+#>     7       M2     42.0  4.192e+01  0.07941
+#>     7       M2     43.1  4.192e+01  1.17941
+#>    14       M2     49.4  4.557e+01  3.83353
+#>    14       M2     44.3  4.557e+01 -1.26647
+#>    28       M2     34.6  3.547e+01 -0.87275
+#>    28       M2     33.0  3.547e+01 -2.47275
+#>    60       M2     18.8  1.858e+01  0.21837
+#>    60       M2     17.6  1.858e+01 -0.98163
+#>    90       M2     10.6  1.013e+01  0.47130
+#>    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
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/test_data_from_UBA_2014-1.png b/docs/dev/reference/test_data_from_UBA_2014-1.png new file mode 100644 index 00000000..db29d16d Binary files /dev/null and b/docs/dev/reference/test_data_from_UBA_2014-1.png differ diff --git a/docs/dev/reference/test_data_from_UBA_2014-2.png b/docs/dev/reference/test_data_from_UBA_2014-2.png new file mode 100644 index 00000000..2bfb77f7 Binary files /dev/null and b/docs/dev/reference/test_data_from_UBA_2014-2.png differ diff --git a/docs/dev/reference/test_data_from_UBA_2014.html b/docs/dev/reference/test_data_from_UBA_2014.html new file mode 100644 index 00000000..0d6b8105 --- /dev/null +++ b/docs/dev/reference/test_data_from_UBA_2014.html @@ -0,0 +1,195 @@ + +Three experimental datasets from two water sediment systems and one soil — test_data_from_UBA_2014 • mkin + Skip to contents + + +
+
+
+ +
+

The datasets were used for the comparative validation of several kinetic evaluation + software packages (Ranke, 2014).

+
+ +
+

Usage

+
test_data_from_UBA_2014
+
+ +
+

Format

+

A list containing three datasets as an R6 class defined by mkinds. + Each dataset has, among others, the following components

title
+

The name of the dataset, e.g. UBA_2014_WS_river

+ +
data
+

A data frame with the data in the form expected by mkinfit

+ + +
+
+

Source

+

Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative + zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452

+
+ +
+

Examples

+
  # \dontrun{
+  # This is a level P-II evaluation of the dataset according to the FOCUS kinetics
+  # guidance. Due to the strong correlation of the parameter estimates, the
+  # covariance matrix is not returned. Note that level P-II evaluations are
+  # generally considered deprecated due to the frequent occurrence of such
+  # large parameter correlations, among other reasons (e.g. the adequacy of the
+  # model).
+  m_ws <- mkinmod(parent_w = mkinsub("SFO", "parent_s"),
+                  parent_s = mkinsub("SFO", "parent_w"))
+#> Temporary DLL for differentials generated and loaded
+  f_river <- mkinfit(m_ws, test_data_from_UBA_2014[[1]]$data, quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+  plot_sep(f_river)
+
+
+  summary(f_river)$bpar
+#>                           Estimate se_notrans    t value       Pr(>t)
+#> parent_w_0             95.98567441 2.16285684 44.3791159 1.245593e-17
+#> k_parent_w              0.42068803 0.05573864  7.5475120 8.752928e-07
+#> k_parent_s              0.07419672 0.10108562  0.7339987 2.371337e-01
+#> f_parent_w_to_parent_s  0.14336920 0.05809346  2.4679062 1.305295e-02
+#> f_parent_s_to_parent_w  1.00000000 3.13868615  0.3186046 3.772097e-01
+#> sigma                   2.98287858 0.68923267  4.3278253 2.987160e-04
+#>                              Lower       Upper
+#> parent_w_0             91.48420501 100.4871438
+#> k_parent_w              0.36593946   0.4836276
+#> k_parent_s              0.02289956   0.2404043
+#> f_parent_w_to_parent_s  0.08180934   0.2391848
+#> f_parent_s_to_parent_w  0.00000000   1.0000000
+#> sigma                   2.00184022   3.9639169
+  mkinerrmin(f_river)
+#>             err.min n.optim df
+#> All data 0.09246946       5  6
+#> parent_w 0.06377096       3  3
+#> parent_s 0.20882325       2  3
+
+  # This is the evaluation used for the validation of software packages
+  # in the expertise from 2014
+  m_soil <- mkinmod(parent = mkinsub("SFO", c("M1", "M2")),
+                    M1 = mkinsub("SFO", "M3"),
+                    M2 = mkinsub("SFO", "M3"),
+                    M3 = mkinsub("SFO"),
+                    use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+  f_soil <- mkinfit(m_soil, test_data_from_UBA_2014[[3]]$data, quiet = TRUE)
+#> Warning: Observations with value of zero were removed from the data
+  plot_sep(f_soil, lpos = c("topright", "topright", "topright", "bottomright"))
+
+  summary(f_soil)$bpar
+#>                   Estimate  se_notrans    t value       Pr(>t)        Lower
+#> parent_0       76.55425650 0.859186398 89.1008711 1.113861e-26 74.755959420
+#> k_parent        0.12081956 0.004601918 26.2541722 1.077359e-16  0.111561575
+#> k_M1            0.84258615 0.806159719  1.0451851 1.545266e-01  0.113779564
+#> k_M2            0.04210880 0.017083034  2.4649483 1.170188e-02  0.018013857
+#> k_M3            0.01122918 0.007245855  1.5497385 6.885051e-02  0.002909431
+#> f_parent_to_M1  0.32240200 0.240783878  1.3389684 9.819070e-02           NA
+#> f_parent_to_M2  0.16099855 0.033691952  4.7785463 6.531136e-05           NA
+#> f_M1_to_M3      0.27921507 0.269423709  1.0363419 1.565266e-01  0.022978202
+#> f_M2_to_M3      0.55641252 0.595119937  0.9349586 1.807707e-01  0.008002509
+#> sigma           1.14005399 0.149696423  7.6157731 1.727024e-07  0.826735778
+#>                      Upper
+#> parent_0       78.35255358
+#> k_parent        0.13084582
+#> k_M1            6.23970946
+#> k_M2            0.09843260
+#> k_M3            0.04333992
+#> f_parent_to_M1          NA
+#> f_parent_to_M2          NA
+#> f_M1_to_M3      0.86450778
+#> f_M2_to_M3      0.99489895
+#> sigma           1.45337221
+  mkinerrmin(f_soil)
+#>             err.min n.optim df
+#> All data 0.09649963       9 20
+#> parent   0.04721283       2  6
+#> M1       0.26551208       2  5
+#> M2       0.20327575       2  5
+#> M3       0.05196550       3  4
+  # }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/tex_listing.html b/docs/dev/reference/tex_listing.html new file mode 100644 index 00000000..779fff4c --- /dev/null +++ b/docs/dev/reference/tex_listing.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/transform_odeparms.html b/docs/dev/reference/transform_odeparms.html new file mode 100644 index 00000000..42125012 --- /dev/null +++ b/docs/dev/reference/transform_odeparms.html @@ -0,0 +1,293 @@ + +Functions to transform and backtransform kinetic parameters for fitting — transform_odeparms • mkin + Skip to contents + + +
+
+
+ +
+

The transformations are intended to map parameters that should only take on +restricted values to the full scale of real numbers. For kinetic rate +constants and other parameters that can only take on positive values, a +simple log transformation is used. For compositional parameters, such as the +formations fractions that should always sum up to 1 and can not be negative, +the ilr transformation is used.

+
+ +
+

Usage

+
transform_odeparms(
+  parms,
+  mkinmod,
+  transform_rates = TRUE,
+  transform_fractions = TRUE
+)
+
+backtransform_odeparms(
+  transparms,
+  mkinmod,
+  transform_rates = TRUE,
+  transform_fractions = TRUE
+)
+
+ +
+

Arguments

+ + +
parms
+

Parameters of kinetic models as used in the differential +equations.

+ + +
mkinmod
+

The kinetic model of class mkinmod, containing +the names of the model variables that are needed for grouping the +formation fractions before ilr transformation, the parameter +names and the information if the pathway to sink is included in the model.

+ + +
transform_rates
+

Boolean specifying if kinetic rate constants should +be transformed in the model specification used in the fitting for better +compliance with the assumption of normal distribution of the estimator. If +TRUE, also alpha and beta parameters of the FOMC model are +log-transformed, as well as k1 and k2 rate constants for the DFOP and HS +models and the break point tb of the HS model.

+ + +
transform_fractions
+

Boolean specifying if formation fractions +constants should be transformed in the model specification used in the +fitting for better compliance with the assumption of normal distribution +of the estimator. The default (TRUE) is to do transformations. +The g parameter of the DFOP model is also seen as a fraction. +If a single fraction is transformed (g parameter of DFOP or only a single +target variable e.g. a single metabolite plus a pathway to sink), a +logistic transformation is used stats::qlogis(). In other cases, i.e. if +two or more formation fractions need to be transformed whose sum cannot +exceed one, the ilr transformation is used.

+ + +
transparms
+

Transformed parameters of kinetic models as used in the +fitting procedure.

+ +
+
+

Value

+

A vector of transformed or backtransformed parameters

+
+
+

Details

+

The transformation of sets of formation fractions is fragile, as it supposes +the same ordering of the components in forward and backward transformation. +This is no problem for the internal use in mkinfit.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+SFO_SFO <- mkinmod(
+  parent = list(type = "SFO", to = "m1", sink = TRUE),
+  m1 = list(type = "SFO"), use_of_ff = "min")
+#> Temporary DLL for differentials generated and loaded
+
+# Fit the model to the FOCUS example dataset D using defaults
+FOCUS_D <- subset(FOCUS_2006_D, value != 0) # remove zero values to avoid warning
+fit <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE)
+fit.s <- summary(fit)
+# Transformed and backtransformed parameters
+print(fit.s$par, 3)
+#>                   Estimate Std. Error Lower  Upper
+#> parent_0             99.60     1.5702 96.40 102.79
+#> log_k_parent_sink    -3.04     0.0763 -3.19  -2.88
+#> log_k_parent_m1      -2.98     0.0403 -3.06  -2.90
+#> log_k_m1_sink        -5.25     0.1332 -5.52  -4.98
+#> sigma                 3.13     0.3585  2.40   3.85
+print(fit.s$bpar, 3)
+#>               Estimate se_notrans t value   Pr(>t)    Lower    Upper
+#> parent_0      99.59848    1.57022   63.43 2.30e-36 96.40384 102.7931
+#> k_parent_sink  0.04792    0.00365   13.11 6.13e-15  0.04103   0.0560
+#> k_parent_m1    0.05078    0.00205   24.80 3.27e-23  0.04678   0.0551
+#> k_m1_sink      0.00526    0.00070    7.51 6.16e-09  0.00401   0.0069
+#> sigma          3.12550    0.35852    8.72 2.24e-10  2.39609   3.8549
+
+# \dontrun{
+# Compare to the version without transforming rate parameters (does not work
+# with analytical solution, we get NA values for m1 in predictions)
+fit.2 <- mkinfit(SFO_SFO, FOCUS_D, transform_rates = FALSE,
+  solution_type = "deSolve", quiet = TRUE)
+fit.2.s <- summary(fit.2)
+print(fit.2.s$par, 3)
+#>               Estimate Std. Error    Lower    Upper
+#> parent_0      99.59848    1.57022 96.40384 1.03e+02
+#> k_parent_sink  0.04792    0.00365  0.04049 5.54e-02
+#> k_parent_m1    0.05078    0.00205  0.04661 5.49e-02
+#> k_m1_sink      0.00526    0.00070  0.00384 6.69e-03
+#> sigma          3.12550    0.35852  2.39609 3.85e+00
+print(fit.2.s$bpar, 3)
+#>               Estimate se_notrans t value   Pr(>t)    Lower    Upper
+#> parent_0      99.59848    1.57022   63.43 2.30e-36 96.40384 1.03e+02
+#> k_parent_sink  0.04792    0.00365   13.11 6.13e-15  0.04049 5.54e-02
+#> k_parent_m1    0.05078    0.00205   24.80 3.27e-23  0.04661 5.49e-02
+#> k_m1_sink      0.00526    0.00070    7.51 6.16e-09  0.00384 6.69e-03
+#> sigma          3.12550    0.35852    8.72 2.24e-10  2.39609 3.85e+00
+# }
+
+initials <- fit$start$value
+names(initials) <- rownames(fit$start)
+transformed <- fit$start_transformed$value
+names(transformed) <- rownames(fit$start_transformed)
+transform_odeparms(initials, SFO_SFO)
+#>          parent_0 log_k_parent_sink   log_k_parent_m1     log_k_m1_sink 
+#>        100.750000         -2.302585         -2.301586         -2.300587 
+backtransform_odeparms(transformed, SFO_SFO)
+#>      parent_0 k_parent_sink   k_parent_m1     k_m1_sink 
+#>      100.7500        0.1000        0.1001        0.1002 
+
+# \dontrun{
+# The case of formation fractions (this is now the default)
+SFO_SFO.ff <- mkinmod(
+  parent = list(type = "SFO", to = "m1", sink = TRUE),
+  m1 = list(type = "SFO"),
+  use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_D, quiet = TRUE)
+fit.ff.s <- summary(fit.ff)
+print(fit.ff.s$par, 3)
+#>                 Estimate Std. Error  Lower  Upper
+#> parent_0         99.5985     1.5702 96.404 102.79
+#> log_k_parent     -2.3157     0.0409 -2.399  -2.23
+#> log_k_m1         -5.2475     0.1332 -5.518  -4.98
+#> f_parent_qlogis   0.0579     0.0893 -0.124   0.24
+#> sigma             3.1255     0.3585  2.396   3.85
+print(fit.ff.s$bpar, 3)
+#>                Estimate se_notrans t value   Pr(>t)    Lower    Upper
+#> parent_0       99.59848    1.57022   63.43 2.30e-36 96.40383 102.7931
+#> k_parent        0.09870    0.00403   24.47 4.96e-23  0.09082   0.1073
+#> k_m1            0.00526    0.00070    7.51 6.16e-09  0.00401   0.0069
+#> f_parent_to_m1  0.51448    0.02230   23.07 3.10e-22  0.46912   0.5596
+#> sigma           3.12550    0.35852    8.72 2.24e-10  2.39609   3.8549
+initials <- c("f_parent_to_m1" = 0.5)
+transformed <- transform_odeparms(initials, SFO_SFO.ff)
+backtransform_odeparms(transformed, SFO_SFO.ff)
+#> f_parent_to_m1 
+#>            0.5 
+
+# And without sink
+SFO_SFO.ff.2 <- mkinmod(
+  parent = list(type = "SFO", to = "m1", sink = FALSE),
+  m1 = list(type = "SFO"),
+  use_of_ff = "max")
+#> Temporary DLL for differentials generated and loaded
+
+
+fit.ff.2 <- mkinfit(SFO_SFO.ff.2, FOCUS_D, quiet = TRUE)
+fit.ff.2.s <- summary(fit.ff.2)
+print(fit.ff.2.s$par, 3)
+#>              Estimate Std. Error Lower Upper
+#> parent_0        84.79      3.012 78.67 90.91
+#> log_k_parent    -2.76      0.082 -2.92 -2.59
+#> log_k_m1        -4.21      0.123 -4.46 -3.96
+#> sigma            8.22      0.943  6.31 10.14
+print(fit.ff.2.s$bpar, 3)
+#>          Estimate se_notrans t value   Pr(>t)   Lower  Upper
+#> parent_0  84.7916    3.01203   28.15 1.92e-25 78.6704 90.913
+#> k_parent   0.0635    0.00521   12.19 2.91e-14  0.0538  0.075
+#> k_m1       0.0148    0.00182    8.13 8.81e-10  0.0115  0.019
+#> sigma      8.2229    0.94323    8.72 1.73e-10  6.3060 10.140
+# }
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/update.mkinfit-1.png b/docs/dev/reference/update.mkinfit-1.png new file mode 100644 index 00000000..bc818a4c Binary files /dev/null and b/docs/dev/reference/update.mkinfit-1.png differ diff --git a/docs/dev/reference/update.mkinfit-2.png b/docs/dev/reference/update.mkinfit-2.png new file mode 100644 index 00000000..bbd2b9b7 Binary files /dev/null and b/docs/dev/reference/update.mkinfit-2.png differ diff --git a/docs/dev/reference/update.mkinfit.html b/docs/dev/reference/update.mkinfit.html new file mode 100644 index 00000000..e83fe3d2 --- /dev/null +++ b/docs/dev/reference/update.mkinfit.html @@ -0,0 +1,138 @@ + +Update an mkinfit model with different arguments — update.mkinfit • mkin + Skip to contents + + +
+
+
+ +
+

This function will return an updated mkinfit object. The fitted degradation +model parameters from the old fit are used as starting values for the +updated fit. Values specified as 'parms.ini' and/or 'state.ini' will +override these starting values.

+
+ +
+

Usage

+
# S3 method for class 'mkinfit'
+update(object, ..., evaluate = TRUE)
+
+ +
+

Arguments

+ + +
object
+

An mkinfit object to be updated

+ + +
...
+

Arguments to mkinfit that should replace +the arguments from the original call. Arguments set to NULL will +remove arguments given in the original call

+ + +
evaluate
+

Should the call be evaluated or returned as a call

+ +
+ +
+

Examples

+
# \dontrun{
+fit <- mkinfit("SFO", subset(FOCUS_2006_D, value != 0), quiet = TRUE)
+parms(fit)
+#>    parent_0    k_parent       sigma 
+#> 99.44423885  0.09793574  3.39632469 
+plot_err(fit)
+
+fit_2 <- update(fit, error_model = "tc")
+parms(fit_2)
+#>     parent_0     k_parent    sigma_low     rsd_high 
+#> 1.008549e+02 1.005665e-01 3.752222e-03 6.763434e-02 
+plot_err(fit_2)
+
+# }
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/dev/reference/update.nlme.mmkin.html b/docs/dev/reference/update.nlme.mmkin.html new file mode 100644 index 00000000..dc3bfe09 --- /dev/null +++ b/docs/dev/reference/update.nlme.mmkin.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/which.best.default.html b/docs/dev/reference/which.best.default.html new file mode 100644 index 00000000..06f15f0c --- /dev/null +++ b/docs/dev/reference/which.best.default.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/dev/reference/which.best.html b/docs/dev/reference/which.best.html new file mode 100644 index 00000000..06f15f0c --- /dev/null +++ b/docs/dev/reference/which.best.html @@ -0,0 +1,8 @@ + + + + + + + + -- cgit v1.2.1