This function uses the Flexible Modelling Environment package
FME
to create a function calculating the model cost, i.e. the
deviation between the kinetic model and the observed data. This model cost is
then minimised using the Port algorithm nlminb
,
using the specified initial or fixed parameters and starting values.
Per default, parameters in the kinetic models are internally transformed in order
to better satisfy the assumption of a normal distribution of their estimators.
In each step of the optimsation, the kinetic model is solved using the
function mkinpredict
. The variance of the residuals for each
observed variable can optionally be iteratively reweighted until convergence
using the argument reweight.method = "obs"
.
mkinfit(mkinmod, observed, parms.ini = "auto", state.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", method.modFit = c("Port", "Marq", "SANN", "Nelder-Mead", "BFGS", "CG", "L-BFGS-B"), maxit.modFit = "auto", control.modFit = list(), transform_rates = TRUE, transform_fractions = TRUE, plot = FALSE, quiet = FALSE, err = NULL, weight = "none", scaleVar = FALSE, atol = 1e-8, rtol = 1e-10, n.outtimes = 100, reweight.method = NULL, reweight.tol = 1e-8, reweight.max.iter = 10, trace_parms = FALSE, ...)
mkinmod
, containing the kinetic model to be
fitted to the data, or one of the shorthand names ("SFO", "FOMC", "DFOP",
"HS", "SFORB"). If a shorthand name is given, a parent only degradation
model is generated for the variable with the highest value in
observed
.
modFit
, i.e. 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. Optionally, a further column
can contain weights for each data point. Its name must be passed as a
further argument named err
which is then passed on to
modFit
.
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.
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.
parms.ini
.
deSolve
is used. If set to "analytical", an analytical
solution of the model is used. This is only implemented for simple
degradation experiments with only one state variable, i.e. with no
metabolites. The default is "auto", which uses "analytical" if possible,
otherwise "eigen" if the model can be expressed using eigenvalues and
eigenvectors, and finally "deSolve" for the remaining models (time
dependence of degradation rates and metabolites). This argument is passed
on to the helper function mkinpredict
.
mkinpredict
to
ode
in case the solution type is "deSolve". The default
"lsoda" is performant, but sometimes fails to converge.
FALSE
, no compiled version of the mkinmod
model is used, in the calls to mkinpredict
even if
a compiled verion is present.
modFit
.
In order to optimally deal with problems where local minima occur, the
"Port" algorithm is now used per default as it is less prone to get trapped
in local minima and depends less on starting values for parameters than
the Levenberg Marquardt variant selected by "Marq". However, "Port" needs
more iterations.
The former default "Marq" is the Levenberg Marquardt algorithm
nls.lm
from the package minpack.lm
and usually needs
the least number of iterations.
The "Pseudo" algorithm is not included because it needs finite parameter bounds
which are currently not supported.
The "Newton" algorithm is not included because its number of iterations
can not be controlled by control.modFit
and it does not appear
to provide advantages over the other algorithms.
modFit
, overriding
what may be specified in the next argument control.modFit
.
modFit
.
ilr
transformation.
NULL
, or the name of the column with the
error estimates, used to weigh the residuals (see details of
modCost
); if NULL
, then the residuals are not weighed.
err
=NULL
: how to weight the residuals, one of "none",
"std", "mean", see details of modCost
.
modCost
. Default is not to scale Variables
according to the number of observations.
ode
. Default is 1e-8,
lower than in lsoda
.
ode
. Default is 1e-10,
much lower than in lsoda
.
mkinpredict
. This impacts the accuracy of
the numerical solver if that is used (see solution_type
argument.
The default value is 100.
reweight.tol
or up to the maximum number of iterations
specified by reweight.max.iter
.
modFit
.
A list with "mkinfit" and "modFit" in the class attribute.
A summary can be obtained by summary.mkinfit
.
Plotting methods plot.mkinfit
and
mkinparplot
.
Fitting of several models to several datasets in a single call to
mmkin
.
The implementation of iteratively reweighted least squares is inspired by the work of the KinGUII team at Bayer Crop Science (Walter Schmitt and Zhenglei Gao). A similar implemention can also be found in CAKE 2.0, which is the other GUI derivative of mkin, sponsored by Syngenta.
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.
# Use shorthand notation for parent only degradation fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) summary(fit)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:39 2016 #> Date of summary: Fri Nov 18 16:45:39 2016 #> #> Equations: #> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent #> #> Model predictions using solution type analytical #> #> Fitted with method Port using 64 model solutions performed in 0.146 s #> #> Weighting: none #> #> 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 #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 85.87000 2.2460 80.38000 91.3700 #> log_alpha 0.05192 0.1605 -0.34080 0.4446 #> log_beta 0.65100 0.2801 -0.03452 1.3360 #> #> Parameter correlation: #> parent_0 log_alpha log_beta #> parent_0 1.0000 -0.2033 -0.3624 #> log_alpha -0.2033 1.0000 0.9547 #> log_beta -0.3624 0.9547 1.0000 #> #> Residual standard error: 2.275 on 6 degrees of freedom #> #> 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 38.230 1.069e-08 80.3800 91.370 #> alpha 1.053 6.231 3.953e-04 0.7112 1.560 #> beta 1.917 3.570 5.895e-03 0.9661 3.806 #> #> 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. # Use mkinsub for convenience in model formulation. Pathway to sink included per default. SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))#># Fit the model to the FOCUS example dataset D using defaults print(system.time(fit <- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE)))#> user system elapsed #> 1.220 1.216 0.920coef(fit)#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink #> 99.59848 -3.03822 -2.98030 -5.24750endpoints(fit)#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 #> #> $SFORB #> logical(0) #> #> $distimes #> DT50 DT90 #> parent 7.022929 23.32967 #> m1 131.760712 437.69961 #># deSolve is slower when no C compiler (gcc) was available during model generation print(system.time(fit.deSolve <- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "deSolve")))#> Model cost at call 1 : 18915.53 #> Model cost at call 2 : 18915.53 #> Model cost at call 6 : 11424.02 #> Model cost at call 10 : 11424 #> Model cost at call 12 : 4094.396 #> Model cost at call 16 : 4094.396 #> Model cost at call 19 : 1340.595 #> Model cost at call 20 : 1340.593 #> Model cost at call 25 : 1072.239 #> Model cost at call 28 : 1072.236 #> Model cost at call 30 : 874.2614 #> Model cost at call 33 : 874.2611 #> Model cost at call 35 : 616.2379 #> Model cost at call 37 : 616.2374 #> Model cost at call 40 : 467.4388 #> Model cost at call 42 : 467.4382 #> Model cost at call 46 : 398.2914 #> Model cost at call 48 : 398.2914 #> Model cost at call 49 : 398.2913 #> Model cost at call 51 : 395.0712 #> Model cost at call 54 : 395.0711 #> Model cost at call 56 : 378.3298 #> Model cost at call 59 : 378.3298 #> Model cost at call 62 : 376.9812 #> Model cost at call 64 : 376.9811 #> Model cost at call 67 : 375.2085 #> Model cost at call 69 : 375.2085 #> Model cost at call 70 : 375.2085 #> Model cost at call 71 : 375.2085 #> Model cost at call 72 : 374.5723 #> Model cost at call 74 : 374.5723 #> Model cost at call 77 : 374.0075 #> Model cost at call 79 : 374.0075 #> Model cost at call 80 : 374.0075 #> Model cost at call 82 : 373.1711 #> Model cost at call 84 : 373.1711 #> Model cost at call 87 : 372.6445 #> Model cost at call 88 : 372.1614 #> Model cost at call 90 : 372.1614 #> Model cost at call 91 : 372.1614 #> Model cost at call 94 : 371.6464 #> Model cost at call 99 : 371.4299 #> Model cost at call 101 : 371.4299 #> Model cost at call 104 : 371.407 #> Model cost at call 106 : 371.407 #> Model cost at call 107 : 371.407 #> Model cost at call 109 : 371.2524 #> Model cost at call 113 : 371.2524 #> Model cost at call 114 : 371.2136 #> Model cost at call 115 : 371.2136 #> Model cost at call 116 : 371.2136 #> Model cost at call 119 : 371.2134 #> Model cost at call 120 : 371.2134 #> Model cost at call 122 : 371.2134 #> Model cost at call 123 : 371.2134 #> Model cost at call 125 : 371.2134 #> Model cost at call 126 : 371.2134 #> Model cost at call 135 : 371.2134 #> Model cost at call 147 : 371.2134 #> Model cost at call 152 : 371.2134 #> Optimisation by method Port successfully terminated. #> user system elapsed #> 0.724 0.048 0.722coef(fit.deSolve)#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink #> 99.59848 -3.03822 -2.98030 -5.24750endpoints(fit.deSolve)#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 #> #> $SFORB #> logical(0) #> #> $distimes #> DT50 DT90 #> parent 7.022929 23.32967 #> m1 131.760713 437.69961 #># Use stepwise fitting, using optimised parameters from parent only fit, FOMC FOMC_SFO <- mkinmod( parent = mkinsub("FOMC", "m1"), m1 = mkinsub("SFO"))#># Fit the model to the FOCUS example dataset D using defaults fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE) # Use starting parameters from parent only FOMC fit fit.FOMC = mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE) fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE, parms.ini = fit.FOMC$bparms.ode) # Use stepwise fitting, using optimised parameters from parent only fit, SFORB SFORB_SFO <- mkinmod( parent = list(type = "SFORB", to = "m1", sink = TRUE), m1 = list(type = "SFO"))#># Fit the model to the FOCUS example dataset D using defaults fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, quiet = TRUE) fit.SFORB_SFO.deSolve <- mkinfit(SFORB_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE) # Use starting parameters from parent only SFORB fit (not really needed in this case) fit.SFORB = mkinfit("SFORB", FOCUS_2006_D, quiet = TRUE) fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, parms.ini = fit.SFORB$bparms.ode, quiet = TRUE) # Weighted fits, including IRLS SFO_SFO.ff <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), use_of_ff = "max")#>f.noweight <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) summary(f.noweight)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:50 2016 #> Date of summary: Fri Nov 18 16:45:50 2016 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> #> Model predictions using solution type deSolve #> #> Fitted with method Port using 185 model solutions performed in 0.872 s #> #> Weighting: none #> #> Starting values for parameters to be optimised: #> value type #> parent_0 100.7500 state #> k_parent 0.1000 deparm #> k_m1 0.1001 deparm #> f_parent_to_m1 0.5000 deparm #> #> Starting values for the transformed parameters actually optimised: #> value lower upper #> parent_0 100.750000 -Inf Inf #> log_k_parent -2.302585 -Inf Inf #> log_k_m1 -2.301586 -Inf Inf #> f_parent_ilr_1 0.000000 -Inf Inf #> #> Fixed parameter values: #> value type #> m1_0 0 state #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.60000 1.61400 96.3300 102.9000 #> log_k_parent -2.31600 0.04187 -2.4010 -2.2310 #> log_k_m1 -5.24800 0.13610 -5.5230 -4.9720 #> f_parent_ilr_1 0.04096 0.06477 -0.0904 0.1723 #> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 #> parent_0 1.0000 0.5178 -0.1701 -0.5489 #> log_k_parent 0.5178 1.0000 -0.3285 -0.5451 #> log_k_m1 -0.1701 -0.3285 1.0000 0.7466 #> f_parent_ilr_1 -0.5489 -0.5451 0.7466 1.0000 #> #> Residual standard error: 3.211 on 36 degrees of freedom #> #> 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 99.600000 61.720 2.024e-38 96.330000 1.029e+02 #> k_parent 0.098700 23.880 5.701e-24 0.090660 1.074e-01 #> k_m1 0.005261 7.349 5.758e-09 0.003992 6.933e-03 #> f_parent_to_m1 0.514500 22.490 4.374e-23 0.468100 5.606e-01 #> #> Chi2 error levels in percent: #> err.min n.optim df #> All data 6.398 4 15 #> parent 6.459 2 7 #> m1 4.690 2 8 #> #> Resulting formation fractions: #> ff #> parent_m1 0.5145 #> parent_sink 0.4855 #> #> Estimated disappearance times: #> DT50 DT90 #> parent 7.023 23.33 #> m1 131.761 437.70 #> #> Data: #> time variable observed predicted residual #> 0 parent 99.46 9.960e+01 -1.385e-01 #> 0 parent 102.04 9.960e+01 2.442e+00 #> 1 parent 93.50 9.024e+01 3.262e+00 #> 1 parent 92.50 9.024e+01 2.262e+00 #> 3 parent 63.23 7.407e+01 -1.084e+01 #> 3 parent 68.99 7.407e+01 -5.083e+00 #> 7 parent 52.32 4.991e+01 2.408e+00 #> 7 parent 55.13 4.991e+01 5.218e+00 #> 14 parent 27.27 2.501e+01 2.257e+00 #> 14 parent 26.64 2.501e+01 1.627e+00 #> 21 parent 11.50 1.253e+01 -1.035e+00 #> 21 parent 11.64 1.253e+01 -8.946e-01 #> 35 parent 2.85 3.148e+00 -2.979e-01 #> 35 parent 2.91 3.148e+00 -2.379e-01 #> 50 parent 0.69 7.162e-01 -2.624e-02 #> 50 parent 0.63 7.162e-01 -8.624e-02 #> 75 parent 0.05 6.074e-02 -1.074e-02 #> 75 parent 0.06 6.074e-02 -7.381e-04 #> 100 parent NA 5.151e-03 NA #> 100 parent NA 5.151e-03 NA #> 120 parent NA 7.155e-04 NA #> 120 parent NA 7.155e-04 NA #> 0 m1 0.00 0.000e+00 0.000e+00 #> 0 m1 0.00 0.000e+00 0.000e+00 #> 1 m1 4.84 4.803e+00 3.704e-02 #> 1 m1 5.64 4.803e+00 8.370e-01 #> 3 m1 12.91 1.302e+01 -1.140e-01 #> 3 m1 12.96 1.302e+01 -6.400e-02 #> 7 m1 22.97 2.504e+01 -2.075e+00 #> 7 m1 24.47 2.504e+01 -5.748e-01 #> 14 m1 41.69 3.669e+01 5.000e+00 #> 14 m1 33.21 3.669e+01 -3.480e+00 #> 21 m1 44.37 4.165e+01 2.717e+00 #> 21 m1 46.44 4.165e+01 4.787e+00 #> 35 m1 41.22 4.331e+01 -2.093e+00 #> 35 m1 37.95 4.331e+01 -5.363e+00 #> 50 m1 41.19 4.122e+01 -2.831e-02 #> 50 m1 40.01 4.122e+01 -1.208e+00 #> 75 m1 40.09 3.645e+01 3.643e+00 #> 75 m1 33.85 3.645e+01 -2.597e+00 #> 100 m1 31.04 3.198e+01 -9.416e-01 #> 100 m1 33.13 3.198e+01 1.148e+00 #> 120 m1 25.15 2.879e+01 -3.640e+00 #> 120 m1 33.31 2.879e+01 4.520e+00f.irls <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, reweight.method = "obs", quiet = TRUE) summary(f.irls)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:52 2016 #> Date of summary: Fri Nov 18 16:45:52 2016 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> #> Model predictions using solution type deSolve #> #> Fitted with method Port using 486 model solutions performed in 2.009 s #> #> Weighting: none then iterative reweighting method obs #> #> Starting values for parameters to be optimised: #> value type #> parent_0 100.7500 state #> k_parent 0.1000 deparm #> k_m1 0.1001 deparm #> f_parent_to_m1 0.5000 deparm #> #> Starting values for the transformed parameters actually optimised: #> value lower upper #> parent_0 100.750000 -Inf Inf #> log_k_parent -2.302585 -Inf Inf #> log_k_m1 -2.301586 -Inf Inf #> f_parent_ilr_1 0.000000 -Inf Inf #> #> Fixed parameter values: #> value type #> m1_0 0 state #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.67000 1.79200 96.04000 103.300 #> log_k_parent -2.31200 0.04560 -2.40400 -2.220 #> log_k_m1 -5.25100 0.12510 -5.50500 -4.998 #> f_parent_ilr_1 0.03785 0.06318 -0.09027 0.166 #> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 #> parent_0 1.0000 0.5083 -0.1979 -0.6148 #> log_k_parent 0.5083 1.0000 -0.3894 -0.6062 #> log_k_m1 -0.1979 -0.3894 1.0000 0.7417 #> f_parent_ilr_1 -0.6148 -0.6062 0.7417 1.0000 #> #> Residual standard error: 1.054 on 36 degrees of freedom #> #> 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 99.67000 55.630 8.183e-37 96.040000 1.033e+02 #> k_parent 0.09906 21.930 1.016e-22 0.090310 1.087e-01 #> k_m1 0.00524 7.996 8.487e-10 0.004066 6.753e-03 #> f_parent_to_m1 0.51340 23.000 2.039e-23 0.468100 5.584e-01 #> #> Chi2 error levels in percent: #> err.min n.optim df #> All data 6.399 4 15 #> parent 6.466 2 7 #> m1 4.679 2 8 #> #> Resulting formation fractions: #> ff #> parent_m1 0.5134 #> parent_sink 0.4866 #> #> Estimated disappearance times: #> DT50 DT90 #> parent 6.997 23.24 #> m1 132.282 439.43 #> #> Data: #> time variable observed predicted residual err #> 0 parent 99.46 9.967e+01 -2.122e-01 3.402 #> 0 parent 102.04 9.967e+01 2.368e+00 3.402 #> 1 parent 93.50 9.027e+01 3.228e+00 3.402 #> 1 parent 92.50 9.027e+01 2.228e+00 3.402 #> 3 parent 63.23 7.405e+01 -1.082e+01 3.402 #> 3 parent 68.99 7.405e+01 -5.056e+00 3.402 #> 7 parent 52.32 4.982e+01 2.499e+00 3.402 #> 7 parent 55.13 4.982e+01 5.309e+00 3.402 #> 14 parent 27.27 2.490e+01 2.367e+00 3.402 #> 14 parent 26.64 2.490e+01 1.737e+00 3.402 #> 21 parent 11.50 1.245e+01 -9.477e-01 3.402 #> 21 parent 11.64 1.245e+01 -8.077e-01 3.402 #> 35 parent 2.85 3.110e+00 -2.600e-01 3.402 #> 35 parent 2.91 3.110e+00 -2.000e-01 3.402 #> 50 parent 0.69 7.037e-01 -1.375e-02 3.402 #> 50 parent 0.63 7.037e-01 -7.375e-02 3.402 #> 75 parent 0.05 5.913e-02 -9.134e-03 3.402 #> 75 parent 0.06 5.913e-02 8.661e-04 3.402 #> 100 parent NA 4.969e-03 NA 3.402 #> 100 parent NA 4.969e-03 NA 3.402 #> 120 parent NA 6.852e-04 NA 3.402 #> 120 parent NA 6.852e-04 NA 3.402 #> 0 m1 0.00 0.000e+00 0.000e+00 2.722 #> 0 m1 0.00 0.000e+00 0.000e+00 2.722 #> 1 m1 4.84 4.813e+00 2.672e-02 2.722 #> 1 m1 5.64 4.813e+00 8.267e-01 2.722 #> 3 m1 12.91 1.305e+01 -1.378e-01 2.722 #> 3 m1 12.96 1.305e+01 -8.779e-02 2.722 #> 7 m1 22.97 2.508e+01 -2.106e+00 2.722 #> 7 m1 24.47 2.508e+01 -6.061e-01 2.722 #> 14 m1 41.69 3.671e+01 4.983e+00 2.722 #> 14 m1 33.21 3.671e+01 -3.497e+00 2.722 #> 21 m1 44.37 4.165e+01 2.719e+00 2.722 #> 21 m1 46.44 4.165e+01 4.789e+00 2.722 #> 35 m1 41.22 4.329e+01 -2.069e+00 2.722 #> 35 m1 37.95 4.329e+01 -5.339e+00 2.722 #> 50 m1 41.19 4.119e+01 -3.388e-03 2.722 #> 50 m1 40.01 4.119e+01 -1.183e+00 2.722 #> 75 m1 40.09 3.644e+01 3.652e+00 2.722 #> 75 m1 33.85 3.644e+01 -2.588e+00 2.722 #> 100 m1 31.04 3.199e+01 -9.497e-01 2.722 #> 100 m1 33.13 3.199e+01 1.140e+00 2.722 #> 120 m1 25.15 2.881e+01 -3.659e+00 2.722 #> 120 m1 33.31 2.881e+01 4.501e+00 2.722f.w.mean <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, weight = "mean", quiet = TRUE) summary(f.w.mean)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:53 2016 #> Date of summary: Fri Nov 18 16:45:53 2016 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> #> Model predictions using solution type deSolve #> #> Fitted with method Port using 155 model solutions performed in 0.647 s #> #> Weighting: mean #> #> Starting values for parameters to be optimised: #> value type #> parent_0 100.7500 state #> k_parent 0.1000 deparm #> k_m1 0.1001 deparm #> f_parent_to_m1 0.5000 deparm #> #> Starting values for the transformed parameters actually optimised: #> value lower upper #> parent_0 100.750000 -Inf Inf #> log_k_parent -2.302585 -Inf Inf #> log_k_m1 -2.301586 -Inf Inf #> f_parent_ilr_1 0.000000 -Inf Inf #> #> Fixed parameter values: #> value type #> m1_0 0 state #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.7300 1.93200 95.81000 103.6000 #> log_k_parent -2.3090 0.04837 -2.40700 -2.2110 #> log_k_m1 -5.2550 0.12070 -5.49900 -5.0100 #> f_parent_ilr_1 0.0354 0.06344 -0.09327 0.1641 #> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 #> parent_0 1.0000 0.5004 -0.2143 -0.6514 #> log_k_parent 0.5004 1.0000 -0.4282 -0.6383 #> log_k_m1 -0.2143 -0.4282 1.0000 0.7390 #> f_parent_ilr_1 -0.6514 -0.6383 0.7390 1.0000 #> #> Residual standard error: 0.09829 on 36 degrees of freedom #> #> 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 99.730000 51.630 1.166e-35 95.81000 1.036e+02 #> k_parent 0.099360 20.670 7.304e-22 0.09007 1.096e-01 #> k_m1 0.005224 8.287 3.649e-10 0.00409 6.672e-03 #> f_parent_to_m1 0.512500 22.860 2.497e-23 0.46710 5.578e-01 #> #> Chi2 error levels in percent: #> err.min n.optim df #> All data 6.401 4 15 #> parent 6.473 2 7 #> m1 4.671 2 8 #> #> Resulting formation fractions: #> ff #> parent_m1 0.5125 #> parent_sink 0.4875 #> #> Estimated disappearance times: #> DT50 DT90 #> parent 6.976 23.18 #> m1 132.696 440.81 #> #> Data: #> time variable observed predicted residual #> 0 parent 99.46 99.730570 -0.270570 #> 0 parent 102.04 99.730570 2.309430 #> 1 parent 93.50 90.298055 3.201945 #> 1 parent 92.50 90.298055 2.201945 #> 3 parent 63.23 74.025028 -10.795028 #> 3 parent 68.99 74.025028 -5.035028 #> 7 parent 52.32 49.748382 2.571618 #> 7 parent 55.13 49.748382 5.381618 #> 14 parent 27.27 24.815876 2.454124 #> 14 parent 26.64 24.815876 1.824124 #> 21 parent 11.50 12.378849 -0.878849 #> 21 parent 11.64 12.378849 -0.738849 #> 35 parent 2.85 3.080219 -0.230219 #> 35 parent 2.91 3.080219 -0.170219 #> 50 parent 0.69 0.693958 -0.003958 #> 50 parent 0.63 0.693958 -0.063958 #> 75 parent 0.05 0.057888 -0.007888 #> 75 parent 0.06 0.057888 0.002112 #> 100 parent NA 0.004829 NA #> 100 parent NA 0.004829 NA #> 120 parent NA 0.000662 NA #> 120 parent NA 0.000662 NA #> 0 m1 0.00 0.000000 0.000000 #> 0 m1 0.00 0.000000 0.000000 #> 1 m1 4.84 4.821488 0.018512 #> 1 m1 5.64 4.821488 0.818512 #> 3 m1 12.91 13.066692 -0.156692 #> 3 m1 12.96 13.066692 -0.106692 #> 7 m1 22.97 25.101058 -2.131058 #> 7 m1 24.47 25.101058 -0.631058 #> 14 m1 41.69 36.720923 4.969077 #> 14 m1 33.21 36.720923 -3.510923 #> 21 m1 44.37 41.648353 2.721647 #> 21 m1 46.44 41.648353 4.791647 #> 35 m1 41.22 43.269225 -2.049225 #> 35 m1 37.95 43.269225 -5.319225 #> 50 m1 41.19 41.173639 0.016361 #> 50 m1 40.01 41.173639 -1.163639 #> 75 m1 40.09 36.431224 3.658776 #> 75 m1 33.85 36.431224 -2.581224 #> 100 m1 31.04 31.996124 -0.956124 #> 100 m1 33.13 31.996124 1.133876 #> 120 m1 25.15 28.824128 -3.674128 #> 120 m1 33.31 28.824128 4.485872f.w.value <- mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), err = "value", quiet = TRUE) summary(f.w.value)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:54 2016 #> Date of summary: Fri Nov 18 16:45:54 2016 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> #> Model predictions using solution type deSolve #> #> Fitted with method Port using 174 model solutions performed in 0.749 s #> #> Weighting: manual #> #> Starting values for parameters to be optimised: #> value type #> parent_0 100.7500 state #> k_parent 0.1000 deparm #> k_m1 0.1001 deparm #> f_parent_to_m1 0.5000 deparm #> #> Starting values for the transformed parameters actually optimised: #> value lower upper #> parent_0 100.750000 -Inf Inf #> log_k_parent -2.302585 -Inf Inf #> log_k_m1 -2.301586 -Inf Inf #> f_parent_ilr_1 0.000000 -Inf Inf #> #> Fixed parameter values: #> value type #> m1_0 0 state #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.6600 2.712000 94.14000 105.2000 #> log_k_parent -2.2980 0.008118 -2.31500 -2.2820 #> log_k_m1 -5.2410 0.096690 -5.43800 -5.0450 #> f_parent_ilr_1 0.0231 0.057990 -0.09474 0.1409 #> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 #> parent_0 1.00000 0.6844 -0.08687 -0.7564 #> log_k_parent 0.68435 1.0000 -0.12694 -0.5812 #> log_k_m1 -0.08687 -0.1269 1.00000 0.5195 #> f_parent_ilr_1 -0.75644 -0.5812 0.51951 1.0000 #> #> Residual standard error: 0.08396 on 34 degrees of freedom #> #> 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 99.660000 36.75 2.957e-29 94.14000 1.052e+02 #> k_parent 0.100400 123.20 5.927e-47 0.09878 1.021e-01 #> k_m1 0.005295 10.34 2.447e-12 0.00435 6.444e-03 #> f_parent_to_m1 0.508200 24.79 1.184e-23 0.46660 5.497e-01 #> #> Chi2 error levels in percent: #> err.min n.optim df #> All data 6.461 4 15 #> parent 6.520 2 7 #> m1 4.744 2 8 #> #> Resulting formation fractions: #> ff #> parent_m1 0.5082 #> parent_sink 0.4918 #> #> Estimated disappearance times: #> DT50 DT90 #> parent 6.902 22.93 #> m1 130.916 434.89 #> #> Data: #> time variable observed predicted residual err #> 0 parent 99.46 99.65571 -0.195714 99.46 #> 0 parent 102.04 99.65571 2.384286 102.04 #> 1 parent 93.50 90.13383 3.366170 93.50 #> 1 parent 92.50 90.13383 2.366170 92.50 #> 3 parent 63.23 73.73252 -10.502518 63.23 #> 3 parent 68.99 73.73252 -4.742518 68.99 #> 7 parent 52.32 49.34027 2.979728 52.32 #> 7 parent 55.13 49.34027 5.789728 55.13 #> 14 parent 27.27 24.42873 2.841271 27.27 #> 14 parent 26.64 24.42873 2.211271 26.64 #> 21 parent 11.50 12.09484 -0.594842 11.50 #> 21 parent 11.64 12.09484 -0.454842 11.64 #> 35 parent 2.85 2.96482 -0.114824 2.85 #> 35 parent 2.91 2.96482 -0.054824 2.91 #> 50 parent 0.69 0.65733 0.032670 0.69 #> 50 parent 0.63 0.65733 -0.027330 0.63 #> 75 parent 0.05 0.05339 -0.003386 0.05 #> 75 parent 0.06 0.05339 0.006614 0.06 #> 1 m1 4.84 4.82570 0.014301 4.84 #> 1 m1 5.64 4.82570 0.814301 5.64 #> 3 m1 12.91 13.06402 -0.154020 12.91 #> 3 m1 12.96 13.06402 -0.104020 12.96 #> 7 m1 22.97 25.04656 -2.076564 22.97 #> 7 m1 24.47 25.04656 -0.576564 24.47 #> 14 m1 41.69 36.53601 5.153988 41.69 #> 14 m1 33.21 36.53601 -3.326012 33.21 #> 21 m1 44.37 41.34639 3.023609 44.37 #> 21 m1 46.44 41.34639 5.093609 46.44 #> 35 m1 41.22 42.82669 -1.606690 41.22 #> 35 m1 37.95 42.82669 -4.876690 37.95 #> 50 m1 41.19 40.67342 0.516578 41.19 #> 50 m1 40.01 40.67342 -0.663422 40.01 #> 75 m1 40.09 35.91105 4.178947 40.09 #> 75 m1 33.85 35.91105 -2.061053 33.85 #> 100 m1 31.04 31.48161 -0.441612 31.04 #> 100 m1 33.13 31.48161 1.648388 33.13 #> 120 m1 25.15 28.32018 -3.170181 25.15 #> 120 m1 33.31 28.32018 4.989819 33.31# Manual weighting dw <- FOCUS_2006_D errors <- c(parent = 2, m1 = 1) dw$err.man <- errors[FOCUS_2006_D$name] f.w.man <- mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE) summary(f.w.man)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:55 2016 #> Date of summary: Fri Nov 18 16:45:55 2016 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> #> Model predictions using solution type deSolve #> #> Fitted with method Port using 316 model solutions performed in 1.288 s #> #> Weighting: manual #> #> Starting values for parameters to be optimised: #> value type #> parent_0 100.7500 state #> k_parent 0.1000 deparm #> k_m1 0.1001 deparm #> f_parent_to_m1 0.5000 deparm #> #> Starting values for the transformed parameters actually optimised: #> value lower upper #> parent_0 100.750000 -Inf Inf #> log_k_parent -2.302585 -Inf Inf #> log_k_m1 -2.301586 -Inf Inf #> f_parent_ilr_1 0.000000 -Inf Inf #> #> Fixed parameter values: #> value type #> m1_0 0 state #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.49000 1.33200 96.7800 102.2000 #> log_k_parent -2.32100 0.03550 -2.3930 -2.2490 #> log_k_m1 -5.24100 0.21280 -5.6730 -4.8100 #> f_parent_ilr_1 0.04571 0.08966 -0.1361 0.2275 #> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 #> parent_0 1.00000 0.5312 -0.09455 -0.3351 #> log_k_parent 0.53123 1.0000 -0.17800 -0.3360 #> log_k_m1 -0.09455 -0.1780 1.00000 0.7616 #> f_parent_ilr_1 -0.33513 -0.3360 0.76156 1.0000 #> #> Residual standard error: 2.628 on 36 degrees of freedom #> #> 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 99.490000 74.69 2.222e-41 96.780000 1.022e+02 #> k_parent 0.098140 28.17 2.012e-26 0.091320 1.055e-01 #> k_m1 0.005292 4.70 1.873e-05 0.003437 8.148e-03 #> f_parent_to_m1 0.516200 16.30 1.686e-18 0.452000 5.798e-01 #> #> Chi2 error levels in percent: #> err.min n.optim df #> All data 6.400 4 15 #> parent 6.454 2 7 #> m1 4.708 2 8 #> #> Resulting formation fractions: #> ff #> parent_m1 0.5162 #> parent_sink 0.4838 #> #> Estimated disappearance times: #> DT50 DT90 #> parent 7.063 23.46 #> m1 130.971 435.08 #> #> Data: #> time variable observed predicted residual err #> 0 parent 99.46 99.485977 -0.025977 1 #> 0 parent 102.04 99.485977 2.554023 1 #> 1 parent 93.50 90.186118 3.313882 1 #> 1 parent 92.50 90.186118 2.313882 1 #> 3 parent 63.23 74.113162 -10.883162 1 #> 3 parent 68.99 74.113162 -5.123162 1 #> 7 parent 52.32 50.050295 2.269705 1 #> 7 parent 55.13 50.050295 5.079705 1 #> 14 parent 27.27 25.179750 2.090250 1 #> 14 parent 26.64 25.179750 1.460250 1 #> 21 parent 11.50 12.667654 -1.167654 1 #> 21 parent 11.64 12.667654 -1.027654 1 #> 35 parent 2.85 3.206164 -0.356164 1 #> 35 parent 2.91 3.206164 -0.296164 1 #> 50 parent 0.69 0.735619 -0.045619 1 #> 50 parent 0.63 0.735619 -0.105619 1 #> 75 parent 0.05 0.063256 -0.013256 1 #> 75 parent 0.06 0.063256 -0.003256 1 #> 100 parent NA 0.005439 NA 1 #> 100 parent NA 0.005439 NA 1 #> 120 parent NA 0.000764 NA 1 #> 120 parent NA 0.000764 NA 1 #> 0 m1 0.00 0.000000 0.000000 2 #> 0 m1 0.00 0.000000 0.000000 2 #> 1 m1 4.84 4.787287 0.052713 2 #> 1 m1 5.64 4.787287 0.852713 2 #> 3 m1 12.91 12.987848 -0.077848 2 #> 3 m1 12.96 12.987848 -0.027848 2 #> 7 m1 22.97 24.996945 -2.026945 2 #> 7 m1 24.47 24.996945 -0.526945 2 #> 14 m1 41.69 36.663527 5.026473 2 #> 14 m1 33.21 36.663527 -3.453527 2 #> 21 m1 44.37 41.656812 2.713188 2 #> 21 m1 46.44 41.656812 4.783188 2 #> 35 m1 41.22 43.350311 -2.130311 2 #> 35 m1 37.95 43.350311 -5.400311 2 #> 50 m1 41.19 41.256364 -0.066364 2 #> 50 m1 40.01 41.256364 -1.246364 2 #> 75 m1 40.09 36.460566 3.629434 2 #> 75 m1 33.85 36.460566 -2.610566 2 #> 100 m1 31.04 31.969288 -0.929288 2 #> 100 m1 33.13 31.969288 1.160712 2 #> 120 m1 25.15 28.760615 -3.610615 2 #> 120 m1 33.31 28.760615 4.549385 2f.w.man.irls <- mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE, reweight.method = "obs") summary(f.w.man.irls)#> mkin version: 0.9.44.9000 #> R version: 3.3.2 #> Date of fit: Fri Nov 18 16:45:58 2016 #> Date of summary: Fri Nov 18 16:45:58 2016 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> #> Model predictions using solution type deSolve #> #> Fitted with method Port using 648 model solutions performed in 2.738 s #> #> Weighting: manual then iterative reweighting method obs #> #> Starting values for parameters to be optimised: #> value type #> parent_0 100.7500 state #> k_parent 0.1000 deparm #> k_m1 0.1001 deparm #> f_parent_to_m1 0.5000 deparm #> #> Starting values for the transformed parameters actually optimised: #> value lower upper #> parent_0 100.750000 -Inf Inf #> log_k_parent -2.302585 -Inf Inf #> log_k_m1 -2.301586 -Inf Inf #> f_parent_ilr_1 0.000000 -Inf Inf #> #> Fixed parameter values: #> value type #> m1_0 0 state #> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.67000 1.79200 96.04000 103.300 #> log_k_parent -2.31200 0.04560 -2.40400 -2.220 #> log_k_m1 -5.25100 0.12510 -5.50500 -4.998 #> f_parent_ilr_1 0.03785 0.06318 -0.09027 0.166 #> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 #> parent_0 1.0000 0.5083 -0.1979 -0.6147 #> log_k_parent 0.5083 1.0000 -0.3894 -0.6062 #> log_k_m1 -0.1979 -0.3894 1.0000 0.7417 #> f_parent_ilr_1 -0.6147 -0.6062 0.7417 1.0000 #> #> Residual standard error: 1.054 on 36 degrees of freedom #> #> 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 99.67000 55.630 8.178e-37 96.040000 1.033e+02 #> k_parent 0.09906 21.930 1.015e-22 0.090310 1.087e-01 #> k_m1 0.00524 7.996 8.488e-10 0.004066 6.753e-03 #> f_parent_to_m1 0.51340 23.000 2.038e-23 0.468100 5.584e-01 #> #> Chi2 error levels in percent: #> err.min n.optim df #> All data 6.399 4 15 #> parent 6.466 2 7 #> m1 4.679 2 8 #> #> Resulting formation fractions: #> ff #> parent_m1 0.5134 #> parent_sink 0.4866 #> #> Estimated disappearance times: #> DT50 DT90 #> parent 6.997 23.24 #> m1 132.281 439.43 #> #> Data: #> time variable observed predicted residual err.ini err #> 0 parent 99.46 9.967e+01 -2.122e-01 1 3.402 #> 0 parent 102.04 9.967e+01 2.368e+00 1 3.402 #> 1 parent 93.50 9.027e+01 3.228e+00 1 3.402 #> 1 parent 92.50 9.027e+01 2.228e+00 1 3.402 #> 3 parent 63.23 7.405e+01 -1.082e+01 1 3.402 #> 3 parent 68.99 7.405e+01 -5.056e+00 1 3.402 #> 7 parent 52.32 4.982e+01 2.499e+00 1 3.402 #> 7 parent 55.13 4.982e+01 5.309e+00 1 3.402 #> 14 parent 27.27 2.490e+01 2.367e+00 1 3.402 #> 14 parent 26.64 2.490e+01 1.737e+00 1 3.402 #> 21 parent 11.50 1.245e+01 -9.477e-01 1 3.402 #> 21 parent 11.64 1.245e+01 -8.077e-01 1 3.402 #> 35 parent 2.85 3.110e+00 -2.600e-01 1 3.402 #> 35 parent 2.91 3.110e+00 -2.000e-01 1 3.402 #> 50 parent 0.69 7.037e-01 -1.375e-02 1 3.402 #> 50 parent 0.63 7.037e-01 -7.375e-02 1 3.402 #> 75 parent 0.05 5.913e-02 -9.134e-03 1 3.402 #> 75 parent 0.06 5.913e-02 8.659e-04 1 3.402 #> 100 parent NA 4.969e-03 NA 1 3.402 #> 100 parent NA 4.969e-03 NA 1 3.402 #> 120 parent NA 6.852e-04 NA 1 3.402 #> 120 parent NA 6.852e-04 NA 1 3.402 #> 0 m1 0.00 0.000e+00 0.000e+00 2 2.722 #> 0 m1 0.00 0.000e+00 0.000e+00 2 2.722 #> 1 m1 4.84 4.813e+00 2.672e-02 2 2.722 #> 1 m1 5.64 4.813e+00 8.267e-01 2 2.722 #> 3 m1 12.91 1.305e+01 -1.378e-01 2 2.722 #> 3 m1 12.96 1.305e+01 -8.778e-02 2 2.722 #> 7 m1 22.97 2.508e+01 -2.106e+00 2 2.722 #> 7 m1 24.47 2.508e+01 -6.061e-01 2 2.722 #> 14 m1 41.69 3.671e+01 4.983e+00 2 2.722 #> 14 m1 33.21 3.671e+01 -3.497e+00 2 2.722 #> 21 m1 44.37 4.165e+01 2.719e+00 2 2.722 #> 21 m1 46.44 4.165e+01 4.789e+00 2 2.722 #> 35 m1 41.22 4.329e+01 -2.069e+00 2 2.722 #> 35 m1 37.95 4.329e+01 -5.339e+00 2 2.722 #> 50 m1 41.19 4.119e+01 -3.394e-03 2 2.722 #> 50 m1 40.01 4.119e+01 -1.183e+00 2 2.722 #> 75 m1 40.09 3.644e+01 3.652e+00 2 2.722 #> 75 m1 33.85 3.644e+01 -2.588e+00 2 2.722 #> 100 m1 31.04 3.199e+01 -9.497e-01 2 2.722 #> 100 m1 33.13 3.199e+01 1.140e+00 2 2.722 #> 120 m1 25.15 2.881e+01 -3.659e+00 2 2.722 #> 120 m1 33.31 2.881e+01 4.501e+00 2 2.722