diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-06-04 21:10:58 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-06-04 21:10:58 +0200 |
commit | 307a317666b8a1cdfe2293371ad8671403680a36 (patch) | |
tree | acb43d723a70065625d8e16e856a4034f04e40a9 | |
parent | 2bc4adb7080e5893ab423768fe2e24777b292f19 (diff) |
Fix a bug introduced in the last commit
-rw-r--r-- | R/mkinfit.R | 6 | ||||
-rw-r--r-- | tests/testthat/test_error_models.R | 2 |
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) |