diff options
Diffstat (limited to 'R/plot.mmkin.R')
-rw-r--r-- | R/plot.mmkin.R | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R index ef80949c..eefafe12 100644 --- a/R/plot.mmkin.R +++ b/R/plot.mmkin.R @@ -1,21 +1,53 @@ -# Copyright (C) 2015-2016,2019 Johannes Ranke -# Contact: jranke@uni-bremen.de - -# This file is part of the R package mkin - -# mkin is free software: you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation, either version 3 of the License, or (at your option) any later -# version. - -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. - -# You should have received a copy of the GNU General Public License along with -# this program. If not, see <http://www.gnu.org/licenses/> - +#' Plot model fits (observed and fitted) and the residuals for a row or column +#' of an mmkin object +#' +#' When x is a row selected from an mmkin object (\code{\link{[.mmkin}}), the +#' same model fitted for at least one dataset is shown. When it is a column, +#' the fit of at least one model to the same dataset is shown. +#' +#' If the current plot device is a \code{\link[tikzDevice]{tikz}} device, then +#' latex is being used for the formatting of the chi2 error level. +#' +#' @param x An object of class \code{\link{mmkin}}, with either one row or one +#' column. +#' @param main The main title placed on the outer margin of the plot. +#' @param legends An index for the fits for which legends should be shown. +#' @param resplot Should the residuals plotted against time, using +#' \code{\link{mkinresplot}}, or as squared residuals against predicted +#' values, with the error model, using \code{\link{mkinerrplot}}. +#' @param show_errmin Should the chi2 error level be shown on top of the plots +#' to the left? +#' @param errmin_var The variable for which the FOCUS chi2 error value should +#' be shown. +#' @param errmin_digits The number of significant digits for rounding the FOCUS +#' chi2 error percentage. +#' @param cex Passed to the plot functions and \code{\link{mtext}}. +#' @param rel.height.middle The relative height of the middle plot, if more +#' than two rows of plots are shown. +#' @param \dots Further arguments passed to \code{\link{plot.mkinfit}} and +#' \code{\link{mkinresplot}}. +#' @return The function is called for its side effect. +#' @author Johannes Ranke +#' @examples +#' +#' \dontrun{ +#' # Only use one core not to offend CRAN checks +#' fits <- mmkin(c("FOMC", "HS"), +#' list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), # named list for titles +#' cores = 1, quiet = TRUE, error_model = "tc") +#' plot(fits[, "FOCUS C"]) +#' plot(fits["FOMC", ]) +#' +#' # We can also plot a single fit, if we like the way plot.mmkin works, but then the plot +#' # height should be smaller than the plot width (this is not possible for the html pages +#' # generated by pkgdown, as far as I know). +#' plot(fits["FOMC", "FOCUS C"]) # same as plot(fits[1, 2]) +#' +#' # Show the error models +#' plot(fits["FOMC", ], resplot = "errmod") +#' } +#' +#' @export plot.mmkin <- function(x, main = "auto", legends = 1, resplot = c("time", "errmod"), show_errmin = TRUE, |