aboutsummaryrefslogtreecommitdiff
path: root/R/mkinresplot.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/mkinresplot.R')
-rw-r--r--R/mkinresplot.R29
1 files changed, 14 insertions, 15 deletions
diff --git a/R/mkinresplot.R b/R/mkinresplot.R
index 524ba788..07bd7dfa 100644
--- a/R/mkinresplot.R
+++ b/R/mkinresplot.R
@@ -1,7 +1,5 @@
-# $Id$
-
-# Copyright (C) 2008-2011 Katrin Lindenberger and Johannes Ranke
-# Contact: mkin-devel@lists.berlios.de
+# Copyright (C) 2008-2014 Johannes Ranke
+# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -19,36 +17,37 @@
# this program. If not, see <http://www.gnu.org/licenses/>
if(getRversion() >= '2.15.1') utils::globalVariables(c("variable", "residual"))
-mkinresplot <- function (object, obs_vars = vector(),
+mkinresplot <- function (object,
+ obs_vars = names(object$mkinmod$map),
xlab = "Time", ylab = "Residual",
maxabs = "auto", legend= TRUE, lpos = "topright", ...)
{
obs_vars_all <- as.character(unique(object$data$variable))
if (length(obs_vars) > 0){
- vars <- intersect(obs_vars_all, obs_vars)
- } else vars <- obs_vars_all
+ obs_vars <- intersect(obs_vars_all, obs_vars)
+ } else obs_vars <- obs_vars_all
- residuals <- subset(object$data, variable %in% vars, residual)
+ residuals <- subset(object$data, variable %in% obs_vars, residual)
if (maxabs == "auto") maxabs = max(abs(residuals), na.rm = TRUE)
- col_obs <- pch_obs <- 1:length(vars)
- names(col_obs) <- names(pch_obs) <- vars
+ col_obs <- pch_obs <- 1:length(obs_vars)
+ names(col_obs) <- names(pch_obs) <- obs_vars
plot(0, xlab = xlab, ylab = ylab,
xlim = c(0, 1.1 * max(object$data$time)),
ylim = c(-1.2 * maxabs, 1.2 * maxabs), ...)
- for(var in vars){
- residuals_plot <- subset(object$data, variable == var, c("time", "residual"))
- points(residuals_plot, pch = pch_obs[var], col = col_obs[var])
+ for(obs_var in obs_vars){
+ residuals_plot <- subset(object$data, variable == obs_var, c("time", "residual"))
+ points(residuals_plot, pch = pch_obs[obs_var], col = col_obs[obs_var])
}
abline(h = 0, lty = 2)
if (legend == TRUE) {
- legend(lpos, inset = c(0.05, 0.05), legend = vars,
- col = col_obs, pch = pch_obs)
+ legend(lpos, inset = c(0.05, 0.05), legend = obs_vars,
+ col = col_obs[obs_vars], pch = pch_obs[obs_vars])
}
}

Contact - Imprint