aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-04-05 18:55:44 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2019-04-05 18:55:44 +0200
commit5e8190f26611c094a1a5d877a314cbca53e3e530 (patch)
tree6f3163fd1a6d1e64ca7aa4a5bb20b92935998159
parent7a1d3d031aa23fce723ac4f4c8e4bb5d64959447 (diff)
Report negative log-likelihood during fits
If not quiet = TRUE
-rw-r--r--R/mkinfit.R14
1 files changed, 10 insertions, 4 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 796b25c7..73c2f485 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -261,9 +261,6 @@ mkinfit <- function(mkinmod, observed,
max(observed$time),
length.out = n.outtimes))))
- calls <- 0 # Counter for number of model solutions
- out_predicted <- NA
-
# Define log-likelihood function for optimisation, including (back)transformations
nlogLik <- function(P, trans = TRUE)
{
@@ -330,6 +327,11 @@ mkinfit <- function(mkinmod, observed,
nlogLik <- - with(data_log_lik,
sum(dnorm(x = value.x, mean = value.y, sd = std, log = TRUE)))
+
+ if (nlogLik < nlogLik.current) {
+ assign("nlogLik.current", nlogLik, inherits = TRUE)
+ if (!quiet) cat("Negative log-likelihood at call ", calls, ": ", nlogLik.current, "\n", sep = "")
+ }
return(nlogLik)
}
@@ -384,6 +386,10 @@ mkinfit <- function(mkinmod, observed,
lower["a"] <- 0
}
+ # Counter for likelihood evaluations
+ calls = 0
+ nlogLik.current <- Inf
+
# Show parameter names if tracing is requested
if(trace_parms) cat(names_optim, "\n")
@@ -502,7 +508,7 @@ summary.mkinfit <- function(object, data = TRUE, distimes = TRUE, alpha = 0.05,
lci <- param + qt(alpha/2, rdf) * se
uci <- param + qt(1-alpha/2, rdf) * se
}
-
+
beparms.optim <- c(object$bparms.optim, object$par[epnames])
if (!is.numeric(covar_notrans) | is.na(covar_notrans[1])) {
covar_notrans <- NULL

Contact - Imprint