aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/endpoints.R2
-rw-r--r--R/mkinerrmin.R2
-rw-r--r--R/mkinfit.R22
-rw-r--r--R/plot.mkinfit.R5
4 files changed, 17 insertions, 14 deletions
diff --git a/R/endpoints.R b/R/endpoints.R
index 98e290d..163dc8d 100644
--- a/R/endpoints.R
+++ b/R/endpoints.R
@@ -3,7 +3,7 @@ endpoints <- function(fit, pseudoDT50 = FALSE) {
# fractions and SFORB eigenvalues from optimised parameters
ep <- list()
obs_vars <- fit$obs_vars
- parms.all <- fit$parms.all
+ parms.all <- fit$bparms.ode
ep$distimes <- data.frame(DT50 = rep(NA, length(obs_vars)),
DT90 = rep(NA, length(obs_vars)),
row.names = obs_vars)
diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R
index 49538e3..8b1e9b2 100644
--- a/R/mkinerrmin.R
+++ b/R/mkinerrmin.R
@@ -20,7 +20,7 @@
utils::globalVariables(c("name"))
mkinerrmin <- function(fit, alpha = 0.05)
{
- parms.optim <- fit$parms.all
+ parms.optim <- fit$par
kinerrmin <- function(errdata, n.parms) {
means.mean <- mean(errdata$value_mean, na.rm=TRUE)
df = length(errdata$value_mean) - n.parms
diff --git a/R/mkinfit.R b/R/mkinfit.R
index e084cf1..3ca3899 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -191,7 +191,9 @@ mkinfit <- function(mkinmod, observed,
value = c(state.ini.fixed, parms.fixed))
fit$fixed$type = c(rep("state", length(state.ini.fixed)), rep("deparm", length(parms.fixed)))
- parms.all = backtransform_odeparms(c(fit$par, parms.fixed), mod_vars)
+ bparms.optim = backtransform_odeparms(fit$par, mod_vars)
+ bparms.fixed = backtransform_odeparms(c(state.ini.fixed, parms.fixed), mod_vars)
+ bparms.all = c(bparms.optim, bparms.fixed)
# Collect observed, predicted and residuals
data <- merge(fit$observed, fit$predicted, by = c("time", "name"))
@@ -201,8 +203,10 @@ mkinfit <- function(mkinmod, observed,
fit$data <- data[order(data$variable, data$time), ]
fit$atol <- atol
fit$rtol <- rtol
- fit$parms.all <- parms.all # Return all backtransformed parameters for summary
- fit$odeparms.final <- parms.all[mkinmod$parms] # Return ode parameters for further fitting
+ # Return all backtransformed parameters for summary
+ fit$bparms.optim <- bparms.optim
+ fit$bparms.fixed <- bparms.fixed
+ fit$bparms.ode <- bparms.all[mkinmod$parms] # Return ode parameters for further fitting
fit$date <- date()
class(fit) <- c("mkinfit", "modFit")
@@ -231,7 +235,7 @@ summary.mkinfit <- function(object, data = TRUE, distimes = TRUE, ...) {
param <- cbind(param, se)
dimnames(param) <- list(pnames, c("Estimate", "Std. Error"))
- bparam <- as.matrix(object$parms.all)
+ bparam <- as.matrix(object$bparms.optim)
dimnames(bparam) <- list(pnames, c("Estimate"))
ans <- list(
@@ -259,9 +263,9 @@ summary.mkinfit <- function(object, data = TRUE, distimes = TRUE, ...) {
ans$errmin <- mkinerrmin(object, alpha = 0.05)
- ans$parms.all <- object$parms.all
+ ans$bparms.ode <- object$bparms.ode
ep <- endpoints(object)
- if (!is.null(ep$ff))
+ if (length(ep$ff) != 0)
ans$ff <- ep$ff
if(distimes) ans$distimes <- ep$distimes
if(length(ep$SFORB) != 0) ans$SFORB <- ep$SFORB
@@ -305,19 +309,19 @@ print.summary.mkinfit <- function(x, digits = max(3, getOption("digits") - 3), .
if(printdistimes){
cat("\nEstimated disappearance times:\n")
print(x$distimes, digits=digits,...)
- }
+ }
printff <- !is.null(x$ff)
if(printff & x$use_of_ff == "min"){
cat("\nEstimated formation fractions:\n")
print(data.frame(ff = x$ff), digits=digits,...)
- }
+ }
printSFORB <- !is.null(x$SFORB)
if(printSFORB){
cat("\nEstimated Eigenvalues of SFORB model(s):\n")
print(x$SFORB, digits=digits,...)
- }
+ }
printcor <- is.numeric(x$cov.unscaled)
if (printcor){
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R
index fc8ecf7..59ef861 100644
--- a/R/plot.mkinfit.R
+++ b/R/plot.mkinfit.R
@@ -30,9 +30,8 @@ plot.mkinfit <- function(x, fit = x,
add = FALSE, legend = !add, ...)
{
solution_type = fit$solution_type
- fixed <- fit$fixed$value
- names(fixed) <- rownames(fit$fixed)
- parms.all <- c(fit$parms.all, fixed)
+ parms.all <- c(fit$bparms.optim, fit$bparms.fixed)
+
ininames <- c(
rownames(subset(fit$start, type == "state")),
rownames(subset(fit$fixed, type == "state")))

Contact - Imprint