aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/mkinfit.R10
1 files changed, 8 insertions, 2 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 39d084cb..c98c7586 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -154,8 +154,14 @@ mkinfit <- function(mkinmod, observed,
# Set default for state.ini if appropriate
if (state.ini[1] == "auto") {
- state.ini = c(mean(subset(observed, time == 0 & name == presumed_parent_name)$value),
- rep(0, length(mkinmod$diffs) - 1))
+ presumed_parent_time_0 = subset(observed,
+ time == 0 & name == presumed_parent_name)$value
+ presumed_parent_time_0_mean = mean(presumed_parent_time_0, na.rm = TRUE)
+ if (is.na(presumed_parent_time_0_mean)) {
+ state.ini = c(100, rep(0, length(mkinmod$diffs) - 1))
+ } else {
+ state.ini = c(presumed_parent_time_0_mean, rep(0, length(mkinmod$diffs) - 1))
+ }
}
# Name the inital state variable values if they are not named yet

Contact - Imprint