R/check_plot_arguments.R

Defines functions plot_check

plot_check <- function(x, label, color, cooks, range) {
  
  if (!all(inherits(x, which = TRUE, c("emdi", "model")))) {
    stop('First object needs to be of class emdi, model. For emdi objects
         obtained by direct estimation diagnostic plots are not reasonable.')
  }
  if (is.null(label) || (!(label == "orig" || label == "no_title" || label == "blank") 
                         && !inherits(label, "list"))) {
    stop("label can be either one of the following characters 'orig', 
         'no_title' or 'blank' or a list as specified in help(plot.emdi).")
  }
  if (length(color) != 2 || !is.vector(color)) {
    stop("color needs to be a vector of length 2 
         defining the two colors for the diagnostic plot. See also
         help(plot.emdi).")
  }
  if (!(inherits(cooks, "logical") && length(cooks) == 1)) {
    stop("cooks needs to be a logical value. Set na.rm to TRUE or FALSE. See 
         also help(plot.emdi).")
  }
  if (!is.null(range) && !inherits(range, "numeric")) {
    stop("range must be a sequence determining the range of the x-axis for plots 
          of the optimal parameter.. Set na.rm to TRUE or FALSE. See 
         also help(plot.emdi).")
  }
}
akreutzmann/fayherriot documentation built on Aug. 19, 2019, 12:22 p.m.