From 5814be02f286ce96d6cff8d698aea6844e4025f1 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 8 Apr 2019 18:00:25 +0200 Subject: Remove zero observations, adapt logLik Zero observations at time zero made fitting the two-component error model fail. A concentration of exactly zero does not make sense anyways, as we generally have a limit of detection --- R/mkinfit.R | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'R/mkinfit.R') diff --git a/R/mkinfit.R b/R/mkinfit.R index 73c2f485..6c12d027 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -64,6 +64,12 @@ mkinfit <- function(mkinmod, observed, observed <- subset(observed, name %in% obs_vars) observed <- subset(observed, !is.na(value)) + # Also remove zero values to avoid instabilities (e.g. of the 'tc' error model) + if (any(observed$value == 0)) { + warning("Observations with value of zero were removed from the data") + observed <- subset(observed, value != 0) + } + # Obtain data for decline from maximum mean value if requested if (from_max_mean) { # This is only used for simple decline models @@ -405,6 +411,7 @@ mkinfit <- function(mkinmod, observed, } else { if(!quiet) cat("Optimisation successfully terminated.\n") } + fit$logLik <- - nlogLik.current # We need to return some more data for summary and plotting fit$solution_type <- solution_type -- cgit v1.2.1