From c322a8102a399cbb1fe38c4c4ca4485cea8bc4e8 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 7 May 2019 08:43:12 +0200 Subject: Fix hessian calculations Static documentation rebuilt by pkgdown --- R/mkinfit.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'R') diff --git a/R/mkinfit.R b/R/mkinfit.R index 664419be..5e7b5bd3 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -343,14 +343,15 @@ mkinfit <- function(mkinmod, observed, data_log_lik <- merge(observed[c("name", "time", "value", "std")], out_long, by = c("name", "time"), suffixes = c(".observed", ".predicted")) - # We only update likelihood and data during the optimisation, not during hessian calculations + if (OLS) { + nlogLik <- with(data_log_lik, sum((value.observed - value.predicted)^2)) + } else { + nlogLik <- - with(data_log_lik, + sum(dnorm(x = value.observed, mean = value.predicted, sd = std, log = TRUE))) + } + + # We update the current likelihood and data during the optimisation, not during hessian calculations if (update_data) { - if (OLS) { - nlogLik <- with(data_log_lik, sum((value.observed - value.predicted)^2)) - } else { - nlogLik <- - with(data_log_lik, - sum(dnorm(x = value.observed, mean = value.predicted, sd = std, log = TRUE))) - } assign("out_predicted", out_long, inherits = TRUE) assign("data_errmod", data_log_lik, inherits = TRUE) -- cgit v1.2.1