TDAbiplot {bipl5}R Documentation

Construct PCA biplots with translated calibrated density axes

Description

Construct various rank-2 PCA biplots with translated axes based on a combination of the first three principal components.

Usage

TDAbiplot(
  x,
  dist = NULL,
  inflate = 1,
  alpha = 0.95,
  alpha_Elip = NULL,
  swop = FALSE,
  density.args = NULL,
  color = NULL,
  symbol = "circle"
)

## S3 method for class 'bipl5'
TDAbiplot(
  x,
  dist = NULL,
  inflate = 1,
  alpha = 0.95,
  alpha_Elip = NULL,
  swop = FALSE,
  density.args = NULL,
  color = NULL,
  symbol = "circle"
)

Arguments

x

An object of class bipl5. See PCAbiplot in this regard.

dist

Minimum distance between each axis. Default is roughly 12.5% of the plot diameter

inflate

Density inflation factor

alpha

Argument passes to alpha_Elip

alpha_Elip

A function taking two arguments, Z and alpha. The output of the function should be a two-column matrix of coordinates which will be used to construct an alpha-ellipse. See details below.

swop

Swop the direction which to which each axis is translated

density.args

Arguments to be passed to the density function

color

Colors to be utilized per class group

symbol

Plotting symbol to be used per class group

Details

This function produces a PCA biplot with translated calibrated axes. The function constructs this biplot in the plot_ly graphing library with reactivity embedded on the display. The following features are available on the display:

The alpha_Elip argument is used to subset the biplot plotting coordinates (Z) to remove the effect of outliers in the data. A common suggestion is to use an alphabag or on Convex hull peeling algorithm to strip away extreme points. The alpha-ellipse will be constructed around this data, and will impact the lengths of the calibrated axes.

Value

A named list of class bipl5, see PCAbiplot, with the following attributes:

x

A data frame which is the original input data

Z

A matrix of n x 2 representing the coordinates of each observation on the biplot

rank

The rank of the approximated data

scale

Whether the data is standardized prior to performing dimension reduction

group

The grouping vector of the data

mu

The vector of column means of the input data

stddev

Vector of column standard deviations if the scale parameter is set to TRUE.

PCA

The singular value decomposition of the covariance/correlation matrix, see svd

plot

The plotly graph displaying the biplot, see plot_ly

Adequacy

The adequacy of each axis displayed for each set of principal components

Predictivity

The predictivity of each axis displayed for each set of principal components

See Also

PCAbiplot FMbiplot

Examples

## Simple illustration of a calibrated density axis biplot
x<-PCAbiplot(iris[,-5],group=iris[,5])
TDAbiplot(x,dist=1,inflate=1)

## Change the plotting characters of class-groups:
y<- x |> TDAbiplot(dist=1,inflate=1,symbol=c("circle","diamond","square"))

## Custom kernel densities can be drawn on the axes:
density.args<-list()
density.args$kernel <- "optcosine"
density.args$bw <- "sj"

y<- x |> TDAbiplot(dist=1,inflate=1,density.args=density.args)

## To lessen the effects of outliers, a smaller alpha-ellipse can be
## used to determine axis lengths. Define a function that strips away
## outliers, for example a convex hull peeling algorithm:

HullPeeling <- function(x,alpha) {
  n<-nrow(x)
  propinside<-1
  target<-1-alpha
  x2<-x
  while (propinside>target) {
    hull<-grDevices::chull(x2)
    x2old<-x2
    x2<-x2[-hull,]
    propinside<-nrow(x2)/n
  }
    return(x2[grDevices::chull(x2),])
}

y<- x |> TDAbiplot(dist=1,inflate=1, alpha_Elip=HullPeeling, alpha=0.4)

[Package bipl5 version 1.0.2 Index]