Functions to estimate the mean squared error of prediction (MSEP), root mean squared error of prediction (RMSEP) and R^2 (A.K.A. coefficient of multiple determination) for fitted PCR and PLSR models. Test-set, cross-validation and calibration-set estimates are implemented.
mvrValstats( object, estimate, newdata, ncomp = 1:object$ncomp, comps, intercept = cumulative, se = FALSE, ... ) R2(object, ...) ## S3 method for class 'mvr' R2( object, estimate, newdata, ncomp = 1:object$ncomp, comps, intercept = cumulative, se = FALSE, ... ) MSEP(object, ...) ## S3 method for class 'mvr' MSEP( object, estimate, newdata, ncomp = 1:object$ncomp, comps, intercept = cumulative, se = FALSE, ... ) RMSEP(object, ...) ## S3 method for class 'mvr' RMSEP(object, ...)
a character vector. Which estimators to use. Should be a
a data frame with test set data.
a vector of positive integers. The components or number of components to use. See below.
logical. Whether estimates for a model with zero components should be returned as well.
logical. Whether estimated standard errors of the estimates should be calculated. Not implemented yet.
further arguments sent to underlying functions or (for
RMSEP simply calls
MSEP and takes the square root of the
estimates. It therefore accepts the same arguments as
Several estimators can be used.
"train" is the training or
calibration data estimate, also called (R)MSEC. For
R2, this is the
unadjusted R^2. It is overoptimistic and should not be used for
"CV" is the cross-validation estimate, and
MSEP) is the bias-corrected
cross-validation estimate. They can only be calculated if the model has
been cross-validated. Finally,
"test" is the test set estimate,
newdata as test set.
Which estimators to use is decided as follows (see below for
estimate is not specified, the test set
estimate is returned if
newdata is specified, otherwise the CV and
adjusted CV (for
MSEP) estimates if the model has
been cross-validated, otherwise the training data estimate. If
"all", all possible estimates are calculated.
Otherwise, the specified estimates are calculated.
Several model sizes can also be specified. If
comps is missing (or
length(ncomp) models are used, with
ncomp[length(ncomp)] components. Otherwise, a
single model with the components
comps[length(comps)] is used. If
model with zero components is also used (in addition to the above).
The R^2 values returned by
"R2" are calculated as 1 -
SSE/SST, where SST is the (corrected) total sum of squares of the
response, and SSE is the sum of squared errors for either the fitted
values (i.e., the residual sum of squares), test set predictions or
cross-validated predictions (i.e., the PRESS). For
"train", this is equivalent to the squared correlation between the fitted
values and the response. For
estimate = "train", the estimate is
often called the prediction R^2.
mvrValstats is a utility function that calculates the statistics
R2. It is not intended to be used
interactively. It accepts the same arguments as
estimate argument must be specified explicitly: no
partial matching and no automatic choice is made. The function simply
calculates the types of estimates it knows, and leaves the other untouched.
mvrValstats returns a list with components
three-dimensional array of SSE values. The first dimension is the different estimators, the second is the response variables and the third is the models.
matrix of SST values. The first dimension is the different estimators and the second is the response variables.
a numeric vector giving the number of objects used for each estimator.
the components specified, with
NULL or not specified.
The other functions return an object of class
three-dimensional array of estimates. The first dimension is the different estimators, the second is the response variables and the third is the models.
the components specified, with
0 prepended if
NULL or not
the function call
Ron Wehrens and Bjørn-Helge Mevik
Mevik, B.-H., Cederkvist, H. R. (2004) Mean Squared Error of Prediction (MSEP) Estimates for Principal Component Regression (PCR) and Partial Least Squares Regression (PLSR). Journal of Chemometrics, 18(9), 422–429.
data(oliveoil) mod <- plsr(sensory ~ chemical, ncomp = 4, data = oliveoil, validation = "LOO") RMSEP(mod) ## Not run: plot(R2(mod))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.