aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/mkinfit.R6
-rw-r--r--tests/testthat/test_error_models.R2
2 files changed, 5 insertions, 3 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 13c7aa90..60697cb1 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -505,13 +505,15 @@ mkinfit <- function(mkinmod, observed,
upper = upper[names(parms.start)],
control = control, ...)
fit$logLik <- - nlogLik.current
+
if (error_model_algorithm == "d_3") {
- if (abs((fit_direct$logLik - fit$logLik))/mean(c(fit_direct$logLik, fit$logLik)) < 0.001) {
+ rel_diff <- abs((fit_direct$logLik - fit$logLik))/-mean(c(fit_direct$logLik, fit$logLik))
+ if (rel_diff < 0.0001) {
if (!quiet) {
message("Direct fitting and three-step fitting yield approximately the same likelihood")
}
} else {
- if (fit_direct$logLik < fit$logLik) {
+ if (fit$logLik > fit_direct$logLik) {
if (!quiet) message("Three-step fitting yielded a higher likelihood than direct fitting")
} else {
if (!quiet) message("Direct fitting yielded a higher likelihood than three-step fitting")
diff --git a/tests/testthat/test_error_models.R b/tests/testthat/test_error_models.R
index 6bb93d48..404f02ab 100644
--- a/tests/testthat/test_error_models.R
+++ b/tests/testthat/test_error_models.R
@@ -181,7 +181,7 @@ test_that("Reweighting method 'tc' produces reasonable variance estimates", {
test_that("The different error model fitting methods work for parent fits", {
skip_on_cran()
- f_9_OLS <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data,
+ f_9_OLS <- mkinfit("SFO", experimental_data_for_UBA_2019[[9]]$data,
quiet = TRUE)
expect_equivalent(round(AIC(f_9_OLS), 2), 137.43)

Contact - Imprint