aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-06-04 19:46:55 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2019-06-04 19:46:55 +0200
commit2bc4adb7080e5893ab423768fe2e24777b292f19 (patch)
tree69bc79d70ae41dd25031a364623bea81abff4ed6
parente36a5db313365bc5acc85126792c767fe18acd71 (diff)
For the d_3 algorithm, report which was better, if any
-rw-r--r--R/mkinfit.R15
1 files changed, 13 insertions, 2 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 33e13d8e..13c7aa90 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -505,8 +505,19 @@ mkinfit <- function(mkinmod, observed,
upper = upper[names(parms.start)],
control = control, ...)
fit$logLik <- - nlogLik.current
- if (error_model_algorithm == "d_3" && fit_direct$logLik > fit$logLik) {
- fit <- fit_direct
+ if (error_model_algorithm == "d_3") {
+ if (abs((fit_direct$logLik - fit$logLik))/mean(c(fit_direct$logLik, fit$logLik)) < 0.001) {
+ if (!quiet) {
+ message("Direct fitting and three-step fitting yield approximately the same likelihood")
+ }
+ } else {
+ if (fit_direct$logLik < fit$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")
+ fit <- fit_direct
+ }
+ }
}
}
if (err_mod != "const" & error_model_algorithm == "IRLS") {

Contact - Imprint