plotResiduals.pca: Residuals distance plot for PCA model

View source: R/pca.R

plotResiduals.pcaR Documentation

Residuals distance plot for PCA model

Description

Shows a plot with score (T2, h) vs orthogonal (Q, q) distances and corresponding critical limits for given number of components.

Usage

## S3 method for class 'pca'
plotResiduals(
  obj,
  ncomp = obj$ncomp.selected,
  log = FALSE,
  norm = TRUE,
  cgroup = NULL,
  xlim = NULL,
  ylim = NULL,
  show.limits = TRUE,
  lim.col = c("darkgray", "darkgray"),
  lim.lwd = c(1, 1),
  lim.lty = c(2, 3),
  res = obj$res,
  show.legend = TRUE,
  ...
)

Arguments

obj

a PCA model (object of class pca)

ncomp

how many components to use (by default optimal value selected for the model will be used)

log

logical, apply log tranformation to the distances or not (see details)

norm

logical, normalize distance values or not (see details)

cgroup

color grouping of plot points (works only if one result object is available)

xlim

limits for x-axis

ylim

limits for y-axis

show.limits

logical, show or not lines/curves with critical limits for the distances

lim.col

vector with two values - line color for extreme and outlier limits

lim.lwd

vector with two values - line width for extreme and outlier limits

lim.lty

vector with two values - line type for extreme and outlier limits

res

list with result objects to show the plot for (by defaul, model results are used)

show.legend

logical, show or not a legend on the plot (needed if several result objects are available)

...

other plot parameters (see mdaplotg for details)

Details

The function is a bit more advanced version of plotResiduals.ldecomp. It allows to show distance values for several result objects (e.g. calibration and test set or calibration and new prediction set) as well as display the correspondng critical limits in form of lines or curves.

Depending on how many result objects your model has or how many you specified manually, using the res parameter, the plot behaves in a bit different way.

If only one result object is provided, then it allows to colorise the points using cgroup parameter. If you specify cgroup = "categories" then it will show points as three groups: normal, extreme and outliers. If two or more result objects are provided, then the function show distances in groups, and adds corresponding legend.

The function can show distance values normalised (h/h0 and q/q0) as well as with log transformation (log(1 + h/h0), log(1 + q/q0)). The latter is useful if distribution of the points is skewed and most of them are densely located around bottom left corner.

See examples in help for pca function.


mdatools documentation built on Sept. 11, 2024, 7:59 p.m.