Learn R Programming

mdatools (version 0.5.3)

plsres: PLS results

Description

plsres is used to store and visualize results of applying a PLS model to a new data.

Usage

plsres(y.pred, y.ref = NULL, ncomp.selected = NULL, xdecomp = NULL, ydecomp = NULL,
   info = '')

Arguments

y.pred
predicted y values.
y.ref
reference (measured) y values.
ncomp.selected
selected (optimal) number of components.
xdecomp
PLS decomposition of X data (object of class ldecomp).
ydecomp
PLS decomposition of Y data (object of class ldecomp).
info
information about the object.

Value

  • Returns an object of plsres class with following fields:
  • ncompnumber of components included to the model.
  • ncomp.selectedselected (optimal) number of components.
  • y.refa matrix with reference values for responses.
  • y.preda matrix with predicted values for responses.
  • rmsea matrix with root mean squared error values for each response and component.
  • slopea matrix with slope values for each response and component.
  • r2a matrix with determination coefficients for each response and component.
  • biasa matrix with bias values for each response and component.
  • sepa matrix with standard error values for each response and component.
  • rpda matrix with RPD values for each response and component.
  • xdecompdecomposition of predictors (object of class ldecomp).
  • ydecompdecomposition of responses (object of class ldecomp).
  • infoinformation about the object.

Details

Do not use plsres manually, the object is created automatically when one applies a PLS model to a new data set, e.g. when calibrate and validate a PLS model (all calibration and validation results in PLS model are stored as objects of plsres class) or use function predict.pls.

The object gives access to all PLS results as well as to the plotting methods for visualisation of the results. The plsres class also inherits all properties and methods of regres - general class for regression results.

If no reference values provided, regression statistics will not be calculated and most of the plots not available. The class is also used for cross-validation results, in this case some of the values and methods are not available (e.g. scores and scores plot, etc.).

All plots are based on mdaplot function, so most of its options can be used (e.g. color grouping, etc.).

RPD is ratio of standard deviation of response values to standard error of prediction (SDy/SEP).

See Also

Methods for plsres objects: ll{ print prints information about a plsres object. summary.plsres shows performance statistics for the results. plot.plsres shows plot overview of the results. plotPredictions.plsres shows predicted vs. measured plot. plotXScores.plsres shows scores plot for x decomposition. plotXYScores.plsres shows scores plot for x and y decomposition. plotRMSE.plsres shows RMSE plot. plotXVariance.plsres shows explained variance plot for x decomposition. plotYVariance.plsres shows explained variance plot for y decomposition. plotXCumVariance.plsres shows cumulative explained variance plot for y decomposition. plotYCumVariance.plsres shows cumulative explained variance plot for y decomposition. plotXResiduals.plsres shows T2 vs. Q2 plot for x decomposition. plotYResiduals.regres shows residuals plot for y values. } See also pls - a class for PLS models.

Examples

Run this code
### Examples of using PLS result class

## 1. Make a PLS model for concentration of first component 
## using full-cross validation and get calibration results

data(simdata)
x = simdata$spectra.c
y = simdata$conc.c[, 1]

model = pls(x, y, ncomp = 8, cv = 1)
model = selectCompNum(model, 2)
res = model$calres

summary(res)
plot(res)

## 2. Make a PLS model for concentration of first component 
## and apply model to a new dataset

data(simdata)
x = simdata$spectra.c
y = simdata$conc.c[, 1]

model = pls(x, y, ncomp = 6, cv = 1)
model = selectCompNum(model, 2)

x.new = simdata$spectra.t
y.new = simdata$conc.t[, 1]
res = predict(model, x.new, y.new)

summary(res)
plot(res)

## 3. Show variance and error plots for PLS results
par(mfrow = c(2, 2))
plotXCumVariance(res, type = 'h')
plotYCumVariance(res, type = 'b', show.labels = TRUE, legend.position = 'bottomright')
plotRMSE(res)
plotRMSE(res, type = 'h', show.labels = TRUE)
par(mfrow = c(1, 1))

## 4. Show scores plots for PLS results
## (for results plot we can use color grouping)
par(mfrow = c(2, 2))
plotXScores(res)
plotXScores(res, show.labels = TRUE, cgroup = y.new)
plotXYScores(res)
plotXYScores(res, comp = 2, show.labels = TRUE)
par(mfrow = c(1, 1))

## 5. Show predictions and residuals plots for PLS results
par(mfrow = c(2, 2))
plotXResiduals(res, show.label = TRUE, cgroup = y.new)
plotYResiduals(res, show.label = TRUE)
plotPredictions(res)
plotPredictions(res, ncomp = 4, xlab = 'C, reference', ylab = 'C, predictions')
par(mfrow = c(1, 1))

Run the code above in your browser using DataLab