plot.lsplsCv: Plot Method for Cross-Validations

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plots.R


Plot method for "lsplsCv" objects. It plots the cross-validated (R)MSEP or R^2 against the total number of components or the matrices included in the model.


## S3 method for class 'lsplsCv'
plot(x, which = c("RMSEP", "MSEP", "R2"), ncomp,
        separate = TRUE, scale = !isTRUE(separate), ...)



object of class "lsplsCv". Object to be plotted. Typically the output from lsplsCv.


character string. Which measure to plot.


list. The number of components to use when plotting, for each PLS matrix in the model. See Details.


logical. Whether separate plots should be generated for each response (default) or one plot with the sum of the measure for all responses.


logical. Whether the responses and predicted values should be divided by the standard deviation of the response prior to calculating the measure. Default is to scale when producing a combined plot (separate = FALSE) and not to scale otherwise.


Further arguments, sent to the underlying plot function.


If ncomp is not specified, the plot method generates a plot of the cross-validated (R)MSEP or R^2 values for all combinations of number of components. The values are plotted against the total number of components. Each point is labelled with the combination of number of components. E.g., for a model with three PLS matrices, 132 means one component from the first matrix, three from the second and two from the third. Also, the lowest (R)MSEP or highest R^2 values for each total number of components are joined by a line.

If ncomp is specified, the plot method plots (R)MSEP or R^2 for models with the first matrix, with the two first matrices, etc. ncomp should be specified as when running lsplsCv, and is used for selecting the number of components for each PLS matrix. For instance

    mod <- lsplsCv(Y ~ X + Z + V:W, ...)
    plot(mod, ncomp = list(2, c(1,3)))

would plot the RMSEPs for Y ~ X, Y ~ X + Z and Y ~ X + Z + V:W, using 2, 1 and 3 components for Z, V and W, respectively.

If separate is TRUE, a separate plot panel is produced for each response. Otherwise the measure is added for all responses and shown in one plot. If scale is TRUE (the default when producing a combined plot), the measures for each response are standardised by dividing the responses and predicted values by the standard deviation of the (corresponding) response prior to calculating the measure. Note that scale is ignored when which is "R2" because R^2 is independent of scale.)


The function returns whatever the (last) underlying plot function returns.


Bjørn-Helge Mevik

See Also

lsplsCv, lspls



lspls documentation built on May 2, 2019, 12:19 p.m.