diff options
author | jranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> | 2013-02-18 22:11:49 +0000 |
---|---|---|
committer | jranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> | 2013-02-18 22:11:49 +0000 |
commit | fa10b85d6bb964742d2c5a3e3f633a5238c43d56 (patch) | |
tree | 7497bddd9937aee3989db75cae5bbdff3fae9146 /R/mkinfit.R | |
parent | 67860242fc619624421a8fd96ba9e385456a9c2d (diff) |
- Completion of the multicompartment part of the mkin examples vignette
- Fix to chi2 error level calculation by correctly returning backtransformed
parameters as bparms.optim and bparms.fixed
- Adaptations of unit tests, summary and plot functions
git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@67 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
Diffstat (limited to 'R/mkinfit.R')
-rw-r--r-- | R/mkinfit.R | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R index e084cf1a..3ca38990 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){
|