Plot stacked ggplot2 graphs of VIP for the final PLS regression model output of the calibration (training) data set for the final number of components, raw (replicate mean) spectra, and preprocessed spectra. Regions with VIP > 1 are highlighted across the stacked graphs in beige colour rectangles. VIP calculation is implemented as described in Chong, I.-G., and Jun, C.-H. (2005). Performance of some variable selection methods when multicollinearity is present. Chemometrics and Intelligent Laboratory Systems, 78(1–2), 103–112. https://doi.org/10.1016/j.chemolab.2004.12.011

plot_pls_vip(mout, y1 = "spc_mean", y2 = "spc_pre",
  by = "sample_id",
  xlab = expression(paste("Wavenumber [", cm^-1, "]")),
  ylab1 = "Absorbance", ylab2 = "Preprocessed Abs.",
  alpha = 0.2)

Arguments

mout

Model output list that is returned from simplerspec::fit_pls(). This object contains a nested list with the caret::train() object (class train), based on which VIPs at finally selected number of PLS components are computed.

y1

Character vector of list-column name in mout$data$calibration, where spectra for bottom graph are extracted. Default is "spc_mean", which plots the mean calibration spectra after resampling.

y2

Character string of list-column name in mout$data$calibration, where spectra for bottom graph are extracted. Default is "spc_pre", which plots the preprocessed calibration spectra after resampling.

by

Character string that is used to assign spectra to the same group and therefore ensures that all spectra are plotted with the same colour. Default is "sample_id"

xlab

Character string of X axis title for shared x axis of stacked graphs. Default is expression(paste("Wavenumber [", cm^-1, "]"))

ylab1

Y axis title of bottom spectrum. Default is "Absorbance".

ylab2

Y axis title of bottom spectrum. Default is "Preprocessed Abs.".

alpha

Double between 0 and 1 that defines transparency of spectra lines in returned graph (ggplot plot object).