From c6079a807e2b400fe0c772603392aeacd887da2f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 8 May 2019 20:57:48 +0200 Subject: Add functionality to plot the error model by plotting squared residuals against predicted values, and showing the variance function used in the fitted error model. Rebuild docs --- R/mkinresplot.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'R/mkinresplot.R') diff --git a/R/mkinresplot.R b/R/mkinresplot.R index 3650ef4b..739a80e9 100644 --- a/R/mkinresplot.R +++ b/R/mkinresplot.R @@ -23,7 +23,7 @@ mkinresplot <- function (object, xlab = "Time", ylab = "Residual", maxabs = "auto", legend= TRUE, lpos = "topright", ...) { - obs_vars_all <- as.character(unique(object$data$variable)) + obs_vars_all <- as.character(unique(object$data$variable)) if (length(obs_vars) > 0){ obs_vars <- intersect(obs_vars_all, obs_vars) @@ -33,18 +33,18 @@ mkinresplot <- function (object, if (maxabs == "auto") maxabs = max(abs(residuals), na.rm = TRUE) - col_obs <- pch_obs <- 1:length(obs_vars) - names(col_obs) <- names(pch_obs) <- obs_vars + col_obs <- pch_obs <- 1:length(obs_vars) + names(col_obs) <- names(pch_obs) <- obs_vars plot(0, type = "n", xlab = xlab, ylab = ylab, xlim = xlim, ylim = c(-1.2 * maxabs, 1.2 * maxabs), ...) - 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]) - } + 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) -- cgit v1.2.1