Learn R Programming

multiblock (version 0.8.8.2)

sopls_plots: Scores, loadings and plots for sopls objects

Description

Extraction of scores and loadings and adaptation of scoreplot, loadingplot and biplot from package pls for sopls objects.

Usage

# S3 method for sopls
loadings(object, ncomp = "all", block = 1, y = FALSE, ...)

# S3 method for sopls scores(object, ncomp = "all", block = 1, y = FALSE, ...)

# S3 method for sopls scoreplot( object, comps = 1:2, ncomp = NULL, block = 1, labels, identify = FALSE, type = "p", xlab, ylab, ... )

# S3 method for sopls loadingplot( object, comps = 1:2, ncomp = NULL, block = 1, scatter = TRUE, labels, identify = FALSE, type, lty, lwd = NULL, pch, cex = NULL, col, legendpos, xlab, ylab, pretty.xlabels = TRUE, xlim, ... )

# S3 method for sopls corrplot( object, comps = 1:2, ncomp = NULL, block = 1, labels = TRUE, col = 1:5, plotx = TRUE, ploty = TRUE, ... )

# S3 method for sopls biplot( x, comps = 1:2, ncomp = "all", block = 1, which = c("x", "y", "scores", "loadings"), var.axes = FALSE, xlabs, ylabs, main, ... )

Arguments

object

sopls object

ncomp

integer vector giving components from all blocks before block (see next argument).

block

integer indicating which block to extract components from.

y

logical extract Y loadings/scores instead of X loadings/scores (default = FALSE).

...

further arguments sent to the underlying plot function(s)

comps

integer vector giving components, within block, to plot (see Details regarding combination of blocks).

labels

character indicating if "names" or "numbers" should be plot symbols (optional).

identify

logical for activating identify to interactively identify points.

type

character for selecting type of plot to make. Defaults to "p" (points) for scatter plots and "l" (lines) for line plots.

xlab

character text for x labels.

ylab

character text for y labels.

scatter

logical indicating if a scatterplot of loadings should be made (default = TRUE).

lty

Vector of line type specifications (see par for details).

lwd

numeric vector of line width specifications.

pch

Vector of point specifications (see points for details).

cex

numeric vector of plot size expansions (see par for details).

col

integer vector of symbol/line colours (see par for details).

legendpos

character indicating legend position (if scatter is FALSE), e.g. legendpos = "topright".

pretty.xlabels

logical indicating if xlabels should be more nicely plotted (default = TRUE).

xlim

numeric vector of length two, with the x limits of the plot (optional).

plotx

locical or integer/character. Whether to plot the \(X\) correlation loadings, optionally which block(s). Defaults to TRUE.

ploty

logical. Whether to plot the \(Y\) correlation loadings. Defaults to TRUE.

x

sopls object

which

character for selecting type of biplot ("x" = default, "y", "scores", "loadings").

var.axes

logical indicating if second axes of a biplot should have arrows.

xlabs

character vector for labelling first set of biplot points (optional).

ylabs

character vector for labelling second set of biplot points (optional).

main

character for setting the main title of a plot.

Details

If comps is supplied as a list for scoreplot, it is assumed that its elements refer to each of the blocks up to block number block. For instance comps = list(1, 0, 1:2) will select 1 component from the first block, no components from the second block and the first two components from the last block. This must be matched by ncomp, specifying how many components were selected before block number block.

See Also

Overviews of available methods, multiblock, and methods organised by main structure: basic, unsupervised, asca, supervised and complex. Common functions for computation and extraction of results are found in sopls_results.

#' @return The score and loading functions return scores and loadings, while plot functions have no return (except use of 'identify').

Examples

Run this code
data(potato)
so <- sopls(Sensory ~ Chemical + Compression + NIRraw, data=potato, ncomp=c(5,5,5))

# Loadings
loadings(so, ncomp=c(3), block=2)[, 1:3]

# Scores
scores(so, block=1)[, 1:4]

# Default plot from first block
scoreplot(so)

# Second block with names
scoreplot(so, ncomp=c(3), block=2, labels="names")

# Scatterplot matrix
scoreplot(so, ncomp=c(3,2), block=3, comps=1:3)

# Combination of blocks (see Details)
scoreplot(so, ncomp=c(3,2), block=3, comps=list(1,0,1))

# Default plot from first block
loadingplot(so, scatter=TRUE)

# Second block with names
loadingplot(so, ncomp=c(3), block=2, labels="names", scatter=TRUE)

# Scatterplot matrix
loadingplot(so, ncomp=c(3,2), block=3, comps=1:3, scatter=TRUE)

# Correlation loadings
corrplot(so, block=2, ncomp=1)

# Default plot from first block
biplot(so)

Run the code above in your browser using DataLab