R/plotPLScalibration.R

Defines functions plotPLScalibration

Documented in plotPLScalibration

#' Visualize PLS modeling results.
#' 
#' This function is a wrapper to the plot methods in the pls R package. It
#' takes an object of class \code{PLScalibration} and produces diagnostic
#' plots.
#' 
#' 
#' @param x An object of class \code{PLScalibration} containing the model.
#' @param pch see par.
#' @param bg see par.
#' @param ncomp The number of latent vectors to use. If NULL, the default is to
#' use the optimal number of determined during the optimization process.
#' @param plottype One of:\cr "prediction" - Predicted versus observed.\cr
#' "validation" - RMSEP versus rank.\cr "coefficients" - Coefficients.\cr
#' "scores" - Biplot of scores.\cr "loadings" - Loadings.
#' @param ... Additional args.
#' @return A plot of model results.
#' @author Daniel M Griffith
#' @keywords visualization
#' @examples
#' 
#' \dontrun{
#' data(N_cal_shootout)
#' plot(N_cal_shootout)
#' }
#' 
#' @export plotPLScalibration
plotPLScalibration <- function(x, pch = 21, bg = "gray", ncomp = NULL, plottype = "prediction", ...){
  
  if(plottype == "prediction"){
    plot(x$model, pch = pch, bg = bg, ncomp = ifelse(is.null(ncomp),x$rank,ncomp), plottype = "prediction", ...)
    abline(a = 0, b = 1)
  }else{
    plot(x$model, plottype = plottype, ...)      
  }
  
}
griffithdan/plantspec documentation built on May 17, 2019, 8:37 a.m.