diff options
-rw-r--r-- | R/mkinpredict.R | 5 | ||||
-rw-r--r-- | R/plot.mkinfit.R | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/R/mkinpredict.R b/R/mkinpredict.R index 5170dc6b..7ce26caf 100644 --- a/R/mkinpredict.R +++ b/R/mkinpredict.R @@ -23,6 +23,11 @@ mkinpredict <- function(mkinmod, odeparms, odeini, outtimes, solution_type = "de # Get the names of the state variables in the model mod_vars <- names(mkinmod$diffs) + # Order the inital values for state variables if they are named + if (!is.null(names(odeini))) { + odeini <- odeini[mod_vars] + } + # Create function for evaluation of expressions with ode parameters and initial values evalparse <- function(string) { diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R index a07ddea1..d4ad6c42 100644 --- a/R/plot.mkinfit.R +++ b/R/plot.mkinfit.R @@ -38,7 +38,10 @@ plot.mkinfit <- function(x, fit = x, rownames(subset(fit$start, type == "state")), rownames(subset(fit$fixed, type == "state"))) odeini <- parms.all[ininames] - names(odeini) <- names(fit$mkinmod$diffs) + + # Order initial state variables + names(odeini) <- sub("_0", "", names(odeini)) + odeini <- odeini[names(fit$mkinmod$diffs)] outtimes <- seq(xlim[1], xlim[2], length.out=100) |