diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-04-08 18:00:25 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-04-08 18:00:25 +0200 |
commit | 5814be02f286ce96d6cff8d698aea6844e4025f1 (patch) | |
tree | bdc45984af83e9629abc968e5dd5193ace2c3a95 /R/mkinfit.R | |
parent | 5e8190f26611c094a1a5d877a314cbca53e3e530 (diff) |
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
Diffstat (limited to 'R/mkinfit.R')
-rw-r--r-- | R/mkinfit.R | 7 |
1 files changed, 7 insertions, 0 deletions
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
|