plsres: PLS results

View source: R/plsres.R

plsresR Documentation

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 = dim(y.pred)[2],
  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.

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).

Value

Returns an object of plsres class with following fields:

ncomp

number of components included to the model.

ncomp.selected

selected (optimal) number of components.

y.ref

a matrix with reference values for responses.

y.pred

a matrix with predicted values for responses.

rmse

a matrix with root mean squared error values for each response and component.

slope

a matrix with slope values for each response and component.

r2

a matrix with determination coefficients for each response and component.

bias

a matrix with bias values for each response and component.

sep

a matrix with standard error values for each response and component.

rpd

a matrix with RPD values for each response and component.

xdecomp

decomposition of predictors (object of class ldecomp).

ydecomp

decomposition of responses (object of class ldecomp).

info

information about the object.

See Also

Methods for plsres objects:

print prints information about a plsres object.
summary.plsres shows performance statistics for the results.
plot.plsres shows plot overview of the results.
plotXScores.plsres shows scores plot for x decomposition.
plotXYScores.plsres shows scores plot for x and y decomposition.
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. Q plot for x decomposition.
plotYResiduals.plsres shows residuals plot for y values.

Methods inherited from regres class (parent class for plsres):

plotPredictions.regres shows predicted vs. measured plot.
plotRMSE.regres shows RMSE plot.

See also pls - a class for PLS models.

Examples

### Examples of using PLS result class
library(mdatools)
## 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))


svkucheryavski/mdatools documentation built on Aug. 25, 2023, 12:27 p.m.