From 7091d3738e7e55acb20edb88772b228f6f5b6c98 Mon Sep 17 00:00:00 2001
From: Johannes Ranke Implement a likelihood ratio test as a method for ‘lrtest’ from the lmtest package Add an ‘update’ method for mkinfit objects which remembers fitted parameters if appropriate Add a ‘residuals’ method for mkinfit objects that supports scaling based on the error model Fix a bug in ‘mkinfit’ that prevented summaries of objects fitted with fixed parameters to be generated Add ‘parms’ and ‘confint’ methods for mkinfit objects. Confidence intervals based on the quadratic approximation as in the summary, and based on the profile likelihood Move long-running tests to tests/testthat/slow with a separate test log. They currently take around 7 minutes on my system ‘mkinfit’: Clean the code and return functions to calculate the log-likelihood and the sum of squared residuals
+
Extract model parameters from mkinfit models
Confidence intervals for parameters of mkinfit objects
Summary method for class "mkinfit"
Summary method for class "mkinfit"
Extract model parameters from mkinfit models
Calculated the log-likelihood of a fitted mkinfit object
Confidence intervals for parameters of mkinfit objects
Function to plot residuals stored in an mkin object
Update an mkinfit model with different arguments
Function to plot the confidence intervals obtained using mkinfit
Likelihood ratio test for mkinfit models
Function to plot squared residuals and the error model for an mkin object
Calculate the minimum error to assume in order to pass the variance test
Calculate the minimum error to assume in order to pass the variance test
Export a list of datasets format to a CAKE study file
Export a list of datasets format to a CAKE study file
Calculated the log-likelihood of a fitted mkinfit object
Extract residuals from an mkinfit model
Function to plot residuals stored in an mkin object
Function to plot the confidence intervals obtained using mkinfit
Function to plot squared residuals and the error model for an mkin object
This function simply calculates the product of the likelihood densities
-calculated using dnorm, i.e. assuming normal distribution,
-with of the mean predicted by the degradation model, and the standard
-deviation predicted by the error model.
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.
# S3 method for mkinfit diff --git a/docs/reference/lrtest.mkinfit.html b/docs/reference/lrtest.mkinfit.html new file mode 100644 index 00000000..dd47d91d --- /dev/null +++ b/docs/reference/lrtest.mkinfit.html @@ -0,0 +1,231 @@ + + + + + + + + +Likelihood ratio test for mkinfit models — lrtest.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + diff --git a/docs/reference/mkinfit.html b/docs/reference/mkinfit.html index 6c98bc38..c72d1cd0 100644 --- a/docs/reference/mkinfit.html +++ b/docs/reference/mkinfit.html @@ -218,7 +218,9 @@ must be given.+ + + + + + +++ + + +++ +++ +Likelihood ratio test for mkinfit models
+ ++lrtest.mkinfit.Rd++ +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.
+# S3 method for mkinfit +lrtest(object, object_2 = NULL, ...)+ +Arguments
++
+ ++ + +object ++ An
mkinfitobject+ +object_2 ++ Optionally, another mkinfit object fitted to the same data.
+ +... ++ Argument to
mkinfit, passed to +update.mkinfitfor creating the alternative fitted object.Details
+ +Alternatively, an argument to mkinfit can be given which is then passed +to
+update.mkinfitto 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#> 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#> Error in mkinfit(mkinmod = "DFOP", observed = test_data, quiet = TRUE, error_model = "tc", parms.ini = c(k1 = 0.359673923258109, k2 = 0.0219997339436148, g = 0.692423284341522), state.ini = c(parent = 103.83323992643)): Objekt 'test_data' nicht gefunden#> Error in mkinfit(mkinmod = "DFOP", observed = test_data, quiet = TRUE, fixed_parms = ..1, parms.ini = c(k1 = 0.359673923258109, k2 = 0.0219997339436148, g = 0.692423284341522), state.ini = c(parent = 103.83323992643)): Objekt 'test_data' nicht gefunden# } +fixed_parms +rather kept at the values specified in The names of parameters that should not be optimised but -rather kept at the values specified in
parms.ini.parms.ini. Alternatively, +a named numeric vector of parameters to be fixed, regardless of the values +in parms.ini.fixed_initials @@ -400,15 +402,15 @@ estimators. fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) summary(fit)#> mkin version used for fitting: 0.9.49.6 #> R version used for fitting: 3.6.1 -#> Date of fit: Fri Oct 25 02:08:07 2019 -#> Date of summary: Fri Oct 25 02:08:07 2019 +#> Date of fit: Thu Oct 31 01:48:29 2019 +#> Date of summary: Thu Oct 31 01:48:29 2019 #> #> 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.453 s +#> Fitted using 222 model solutions performed in 0.455 s #> #> Error model: Constant variance #> @@ -480,7 +482,7 @@ estimators. 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)))#> Warning: Observations with value of zero were removed from the data#> User System verstrichen -#> 1.447 0.000 1.448coef(fit)#> NULLendpoints(fit)#> $ff +#> 1.464 0.000 1.465coef(fit)#> NULLendpoints(fit)#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 #> @@ -553,7 +555,7 @@ estimators. #> Sum of squared residuals at call 126: 371.2134 #> Sum of squared residuals at call 135: 371.2134 #> Negative log-likelihood at call 145: 97.22429#>#> User System verstrichen -#> 1.032 0.000 1.032coef(fit.deSolve)#> NULLendpoints(fit.deSolve)#> $ff +#> 1.047 0.000 1.047coef(fit.deSolve)#> NULLendpoints(fit.deSolve)#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 #> @@ -589,8 +591,8 @@ estimators. 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)#> Warning: Observations with value of zero were removed from the datasummary(f.noweight)#> mkin version used for fitting: 0.9.49.6 #> R version used for fitting: 3.6.1 -#> Date of fit: Fri Oct 25 02:08:22 2019 -#> Date of summary: Fri Oct 25 02:08:22 2019 +#> Date of fit: Thu Oct 31 01:48:44 2019 +#> Date of summary: Thu Oct 31 01:48:44 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -598,7 +600,7 @@ estimators. #> #> Model predictions using solution type deSolve #> -#> Fitted using 421 model solutions performed in 1.062 s +#> Fitted using 421 model solutions performed in 1.136 s #> #> Error model: Constant variance #> @@ -706,8 +708,8 @@ estimators. #> 120 m1 25.15 28.78984 -3.640e+00 #> 120 m1 33.31 28.78984 4.520e+00f.obs <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "obs", quiet = TRUE)#> Warning: Observations with value of zero were removed from the datasummary(f.obs)#> mkin version used for fitting: 0.9.49.6 #> R version used for fitting: 3.6.1 -#> Date of fit: Fri Oct 25 02:08:25 2019 -#> Date of summary: Fri Oct 25 02:08:25 2019 +#> Date of fit: Thu Oct 31 01:48:47 2019 +#> Date of summary: Thu Oct 31 01:48:47 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -715,7 +717,7 @@ estimators. #> #> Model predictions using solution type deSolve #> -#> Fitted using 978 model solutions performed in 2.523 s +#> Fitted using 978 model solutions performed in 2.512 s #> #> Error model: Variance unique to each observed variable #> @@ -838,8 +840,8 @@ estimators. #> 120 m1 25.15 28.80429 -3.654e+00 #> 120 m1 33.31 28.80429 4.506e+00f.tc <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "tc", quiet = TRUE)#> Warning: Observations with value of zero were removed from the datasummary(f.tc)#> mkin version used for fitting: 0.9.49.6 #> R version used for fitting: 3.6.1 -#> Date of fit: Fri Oct 25 02:08:34 2019 -#> Date of summary: Fri Oct 25 02:08:34 2019 +#> Date of fit: Thu Oct 31 01:48:56 2019 +#> Date of summary: Thu Oct 31 01:48:56 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -847,7 +849,7 @@ estimators. #> #> Model predictions using solution type deSolve #> -#> Fitted using 2289 model solutions performed in 9.136 s +#> Fitted using 2289 model solutions performed in 9.124 s #> #> Error model: Two-component variance function #> diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html new file mode 100644 index 00000000..90cbec1a --- /dev/null +++ b/docs/reference/reexports.html @@ -0,0 +1,180 @@ + + + + + + + + +Objects exported from other packages — reexports • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + diff --git a/docs/reference/residuals.mkinfit.html b/docs/reference/residuals.mkinfit.html new file mode 100644 index 00000000..7dd25012 --- /dev/null +++ b/docs/reference/residuals.mkinfit.html @@ -0,0 +1,196 @@ + + + + + + + + ++ + + + + + +++ + + +++ +++ +Objects exported from other packages
+ ++reexports.Rd++ + + + +These objects are imported from other packages. Follow the links +below to see their documentation.
++
+- lmtest
- + +
Extract residuals from an mkinfit model — residuals.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + diff --git a/docs/reference/update.mkinfit.html b/docs/reference/update.mkinfit.html new file mode 100644 index 00000000..b4040a1b --- /dev/null +++ b/docs/reference/update.mkinfit.html @@ -0,0 +1,544 @@ + + + + + + + + ++ + + + + + +++ + + +++ +++ +Extract residuals from an mkinfit model
+ ++residuals.mkinfit.Rd++ +Extract residuals from an mkinfit model
+# S3 method for mkinfit +residuals(object, standardized = FALSE, ...)+ +Arguments
++
+ + ++ + +object ++ An
mkinfitobject+ +standardized ++ Should the residuals be standardized by dividing by the +standard deviation obtained from the fitted error model?
+ +... ++ Not used
Examples
++#> [1] 0.09726306 -0.13912135 -0.15351176 0.73388319 -0.08657030 -0.93204730 +#> [7] -0.03269102 1.45347805 -0.88423710#> [1] 0.13969820 -0.19981894 -0.22048777 1.05407086 -0.12434027 -1.33869248 +#> [7] -0.04695387 2.08761953 -1.27002305Update an mkinfit model with different arguments — update.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 9e3363ba..3767bdda 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -72,6 +72,9 @@+ + + + + + +++ + + +++ +++ +Update an mkinfit model with different arguments
+ ++update.mkinfit.Rd++ +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.
+# S3 method for mkinfit +update(object, ..., evaluate = TRUE)+ +Arguments
++
+ + ++ + +object ++ An mkinfit object to be updated
+ +... ++ Arguments to
mkinfitthat 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("DFOP", subset(FOCUS_2006_D, value != 0), quiet = TRUE) +update(fit, error_model = "tc")#> $par +#> parent_0 log_k1 log_k2 g_ilr sigma_low rsd_high +#> 100.85489822 8.84468217 -2.29693632 -14.95263998 0.00375222 0.06763435 +#> +#> $objective +#> [1] 19.40656 +#> +#> $convergence +#> [1] 0 +#> +#> $iterations +#> [1] 120 +#> +#> $evaluations +#> function gradient +#> 144 847 +#> +#> $message +#> [1] "relative convergence (4)" +#> +#> $logLik +#> [1] -19.40656 +#> +#> $d_3_message +#> threestep +#> "Three-step fitting yielded a higher likelihood than direct fitting" +#> +#> $hessian +#> parent_0 log_k1 log_k2 g_ilr sigma_low +#> parent_0 3.662473e-01 -2.914408e-16 -7.241561e+01 -3.021629e-08 1.923504e+01 +#> log_k1 -2.914408e-16 0.000000e+00 -2.215935e-13 -7.291307e-25 3.416474e-15 +#> log_k2 -7.241561e+01 -2.215935e-13 3.127457e+04 6.766544e-06 -1.495826e+04 +#> g_ilr -3.021629e-08 -7.291307e-25 6.766544e-06 3.122099e-09 -1.797429e-06 +#> sigma_low 1.923504e+01 3.416474e-15 -1.495826e+04 -1.797429e-06 7.759299e+04 +#> rsd_high 3.902119e+00 -1.801019e-16 -1.685343e+02 -3.750713e-07 3.984179e+03 +#> rsd_high +#> parent_0 3.902119e+00 +#> log_k1 -1.801019e-16 +#> log_k2 -1.685343e+02 +#> g_ilr -3.750713e-07 +#> sigma_low 3.984179e+03 +#> rsd_high 7.188991e+03 +#> +#> $hessian_notrans +#> parent_0 k1 k2 g sigma_low +#> parent_0 3.662473e-01 -3.714445e-19 -7.201669e+02 -3.261485e+01 1.923504e+01 +#> k1 -3.714445e-19 0.000000e+00 -4.258512e-15 7.218123e-21 4.355854e-18 +#> k2 -7.201669e+02 -4.258512e-15 3.092510e+06 7.263235e+04 -1.456870e+05 +#> g -3.261485e+01 7.218123e-21 7.263235e+04 3.291750e+03 -1.939948e+03 +#> sigma_low 1.923504e+01 4.355854e-18 -1.456870e+05 -1.939948e+03 7.759299e+04 +#> rsd_high 3.902119e+00 -2.259812e-19 -1.779680e+03 -4.048658e+02 3.984179e+03 +#> rsd_high +#> parent_0 3.902119e+00 +#> k1 -2.259812e-19 +#> k2 -1.779680e+03 +#> g -4.048658e+02 +#> sigma_low 3.984179e+03 +#> rsd_high 7.188991e+03 +#> +#> $call +#> mkinfit(mkinmod = "DFOP", observed = subset(FOCUS_2006_D, value != +#> 0), parms.ini = c(k1 = 0.699298911979803, k2 = 0.0899931270871125, +#> g = 0.0923391681138686), state.ini = c(parent = 101.948852047129), +#> quiet = TRUE, error_model = "tc") +#> +#> $error_model_algorithm +#> [1] "d_3" +#> +#> $solution_type +#> [1] "analytical" +#> +#> $transform_rates +#> [1] TRUE +#> +#> $transform_fractions +#> [1] TRUE +#> +#> $reweight.tol +#> [1] 1e-08 +#> +#> $reweight.max.iter +#> [1] 10 +#> +#> $control +#> $control$eval.max +#> [1] 300 +#> +#> $control$iter.max +#> [1] 200 +#> +#> +#> $calls +#> [1] 3105 +#> +#> $time +#> User System verstrichen +#> 10.314 0.000 10.320 +#> +#> $mkinmod +#> <mkinmod> model generated with +#> Use of formation fractions $use_of_ff: min +#> Specification $spec: +#> $parent +#> $type: DFOP; $sink: TRUE +#> Differential 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 +#> +#> $observed +#> name time value +#> 1 parent 0 99.46 +#> 2 parent 0 102.04 +#> 3 parent 1 93.50 +#> 4 parent 1 92.50 +#> 5 parent 3 63.23 +#> 6 parent 3 68.99 +#> 7 parent 7 52.32 +#> 8 parent 7 55.13 +#> 9 parent 14 27.27 +#> 10 parent 14 26.64 +#> 11 parent 21 11.50 +#> 12 parent 21 11.64 +#> 13 parent 35 2.85 +#> 14 parent 35 2.91 +#> 15 parent 50 0.69 +#> 16 parent 50 0.63 +#> 17 parent 75 0.05 +#> 18 parent 75 0.06 +#> +#> $obs_vars +#> [1] "parent" +#> +#> $predicted +#> name time value +#> 1 parent 0.0000000 100.85489822 +#> 2 parent 0.7575758 93.45650191 +#> 3 parent 1.0000000 91.20560523 +#> 4 parent 1.5151515 86.60082860 +#> 5 parent 2.2727273 80.24806580 +#> 6 parent 3.0000000 74.58828105 +#> 7 parent 3.0303030 74.36132158 +#> 8 parent 3.7878788 68.90641029 +#> 9 parent 4.5454545 63.85165403 +#> 10 parent 5.3030303 59.16769870 +#> 11 parent 6.0606061 54.82734352 +#> 12 parent 6.8181818 50.80538306 +#> 13 parent 7.0000000 49.88485755 +#> 14 parent 7.5757576 47.07846089 +#> 15 parent 8.3333333 43.62493394 +#> 16 parent 9.0909091 40.42474681 +#> 17 parent 9.8484848 37.45931528 +#> 18 parent 10.6060606 34.71141842 +#> 19 parent 11.3636364 32.16509858 +#> 20 parent 12.1212121 29.80556871 +#> 21 parent 12.8787879 27.61912649 +#> 22 parent 13.6363636 25.59307475 +#> 23 parent 14.0000000 24.67405211 +#> 24 parent 14.3939394 23.71564776 +#> 25 parent 15.1515152 21.97594287 +#> 26 parent 15.9090909 20.36385722 +#> 27 parent 16.6666667 18.87002909 +#> 28 parent 17.4242424 17.48578345 +#> 29 parent 18.1818182 16.20308170 +#> 30 parent 18.9393939 15.01447489 +#> 31 parent 19.6969697 13.91306051 +#> 32 parent 20.4545455 12.89244241 +#> 33 parent 21.0000000 12.20428157 +#> 34 parent 21.2121212 11.94669362 +#> 35 parent 21.9696970 11.07032198 +#> 36 parent 22.7272727 10.25823818 +#> 37 parent 23.4848485 9.50572628 +#> 38 parent 24.2424242 8.80841627 +#> 39 parent 25.0000000 8.16225872 +#> 40 parent 25.7575758 7.56350125 +#> 41 parent 26.5151515 7.00866672 +#> 42 parent 27.2727273 6.49453311 +#> 43 parent 28.0303030 6.01811471 +#> 44 parent 28.7878788 5.57664485 +#> 45 parent 29.5454545 5.16755983 +#> 46 parent 30.3030303 4.78848399 +#> 47 parent 31.0606061 4.43721595 +#> 48 parent 31.8181818 4.11171583 +#> 49 parent 32.5757576 3.81009336 +#> 50 parent 33.3333333 3.53059697 +#> 51 parent 34.0909091 3.27160354 +#> 52 parent 34.8484848 3.03160906 +#> 53 parent 35.0000000 2.98576554 +#> 54 parent 35.6060606 2.80921981 +#> 55 parent 36.3636364 2.60314433 +#> 56 parent 37.1212121 2.41218590 +#> 57 parent 37.8787879 2.23523557 +#> 58 parent 38.6363636 2.07126576 +#> 59 parent 39.3939394 1.91932426 +#> 60 parent 40.1515152 1.77852870 +#> 61 parent 40.9090909 1.64806147 +#> 62 parent 41.6666667 1.52716489 +#> 63 parent 42.4242424 1.41513691 +#> 64 parent 43.1818182 1.31132694 +#> 65 parent 43.9393939 1.21513214 +#> 66 parent 44.6969697 1.12599389 +#> 67 parent 45.4545455 1.04339454 +#> 68 parent 46.2121212 0.96685442 +#> 69 parent 46.9696970 0.89592904 +#> 70 parent 47.7272727 0.83020652 +#> 71 parent 48.4848485 0.76930520 +#> 72 parent 49.2424242 0.71287140 +#> 73 parent 50.0000000 0.66057741 +#> 74 parent 50.7575758 0.61211954 +#> 75 parent 51.5151515 0.56721639 +#> 76 parent 52.2727273 0.52560719 +#> 77 parent 53.0303030 0.48705031 +#> 78 parent 53.7878788 0.45132184 +#> 79 parent 54.5454545 0.41821430 +#> 80 parent 55.3030303 0.38753542 +#> 81 parent 56.0606061 0.35910705 +#> 82 parent 56.8181818 0.33276409 +#> 83 parent 57.5757576 0.30835357 +#> 84 parent 58.3333333 0.28573373 +#> 85 parent 59.0909091 0.26477320 +#> 86 parent 59.8484848 0.24535028 +#> 87 parent 60.6060606 0.22735216 +#> 88 parent 61.3636364 0.21067432 +#> 89 parent 62.1212121 0.19521992 +#> 90 parent 62.8787879 0.18089921 +#> 91 parent 63.6363636 0.16762901 +#> 92 parent 64.3939394 0.15533228 +#> 93 parent 65.1515152 0.14393759 +#> 94 parent 65.9090909 0.13337879 +#> 95 parent 66.6666667 0.12359454 +#> 96 parent 67.4242424 0.11452804 +#> 97 parent 68.1818182 0.10612662 +#> 98 parent 68.9393939 0.09834151 +#> 99 parent 69.6969697 0.09112749 +#> 100 parent 70.4545455 0.08444266 +#> 101 parent 71.2121212 0.07824822 +#> 102 parent 71.9696970 0.07250818 +#> 103 parent 72.7272727 0.06718920 +#> 104 parent 73.4848485 0.06226042 +#> 105 parent 74.2424242 0.05769319 +#> 106 parent 75.0000000 0.05346100 +#> +#> $rss +#> function (P) +#> cost_function(P, OLS = TRUE, update_data = FALSE) +#> <bytecode: 0x555557c557c8> +#> <environment: 0x55555bb0e330> +#> +#> $ll +#> function (P, fixed_degparms = FALSE, fixed_errparms = FALSE) +#> { +#> -cost_function(P, trans = FALSE, fixed_degparms = fixed_degparms, +#> fixed_errparms = fixed_errparms, OLS = FALSE, update_data = FALSE) +#> } +#> <bytecode: 0x555557c55bf0> +#> <environment: 0x55555bb0e330> +#> +#> $start +#> value type +#> parent_0 101.94885205 state +#> k1 0.69929891 deparm +#> k2 0.08999313 deparm +#> g 0.09233917 deparm +#> sigma_low 0.10000000 error +#> rsd_high 0.10000000 error +#> +#> $start_transformed +#> value lower upper +#> parent_0 101.948852 -Inf Inf +#> log_k1 -0.357677 -Inf Inf +#> log_k2 -2.408022 -Inf Inf +#> g_ilr -1.616024 -Inf Inf +#> sigma_low 0.100000 0 Inf +#> rsd_high 0.100000 0 Inf +#> +#> $fixed +#> [1] value type +#> <0 Zeilen> (oder row.names mit Länge 0) +#> +#> $data +#> time variable observed predicted residual +#> 1 0 parent 99.46 100.8548982 -1.39489822 +#> 2 0 parent 102.04 100.8548982 1.18510178 +#> 3 1 parent 93.50 91.2056052 2.29439477 +#> 4 1 parent 92.50 91.2056052 1.29439477 +#> 5 3 parent 63.23 74.5882810 -11.35828105 +#> 6 3 parent 68.99 74.5882810 -5.59828105 +#> 7 7 parent 52.32 49.8848576 2.43514245 +#> 8 7 parent 55.13 49.8848576 5.24514245 +#> 9 14 parent 27.27 24.6740521 2.59594789 +#> 10 14 parent 26.64 24.6740521 1.96594789 +#> 11 21 parent 11.50 12.2042816 -0.70428157 +#> 12 21 parent 11.64 12.2042816 -0.56428157 +#> 13 35 parent 2.85 2.9857655 -0.13576554 +#> 14 35 parent 2.91 2.9857655 -0.07576554 +#> 15 50 parent 0.69 0.6605774 0.02942259 +#> 16 50 parent 0.63 0.6605774 -0.03057741 +#> 17 75 parent 0.05 0.0534610 -0.00346100 +#> 18 75 parent 0.06 0.0534610 0.00653900 +#> +#> $atol +#> [1] 1e-08 +#> +#> $rtol +#> [1] 1e-10 +#> +#> $err_mod +#> [1] "tc" +#> +#> $bparms.optim +#> parent_0 k1 k2 g +#> 1.008549e+02 6.937399e+03 1.005665e-01 6.551046e-10 +#> +#> $bparms.fixed +#> numeric(0) +#> +#> $bparms.ode +#> k1 k2 g +#> 6.937399e+03 1.005665e-01 6.551046e-10 +#> +#> $bparms.state +#> parent +#> 100.8549 +#> +#> $errparms +#> sigma_low rsd_high +#> 0.00375222 0.06763435 +#> +#> $df.residual +#> [1] 12 +#> +#> $date +#> [1] "Thu Oct 31 01:49:09 2019" +#> +#> $version +#> [1] "0.9.49.6" +#> +#> $Rversion +#> [1] "3.6.1" +#> +#> attr(,"class") +#> [1] "mkinfit" "modFit"# } ++ https://pkgdown.jrwb.de/mkin/reference/logistic.solution.html + https://pkgdown.jrwb.de/mkin/reference/lrtest.mkinfit.html +@@ -138,6 +141,12 @@ https://pkgdown.jrwb.de/mkin/reference/max_twa_parent.html + https://pkgdown.jrwb.de/mkin/reference/print.mkinmod.html + +https://pkgdown.jrwb.de/mkin/reference/reexports.html ++ https://pkgdown.jrwb.de/mkin/reference/residuals.mkinfit.html +@@ -156,6 +165,9 @@ https://pkgdown.jrwb.de/mkin/reference/schaefer07_complex_case.html + https://pkgdown.jrwb.de/mkin/reference/transform_odeparms.html + https://pkgdown.jrwb.de/mkin/reference/update.mkinfit.html +diff --git a/man/confint.mkinfit.Rd b/man/confint.mkinfit.Rd index bad73407..ee07c9c1 100644 --- a/man/confint.mkinfit.Rd +++ b/man/confint.mkinfit.Rd @@ -71,7 +71,8 @@ system.time(ci_profile <- confint(f_d_1, cores = 1, quiet = TRUE)) # c("k_parent_sink", "k_parent_m1", "k_m1_sink", "sigma"), cores = 1)) # If we exclude parent_0 (the confidence of which is often of minor interest), we get a nice # performance improvement from about 30 seconds to about 12 seconds -# system.time(ci_profile_no_parent_0 <- confint(f_d_1, c("k_parent_sink", "k_parent_m1", "k_m1_sink", "sigma"), cores = 4)) +# system.time(ci_profile_no_parent_0 <- confint(f_d_1, +# c("k_parent_sink", "k_parent_m1", "k_m1_sink", "sigma"), cores = 4)) ci_profile ci_quadratic_transformed <- confint(f_d_1, method = "quadratic") ci_quadratic_transformed diff --git a/man/logLik.mkinfit.Rd b/man/logLik.mkinfit.Rd index bb2c2957..502fb4d7 100644 --- a/man/logLik.mkinfit.Rd +++ b/man/logLik.mkinfit.Rd @@ -17,10 +17,11 @@ An object of class \code{\link{logLik}} with the number of estimated as attribute. } \description{ -This function simply calculates the product of the likelihood densities -calculated using \code{\link{dnorm}}, i.e. assuming normal distribution, -with of the mean predicted by the degradation model, and the standard -deviation predicted by the error model. +This function returns the product of the likelihood densities of each +observed value, as calculated as part of the fitting procedure using +\code{\link{dnorm}}, i.e. assuming normal distribution, and with the means +predicted by the degradation model, and the standard deviations predicted by +the error model. } \details{ The total number of estimated parameters returned with the value of the diff --git a/man/lrtest.mkinfit.Rd b/man/lrtest.mkinfit.Rd new file mode 100644 index 00000000..b38732b4 --- /dev/null +++ b/man/lrtest.mkinfit.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lrtest.mkinfit.R +\name{lrtest.mkinfit} +\alias{lrtest.mkinfit} +\title{Likelihood ratio test for mkinfit models} +\usage{ +\method{lrtest}{mkinfit}(object, object_2 = NULL, ...) +} +\arguments{ +\item{object}{An \code{\link{mkinfit}} object} + +\item{object_2}{Optionally, another mkinfit object fitted to the same data.} + +\item{\dots}{Argument to \code{\link{mkinfit}}, passed to +\code{\link{update.mkinfit}} for creating the alternative fitted object.} +} +\description{ +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. +} +\details{ +Alternatively, an argument to mkinfit can be given which is then passed +to \code{\link{update.mkinfit}} to obtain the alternative model. + +The comparison is then made by the \code{\link[lmtest]{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) +lrtest(sfo_fit, dfop_fit) +lrtest(dfop_fit, error_model = "tc") +lrtest(dfop_fit, fixed_parms = c(k2 = 0)) +} +} diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index d9afb753..e58e61e2 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -65,7 +65,9 @@ default values. Otherwise, inital values for all error model parameters must be given.} \item{fixed_parms}{The names of parameters that should not be optimised but -rather kept at the values specified in \code{parms.ini}.} +rather kept at the values specified in \code{parms.ini}. Alternatively, +a named numeric vector of parameters to be fixed, regardless of the values +in parms.ini.} \item{fixed_initials}{The names of model variables for which the initial state at time 0 should be excluded from the optimisation. Defaults to all diff --git a/man/reexports.Rd b/man/reexports.Rd new file mode 100644 index 00000000..bb77acc5 --- /dev/null +++ b/man/reexports.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lrtest.mkinfit.R +\docType{import} +\name{reexports} +\alias{reexports} +\alias{lrtest} +\title{Objects exported from other packages} +\keyword{internal} +\description{ +These objects are imported from other packages. Follow the links +below to see their documentation. + +\describe{ + \item{lmtest}{\code{\link[lmtest]{lrtest}}} +}} + diff --git a/man/residuals.mkinfit.Rd b/man/residuals.mkinfit.Rd new file mode 100644 index 00000000..407b89b9 --- /dev/null +++ b/man/residuals.mkinfit.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/residuals.mkinfit.R +\name{residuals.mkinfit} +\alias{residuals.mkinfit} +\title{Extract residuals from an mkinfit model} +\usage{ +\method{residuals}{mkinfit}(object, standardized = FALSE, ...) +} +\arguments{ +\item{object}{An \code{\link{mkinfit}} object} + +\item{standardized}{Should the residuals be standardized by dividing by the +standard deviation obtained from the fitted error model?} + +\item{\dots}{Not used} +} +\description{ +Extract residuals from an mkinfit model +} +\examples{ +f <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE) +residuals(f) +residuals(f, standardized = TRUE) +} diff --git a/man/update.mkinfit.Rd b/man/update.mkinfit.Rd new file mode 100644 index 00000000..aae1fbb4 --- /dev/null +++ b/man/update.mkinfit.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/update.mkinfit.R +\name{update.mkinfit} +\alias{update.mkinfit} +\title{Update an mkinfit model with different arguments} +\usage{ +\method{update}{mkinfit}(object, ..., evaluate = TRUE) +} +\arguments{ +\item{object}{An mkinfit object to be updated} + +\item{\dots}{Arguments to \code{\link{mkinfit}} that should replace +the arguments from the original call. Arguments set to NULL will +remove arguments given in the original call} + +\item{evaluate}{Should the call be evaluated or returned as a call} +} +\description{ +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. +} +\examples{ +\dontrun{ +fit <- mkinfit("DFOP", subset(FOCUS_2006_D, value != 0), quiet = TRUE) +update(fit, error_model = "tc") +} +} diff --git a/test.log b/test.log index da9af79e..7b397ee1 100644 --- a/test.log +++ b/test.log @@ -1,31 +1,34 @@ Loading mkin Testing mkin +Successfully compiled differential equation model from auto-generated C code. ✔ | OK F W S | Context ✔ | 2 | Export dataset for reading into CAKE -✔ | 10 | Confidence intervals and p-values [12.8 s] -✔ | 10 | Error model fitting [37.1 s] +✔ | 10 | Confidence intervals and p-values [10.2 s] +✔ | 10 | Error model fitting [38.3 s] ✔ | 5 | Calculation of FOCUS chi2 error levels [3.5 s] -✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.4 s] +✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [3.3 s] ✔ | 6 | Test fitting the decline of metabolites from their maximum [0.9 s] ✔ | 1 | Fitting the logistic model [0.9 s] ✔ | 1 | Test dataset class mkinds used in gmkin ✔ | 12 | Special cases of mkinfit calls [2.7 s] ✔ | 9 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.3 s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.0 s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2 s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [4.1 s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3 s] ✔ | 3 | Summary ✔ | 11 | Plotting [0.6 s] ✔ | 3 | AIC calculation +✔ | 2 | Residuals extracted from mkinfit models ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] ✔ | 4 | Fitting the SFORB model [1.7 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.2 s] +✔ | 5 | Hypothesis tests [9.9 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 84.5 s +Duration: 91.5 s -OK: 120 +OK: 127 Failed: 0 Warnings: 0 Skipped: 0 diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index c9da7d61..942d56e1 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2019-10-28 +Date: 2019-10-31 Optimiser: IRLS [Data] diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index cfa978fc..fc972a3d 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -14,6 +14,27 @@ if (Sys.getenv("TRAVIS") != "") n_cores = 1 # On Windows we would need to make a cluster first if (Sys.info()["sysname"] == "Windows") n_cores = 1 +# We set up some models and fits with nls for comparisons +SFO_trans <- function(t, parent_0, log_k_parent_sink) { + parent_0 * exp(- exp(log_k_parent_sink) * t) +} +SFO_notrans <- function(t, parent_0, k_parent_sink) { + parent_0 * exp(- k_parent_sink * t) +} +f_1_nls_trans <- nls(value ~ SFO_trans(time, parent_0, log_k_parent_sink), + data = FOCUS_2006_A, + start = list(parent_0 = 100, log_k_parent_sink = log(0.1))) +f_1_nls_notrans <- nls(value ~ SFO_notrans(time, parent_0, k_parent_sink), + data = FOCUS_2006_A, + start = list(parent_0 = 100, k_parent_sink = 0.1)) + +f_1_mkin_trans <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE) +f_1_mkin_notrans <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE, + transform_rates = FALSE) + +f_2_mkin <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE) +f_2_nls <- nls(value ~ SSbiexp(time, A1, lrc1, A2, lrc2), data = FOCUS_2006_C) + # mmkin object of parent fits for tests models <- c("SFO", "FOMC", "DFOP", "HS") fits <- mmkin(models, @@ -54,8 +75,8 @@ m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")), M2 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) -f_SFO_lin_mkin_OLS <- mkinfit(m_synth_SFO_lin, SFO_lin_a, quiet = TRUE) -f_SFO_lin_mkin_ML <- mkinfit(m_synth_SFO_lin, SFO_lin_a, quiet = TRUE, +fit_nw_1 <- mkinfit(m_synth_SFO_lin, SFO_lin_a, quiet = TRUE) +fit_nw_1_ML <- mkinfit(m_synth_SFO_lin, SFO_lin_a, quiet = TRUE, error_model = "const", error_model_algorithm = "direct") # We know direct optimization is OK and direct needs 4 sec versus 5.5 for threestep and 6 for IRLS @@ -69,5 +90,14 @@ fit_tc_1 <- mkinfit(m_synth_SFO_lin, SFO_lin_a, error_model = "tc", quiet = TRUE f_tc_2 <- mkinfit(m_synth_DFOP_par, DFOP_par_c, error_model = "tc", error_model_algorithm = "direct", quiet = TRUE) -#f_tc_2_ntf <- mkinfit(m_synth_DFOP_par, DFOP_par_c, error_model = "tc", -# transform_fractions = FALSE, error_model_algorithm = "direct", quiet = TRUE) +# Experimental data for UBA +dfop_sfo_sfo <- mkinmod( + parent = mkinsub("DFOP", to = "A1"), + A1 = mkinsub("SFO", to = "A2"), + A2 = mkinsub("SFO"), + use_of_ff = "max" +) + +f_soil_1_tc <- mkinfit(dfop_sfo_sfo, + experimental_data_for_UBA_2019[[1]]$data, + error_model = "tc", quiet = TRUE) diff --git a/tests/testthat/test_confidence.R b/tests/testthat/test_confidence.R index 5f76c344..2443fa66 100644 --- a/tests/testthat/test_confidence.R +++ b/tests/testthat/test_confidence.R @@ -1,44 +1,21 @@ -# We set up some models and fits with nls for comparisons -SFO_trans <- function(t, parent_0, log_k_parent_sink) { - parent_0 * exp(- exp(log_k_parent_sink) * t) -} -SFO_notrans <- function(t, parent_0, k_parent_sink) { - parent_0 * exp(- k_parent_sink * t) -} -f_1_nls_trans <- nls(value ~ SFO_trans(time, parent_0, log_k_parent_sink), - data = FOCUS_2006_A, - start = list(parent_0 = 100, log_k_parent_sink = log(0.1))) -f_1_nls_notrans <- nls(value ~ SFO_notrans(time, parent_0, k_parent_sink), - data = FOCUS_2006_A, - start = list(parent_0 = 100, k_parent_sink = 0.1)) - -f_1_mkin_OLS <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE) -f_1_mkin_OLS_notrans <- mkinfit("SFO", FOCUS_2006_A, quiet = TRUE, - transform_rates = FALSE) - - -f_2_mkin <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE) -f_2_nls <- nls(value ~ SSbiexp(time, A1, lrc1, A2, lrc2), data = FOCUS_2006_C) - context("Confidence intervals and p-values") test_that("The confint method 'quadratic' is consistent with the summary", { expect_equivalent( - confint(f_SFO_lin_mkin_ML, method = "quadratic"), - summary(f_SFO_lin_mkin_ML)$bpar[, c("Lower", "Upper")]) + confint(fit_nw_1, method = "quadratic"), + summary(fit_nw_1)$bpar[, c("Lower", "Upper")]) expect_equivalent( - confint(f_SFO_lin_mkin_ML, method = "quadratic", backtransform = FALSE), - summary(f_SFO_lin_mkin_ML)$par[, c("Lower", "Upper")]) + confint(fit_nw_1, method = "quadratic", backtransform = FALSE), + summary(fit_nw_1)$par[, c("Lower", "Upper")]) - f_notrans <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE, transform_rates = FALSE) expect_equivalent( - confint(f_notrans, method = "quadratic", transformed = FALSE), - summary(f_notrans)$par[, c("Lower", "Upper")]) + confint(f_1_mkin_notrans, method = "quadratic", transformed = FALSE), + summary(f_1_mkin_notrans)$par[, c("Lower", "Upper")]) expect_equivalent( - confint(f_notrans, method = "quadratic", transformed = FALSE), - summary(f_notrans)$bpar[, c("Lower", "Upper")]) + confint(f_1_mkin_notrans, method = "quadratic", transformed = FALSE), + summary(f_1_mkin_notrans)$bpar[, c("Lower", "Upper")]) }) @@ -46,20 +23,20 @@ test_that("Quadratic confidence intervals for rate constants are comparable to v # Check fitted parameter values expect_equivalent( - (f_1_mkin_OLS$bparms.optim -coef(f_1_nls_notrans))/f_1_mkin_OLS$bparms.optim, + (f_1_mkin_trans$bparms.optim -coef(f_1_nls_notrans))/f_1_mkin_trans$bparms.optim, rep(0, 2), tolerance = 1e-6) expect_equivalent( - (f_1_mkin_OLS$par[1:2] - coef(f_1_nls_trans))/f_1_mkin_OLS$par[1:2], + (f_1_mkin_trans$par[1:2] - coef(f_1_nls_trans))/f_1_mkin_trans$par[1:2], rep(0, 2), tolerance = 1e-6) # Check the standard error for the transformed parameters se_nls <- summary(f_1_nls_trans)$coefficients[, "Std. Error"] # This is of similar magnitude as the standard error obtained with the mkin - se_mkin <- summary(f_1_mkin_OLS)$par[1:2, "Std. Error"] + se_mkin <- summary(f_1_mkin_trans)$par[1:2, "Std. Error"] se_nls_notrans <- summary(f_1_nls_notrans)$coefficients[, "Std. Error"] # This is also of similar magnitude as the standard error obtained with the mkin - se_mkin_notrans <- summary(f_1_mkin_OLS_notrans)$par[1:2, "Std. Error"] + se_mkin_notrans <- summary(f_1_mkin_notrans)$par[1:2, "Std. Error"] # The difference can partly be explained by the ratio between # the maximum likelihood estimate of the standard error sqrt(rss/n) diff --git a/tests/testthat/test_residuals.R b/tests/testthat/test_residuals.R new file mode 100644 index 00000000..0fe05b4f --- /dev/null +++ b/tests/testthat/test_residuals.R @@ -0,0 +1,8 @@ +context("Residuals extracted from mkinfit models") + +test_that("Residuals are correctly returned", { + f <- fits[["FOMC", "FOCUS_C"]] + expect_equal(residuals(f)[1:3], c(-0.7748906, 2.7090589, -1.9451989)) + + expect_equivalent(residuals(f_tc_2, standardized = TRUE)[1:3], c(0.52579103, 0.40714911, 1.66394233)) +}) diff --git a/tests/testthat/test_tests.R b/tests/testthat/test_tests.R new file mode 100644 index 00000000..523edc4a --- /dev/null +++ b/tests/testthat/test_tests.R @@ -0,0 +1,27 @@ +context("Hypothesis tests") + +test_that("The likelihood ratio test works", { + + expect_error(lrtest(fit_tc_1, f_tc_2), "not been fitted to the same data") + + res <- lrtest(fit_nw_1, fit_tc_1) + expect_equal(res[["2", "Pr(>Chisq)"]], 0.9999998) + +}) + +test_that("We can conveniently fix parameters using 'fixed_parms'", { + f_k2_fixed <- mkinfit("DFOP", FOCUS_2006_C, fixed_parms = c(k2 = 0.05), quiet = TRUE) + expect_equivalent(f_k2_fixed$bparms.ode["k2"], 0.05) +}) + +test_that("Updating fitted models works", { + f_dfop_const <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE) + f_dfop_tc <- update(f_dfop_const, error_model = "tc") + + f_soil_1_nw <- update(f_soil_1_tc, error_model = "const") + f_soil_1_nw_A2 <- update(f_soil_1_nw, fixed_parms = c(k_A2 = 0)) + test_nw_tc <- lrtest(f_soil_1_nw, f_soil_1_tc) + expect_equivalent(test_nw_tc[["2", "Pr(>Chisq)"]], 2.113e-6) + test_nw_A2 <- lrtest(f_soil_1_nw, f_soil_1_nw_A2) + expect_equivalent(test_nw_A2[["2", "Pr(>Chisq)"]], 0.9999468) +}) -- cgit v1.2.3 https://pkgdown.jrwb.de/mkin/articles/FOCUS_D.html