Title: | EZ-to-Use Biplots |
---|---|
Description: | Provides users with an EZ-to-use platform for representing data with biplots. Currently principal component analysis (PCA), canonical variate analysis (CVA) and simple correspondence analysis (CA) biplots are included. This is accompanied by various formatting options for the samples and axes. Alpha-bags and concentration ellipses are included for visual enhancements and interpretation. For an extensive discussion on the topic, see Gower, J.C., Lubbe, S. and le Roux, N.J. (2011, ISBN: 978-0-470-01255-0) Understanding Biplots. Wiley: Chichester. |
Authors: | Sugnet Lubbe [aut, cre, cph] , Niël le Roux [aut] , Johané Nienkemper-Swanepoel [aut] , Raeesa Ganey [aut] , Ruan Buys [aut] , Zoë-Mae Adams [aut] , Peter Manefeldt [aut] |
Maintainer: | Sugnet Lubbe <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.2 |
Built: | 2024-11-14 11:17:33 UTC |
Source: | CRAN |
This function produces -bags, which is a useful graphical summary of the
scatter plot. The alpha-bag refers to a contour which contains
% of the observations.
alpha.bags(bp, alpha = 0.95, which = NULL, col = ez.col[which], lty = 1, lwd = 1, max = 2500, trace = TRUE, opacity = 0.25, outlying=FALSE)
alpha.bags(bp, alpha = 0.95, which = NULL, col = ez.col[which], lty = 1, lwd = 1, max = 2500, trace = TRUE, opacity = 0.25, outlying=FALSE)
bp |
an object of class |
alpha |
numeric vector between 0 and 1 to determine coverage of the bag ( |
which |
numeric vector indicating the selection of groups or classes to be fitted with |
col |
vector of colours for the |
lty |
vector of line types for the |
lwd |
vector of line widths for the |
max |
maximum number of samples to include in |
trace |
logical, indicating progress of computation. |
opacity |
level of opacity, with default |
outlying |
logical indicating whether only outlying points should be plotted. Note the |
A list with the following components is available:
alpha.bags |
list of coordinates for the |
col |
vector of colours for the |
lty |
vector of line types for the |
lwd |
vector of line widths for the |
Gower, J., Gardner-Lubbe, S. & Le Roux, N. (2011, ISBN: 978-0-470-01255-0) Understanding Biplots. Chichester, England: John Wiley & Sons Ltd.
biplot (iris[,1:4]) |> PCA(group.aes=iris[,5]) |> alpha.bags(alpha=0.95) |> plot() biplot (iris[,1:4],group.aes=iris[,5]) |> PCA() |> alpha.bags(alpha=0.95) |> plot()
biplot (iris[,1:4]) |> PCA(group.aes=iris[,5]) |> alpha.bags(alpha=0.95) |> plot() biplot (iris[,1:4],group.aes=iris[,5]) |> PCA() |> alpha.bags(alpha=0.95) |> plot()
This function appends the biplot
object with elements resulting from using the AoD method.
AoD(bp, classes=bp$classes, dist.func=NULL, dist.func.cat=NULL, dim.biplot = c(2,1,3), e.vects = 1:ncol(bp$X), weighted = c("unweighted","weighted"), show.class.means = TRUE, axes = c("regression","splines"), ...)
AoD(bp, classes=bp$classes, dist.func=NULL, dist.func.cat=NULL, dim.biplot = c(2,1,3), e.vects = 1:ncol(bp$X), weighted = c("unweighted","weighted"), show.class.means = TRUE, axes = c("regression","splines"), ...)
bp |
an object of class |
classes |
a vector of the same length as the number of rows in the data matrix with the class indicator for the samples. |
dist.func |
a character string indicating which distance function is used to compute the Euclidean embeddable distances between samples. One of |
dist.func.cat |
a character string indicating which distance function is used to compute the Euclidean embeddable distances between samples. One of |
dim.biplot |
the dimension of the biplot. Only values |
e.vects |
the vector indicating which eigenvectors (canonical variates) should be plotted in the biplot, with default |
weighted |
a character string indicating the weighting of the classes. One of " |
show.class.means |
a logical value indicating whether to plot the class means on the biplot. |
axes |
a character string indicating the type of biplot axes to be used in the biplot. One of |
... |
more arguments to |
Object of class biplot
biplot(iris[,1:4]) |> AoD(classes=iris[,5]) # create a CVA biplot biplot(iris[,1:4]) |> AoD(classes=iris[,5]) |> plot()
biplot(iris[,1:4]) |> AoD(classes=iris[,5]) # create a CVA biplot biplot(iris[,1:4]) |> AoD(classes=iris[,5]) |> plot()
This function is used to construct the AoD biplot
## S3 method for class 'biplot' AoD( bp, classes = bp$classes, dist.func = NULL, dist.func.cat = NULL, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), weighted = c("unweighted", "weighted"), show.class.means = TRUE, axes = c("regression", "splines"), ... )
## S3 method for class 'biplot' AoD( bp, classes = bp$classes, dist.func = NULL, dist.func.cat = NULL, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), weighted = c("unweighted", "weighted"), show.class.means = TRUE, axes = c("regression", "splines"), ... )
bp |
an object of class |
classes |
a vector of the same length as the number of rows in the data matrix with the class indicator for the samples. |
dist.func |
a character string indicating which distance function is used to compute the Euclidean embeddable distances between samples. One of |
dist.func.cat |
a character string indicating which distance function is used to compute the Euclidean embeddable distances between samples. One of |
dim.biplot |
the dimension of the biplot. Only values |
e.vects |
the vector indicating which eigenvectors (canonical variates) should be plotted in the biplot, with default |
weighted |
a character string indicating the weighting of the classes. One of " |
show.class.means |
a logical value indicating whether to plot the class means on the biplot. |
axes |
a character string indicating the type of biplot axes to be used in the biplot. One of |
... |
more arguments to |
an object of class biplot
.
biplot(iris) |> AoD(classes = iris[,5]) |> plot()
biplot(iris) |> AoD(classes = iris[,5]) |> plot()
This function allows the user to format the aesthetics for the biplot axes.
axes(bp, X.names=colnames(bp$X), which = 1:bp$p, col = grey(0.7), lwd = 1, lty = 1, label.dir = "Orthog", label.col = col, label.cex = 0.75, label.line = 0.1, label.offset=rep(0,4), ticks = 5, tick.col = col, tick.size = 1, tick.label = TRUE, tick.label.side = "below", tick.label.col = tick.col, tick.label.cex = 0.6, predict.col = col, predict.lwd = lwd, predict.lty = lty, ax.names = X.names, orthogx = 0, orthogy = 0, vectors = FALSE, unit.circle=FALSE)
axes(bp, X.names=colnames(bp$X), which = 1:bp$p, col = grey(0.7), lwd = 1, lty = 1, label.dir = "Orthog", label.col = col, label.cex = 0.75, label.line = 0.1, label.offset=rep(0,4), ticks = 5, tick.col = col, tick.size = 1, tick.label = TRUE, tick.label.side = "below", tick.label.col = tick.col, tick.label.cex = 0.6, predict.col = col, predict.lwd = lwd, predict.lty = lty, ax.names = X.names, orthogx = 0, orthogy = 0, vectors = FALSE, unit.circle=FALSE)
bp |
an object of class |
X.names |
a vector of column names of |
which |
a vector containing the columns or variables for which the axes should be displayed, with default |
col |
the colour(s) for the axes, with default |
lwd |
the line width(s) for the axes, with default |
lty |
the line type(s) for the axes, with default |
label.dir |
a character string indicating the placement of the axis titles to the side of the figure. One of " |
label.col |
the colour(s) for the axis labels, with default, |
label.cex |
the label expansion for the axis labels, with default |
label.line |
the distance of the axis title from the side of the figure, with default |
label.offset |
a four-component numeric vector controlling the distances axis titles are displayed from the side of the figure, with default |
ticks |
an integer-valued vector indicating the number of tickmarks for each axis, with default |
tick.col |
the colour(s) for the tick marks, with default |
tick.size |
a vector specifying the sizes of tick marks for each axis, with default |
tick.label |
a logical value indicating whether the axes should be labelled, with default |
tick.label.side |
a character string indicating the position of the tick label. One of " |
tick.label.col |
the colour(s) for the tick mark labels, with default |
tick.label.cex |
the label expansion for the tick mark labels, with default |
predict.col |
the colour(s) for the predicted samples, with default |
predict.lwd |
the line width(s) for the predicted samples, with default |
predict.lty |
the line type(s) for the predicted samples, with default |
ax.names |
a vector of size |
orthogx |
a numeric vector of size |
orthogy |
a numeric vector of size |
vectors |
a logical value indicating whether vector representation (calibrated axes) should be displayed on the biplot. This is only used when a PCA biplot is produced. |
unit.circle |
a logical value indicating whether a unit circle should be displayed on the biplot. |
The object of class biplot
will be appended with a list called axes
containing the following elements:
which |
a vector containing the columns for which the axes are displayed. |
col |
the colour(s) of the axes. |
lwd |
the line width(s) of the axes. |
lty |
the line type(s) of the axes. |
label.dir |
the placement of the axis titles to the side of the figure. |
label.col |
the colour(s) of the axis titles. |
label.cex |
the label expansion(s) of the axis titles. |
label.line |
the distance(s) of the axis titles from the side of the figure. |
ticks |
the number of tick marks per axis. |
tick.col |
the colour(s) of the tick marks. |
tick.size |
the size(s) of the tick marks. |
tick.label |
logical value(s) indicating whether axes are labelled. |
tick.label.side |
the position of the tick mark labels. |
tick.label.col |
the colour(s) of the tick mark labels. |
tick.label.cex |
the expansion(s) of the tick mark labels. |
predict.col |
the colour(s) of the predicted samples. |
predict.lty |
the line type(s) of the predicted samples. |
predict.lwd |
the line width(s) of the predicted samples. |
names |
the user defined axis titles. |
orthogx |
the horizontal translations for each axis. |
orthogy |
the vertical translations for each axis. |
vectors |
a logical value indicating whether calibrated axes are plotted. |
biplot(iris[,1:4]) |> PCA() |> axes(col="purple") |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=15) |> axes() |> plot()
biplot(iris[,1:4]) |> PCA() |> axes(col="purple") |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=15) |> axes() |> plot()
Convenience function to obtain the coordinates of the calibrated ticks marks on the biplot
axes_coordinates(x)
axes_coordinates(x)
x |
an object of class |
An ordered list containing the coordinates the of tick marks to plotted on the biplot
x<-biplot(iris) |> PCA() coordinates<-axes_coordinates(x)
x<-biplot(iris) |> PCA() coordinates<-axes_coordinates(x)
This function produces a list of elements to be used when producing a biplot, which provides a useful data analysis tool and allows the visual appraisal of the structure of large data matrices. Biplots are the multivariate analogue of scatter plots. They approximate the multivariate distribution of a sample in a few dimensions and they superimpose on this display representations of the variables on which the samples are measured.
biplot(data, classes = NULL, group.aes = NULL, center = TRUE, scaled = FALSE, Title = NULL)
biplot(data, classes = NULL, group.aes = NULL, center = TRUE, scaled = FALSE, Title = NULL)
data |
a data frame or numeric matrix containing all variables the user wants to analyse. |
classes |
a vector identifying class membership. |
group.aes |
a vector identifying groups for aesthetic formatting. |
center |
a logical value indicating whether |
scaled |
a logical value indicating whether |
Title |
the title of the biplot to be rendered, enter text in " ". |
This function is the entry-level function in biplotEZ
to construct a biplot display.
It initialises an object of class biplot
which can then be piped to various other functions
to build up the biplot display.
A list with the following components is available:
X |
the matrix of the centered and scaled numeric variables. |
Xcat |
the data frame of the categorical variables. |
raw.X |
the original data. |
classes |
the vector of category levels for the class variable. This is to be used for |
na.action |
the vector of observations that have been removed. |
center |
a logical value indicating whether |
scaled |
a logical value indicating whether |
means |
the vector of means for each numeric variable. |
sd |
the vector of standard deviations for each numeric variable. |
n |
the number of observations. |
p |
the number of variables. |
group.aes |
the vector of category levels for the grouping variable. This is to be used for |
g.names |
the descriptive names to be used for group labels. |
g |
the number of groups. |
Title |
the title of the biplot rendered |
The biplot display can be built up in four broad steps depending on the needs for the display. Firstly, choose an appropriate method to construct the display; Secondly, change the aesthetics of the display; Thirdly, append the display with supplementary features such as axes, samples and means; Finally, superimpose shapes, characters or elements onto the display.
1. Different types of biplots:
PCA()
: Principal Component Analysis biplot of various dimensions
CVA()
: Canonical Variate Analysis biplot
PCO()
: Principal Coordinate Analysis biplot
CA()
: Correspondence Analysis biplot
regress()
: Regression biplot method
2. Customise the biplot display with aesthetic functions:
samples()
: Change the formatting of sample points on the biplot display
axes()
: Change the formatting of the biplot axes
3. Supplement the existing biplot with additional axes, samples and group means:
newsamples()
: Add and change formatting of additional samples
newaxes()
: Add and change formatting of additional axes
means()
: Insert class means to the display, and format appropriately
4. Append the biplot display:
alpha.bags()
: Add -bags
ellipses()
: Add ellipses
density2D()
: Add 2D density regions
Other useful links:
Gabriel, K.R. (1971) The biplot graphic display of matrices with application to principal component analysis. Biometrika. 58(3):453–467.
Gower, J., Gardner-Lubbe, S. & Le Roux, N. (2011, ISBN: 978-0-470-01255-0) Understanding Biplots. Chichester, England: John Wiley & Sons Ltd.
Gower, J.C. & Hand, D.J.(1996, ISBN: 0-412-71630-5) Biplots. London: Chapman & Hall.
biplot(data = iris) # create a PCA biplot biplot(data = iris) |> PCA() |> plot()
biplot(data = iris) # create a PCA biplot biplot(data = iris) |> PCA() |> plot()
The goal of biplotEZ is to provide users an EZ-to-use platform for visually representing their data with biplots. Currently, this package includes principal component analysis (PCA) and canonical variate analysis (CVA) biplots. This is accompanied by various formatting options for the samples and axes. Alpha-bags and concentration ellipses are included for visual enhancements and interpretation.
Package: | biplotEZ |
Type: | Package |
Version: | 2.0 |
Date: | 05-04-2024 |
License: | MIT |
LazyLoad: | TRUE |
Sugnet Lubbe (Maintainer, [email protected])
Niël le Roux
Johané Nienkemper-Swanepoel
Raeesa Ganey
Ruan Buys
Zoë-Mae Adams
Peter Manefeldt
The newest version of the package can be obtained on GitHub: https://github.com/MuViSU/biplotEZ
This function produces a list of elements to be used for CA biplot construction by approximation of the Pearson residuals.
CA(bp, dim.biplot = c(2,1,3), e.vects = 1:ncol(bp$X), variant = "Princ", lambda.scal = FALSE)
CA(bp, dim.biplot = c(2,1,3), e.vects = 1:ncol(bp$X), variant = "Princ", lambda.scal = FALSE)
bp |
object of class |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
which eigenvectors (canonical variates) to extract, with default |
variant |
which correspondence analysis variant, with default "Princ", presents a biplot with rows in principal coordinates
and columns in standard coordinates. |
lambda.scal |
logical value to request lambda-scaling, default is |
A list with the following components is available:
Z |
Combined data frame of the row and column coordinates. |
r |
Numer of levels in the row factor. |
c |
Numer of levels in the column factor. |
Dr |
Diagonal matrix of row profiles. |
Dc |
Diagonal matrix of column profiles. |
Drh |
Weighted row profiles. |
Dch |
Weighted column profiles. |
rowcoor |
Row coordinates based on the selected |
colcoor |
Column coordinates based on the selected |
P |
Correspondence Matrix. |
Smat |
Standardised Pearson residuals. |
SVD |
Singular value decomposition solution: |
e.vects |
Depending on what was specified in |
dim.biplot |
The dimension of the biplot. |
lambda.val |
The computed lambda value if lambda-scaling is requested. |
gamma |
Contribution of the singular values, based on the CA variant. |
# Creating a CA biplot with rows in principal coordinates: biplot(HairEyeColor[,,2], center = FALSE) |> CA() |> plot() # Creating a CA biplot with rows in standard coordinates: biplot(HairEyeColor[,,2], center = FALSE) |> CA(variant = "Stand") |> samples(col=c("magenta","purple"), pch = c(15,17), label.col = "black") |> plot() # Creating a CA biplot with rows and columns scaled equally: biplot(HairEyeColor[,,2], center = FALSE) |> CA(variant = "Symmetric") |> samples(col = c("magenta","purple"), pch = c(15,17), label.col = "black") |> plot()
# Creating a CA biplot with rows in principal coordinates: biplot(HairEyeColor[,,2], center = FALSE) |> CA() |> plot() # Creating a CA biplot with rows in standard coordinates: biplot(HairEyeColor[,,2], center = FALSE) |> CA(variant = "Stand") |> samples(col=c("magenta","purple"), pch = c(15,17), label.col = "black") |> plot() # Creating a CA biplot with rows and columns scaled equally: biplot(HairEyeColor[,,2], center = FALSE) |> CA(variant = "Symmetric") |> samples(col = c("magenta","purple"), pch = c(15,17), label.col = "black") |> plot()
Performs calculations for a CA biplot.
## S3 method for class 'biplot' CA( bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), variant = "Princ", lambda.scal = FALSE )
## S3 method for class 'biplot' CA( bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), variant = "Princ", lambda.scal = FALSE )
bp |
object of class |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
which eigenvectors (canonical variates) to extract, with default |
variant |
which correspondence analysis variant, with default "Princ", presents a biplot with rows in principal coordinates
and columns in standard coordinates. |
lambda.scal |
logical value to request lambda-scaling, default is |
an object of class CA, inherits from class biplot.
biplot(HairEyeColor[,,2], center = FALSE) |> CA() |> plot()
biplot(HairEyeColor[,,2], center = FALSE) |> CA() |> plot()
Categorical Principal Component Analysis
CATPCA(bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, show.class.means = FALSE)
CATPCA(bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, show.class.means = FALSE)
bp |
an object of class |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
which eigenvectors (principal components) to extract, with default |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.class.means |
logical, indicating whether group means should be plotted in the biplot. |
an object of class biplot
CATPCA (iris)
CATPCA (iris)
This function produces a list of elements to be used for constructing a classification biplot.
classification(bp, Pmat, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes=NULL, axes = "regression", col=ez.col, opacity=0.4, borders = FALSE)
classification(bp, Pmat, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes=NULL, axes = "regression", col=ez.col, opacity=0.4, borders = FALSE)
bp |
an object of class |
Pmat |
a matrix containing the posterior probability for the classes |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
which eigenvectors (principal components) to extract, with default |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
axes |
type of axes, defaults to "regression" |
col |
colour of the classification regions |
opacity |
opacity of classification regions |
borders |
logical, indicating whether borders should be added to classification regions |
Object of class biplot with the following elements:
Gardner-Lubbe, S., 2016. A triplot for multiclass classification visualisation. Computational Statistics & Data Analysis, 94, pp.20-32.
biplot(iris[,1:4]) |> classification(predict(MASS::lda(Species ~ ., data = iris))$posterior) # create a classification biplot biplot(iris[,1:4]) |> classification(predict(MASS::lda(Species ~ ., data = iris))$posterior) |> plot()
biplot(iris[,1:4]) |> classification(predict(MASS::lda(Species ~ ., data = iris))$posterior) # create a classification biplot biplot(iris[,1:4]) |> classification(predict(MASS::lda(Species ~ ., data = iris))$posterior) |> plot()
Performs calculations for a classification biplot.
## S3 method for class 'biplot' classification( bp, Pmat, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, axes = "regression", col = ez.col, opacity = 0.4, borders = FALSE )
## S3 method for class 'biplot' classification( bp, Pmat, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, axes = "regression", col = ez.col, opacity = 0.4, borders = FALSE )
bp |
an object of class |
Pmat |
a matrix containing the posterior probability for the classes |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
which eigenvectors (principal components) to extract, with default |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
axes |
type of axes, defaults to "regression" |
col |
colour of the classification regions |
opacity |
opacity of classification regions |
borders |
logical, indicating whether borders should be added to classification regions |
an object of class biplot.
Classify samples into classes
classify( bp, classify.regions = TRUE, col = ez.col, opacity = 0.4, borders = FALSE )
classify( bp, classify.regions = TRUE, col = ez.col, opacity = 0.4, borders = FALSE )
bp |
an object of class |
classify.regions |
a logical value indicating whether classifications regions should be
shown in the biplot, with default |
col |
the colours of the classification regions |
opacity |
the opacity levels of the classification regions |
borders |
the border colours of the classification regions |
A list object called classify
appended to the object of class biplot
with the following elements:
table |
the confusion matrix resulting from the classification into classes. |
rate |
the classification accuracy rate. |
classify.regions |
a logical value indicating whether classification regions are shown in the biplot. |
aes |
a list of chosen aesthetics for the colours, opacity levels and border colours of the classification regions. |
biplot(iris[,1:4],classes = iris[,5]) |> CVA() |> axes(col="black") |> classify(col=c("red","blue","orange"),opacity=0.1) |> plot()
biplot(iris[,1:4],classes = iris[,5]) |> CVA() |> axes(col="black") |> classify(col=c("red","blue","orange"),opacity=0.1) |> plot()
This function allows the user to format the aesthetics for the category level points (CLPs).
CLPs (bp, which = 1:ncol(bp$Xcat), col = "black", cex = 0.6)
CLPs (bp, which = 1:ncol(bp$Xcat), col = "black", cex = 0.6)
bp |
an object of class |
which |
a vector containing the columns or variables for which the CLPs should be displayed,
with default |
col |
the colour(s) for the CLPs, with default |
cex |
the character expansion(s) for the CLPs, with default |
The object of class biplot
will be appended with a list called CLP.aes
containing the following elements A list with the following components is available:
which |
a vector containing the columns or variables for which the CLPs are displayed. |
col |
the colour(s) of the CLPs. |
cex |
the character expansion(s) of the plotting characters of the CLPs. |
mtdf <- as.data.frame(mtcars) mtdf$cyl <- factor(mtdf$cyl) mtdf$vs <- factor(mtdf$vs) mtdf$am <- factor(mtdf$am) mtdf$gear <- factor(mtdf$gear) mtdf$carb <- factor(mtdf$carb) biplot(mtdf[,-11], scaled = TRUE) |> AoD(classes = mtdf[,11]) |> CLPs(col = list(rep("olivedrab",3), rep("orange",2), rep("coral",2), rep("brown",3))) |> plot()
mtdf <- as.data.frame(mtcars) mtdf$cyl <- factor(mtdf$cyl) mtdf$vs <- factor(mtdf$vs) mtdf$am <- factor(mtdf$am) mtdf$gear <- factor(mtdf$gear) mtdf$carb <- factor(mtdf$carb) biplot(mtdf[,-11], scaled = TRUE) |> AoD(classes = mtdf[,11]) |> CLPs(col = list(rep("olivedrab",3), rep("orange",2), rep("coral",2), rep("brown",3))) |> plot()
This function allows the user to format the aesthetics for the category level points (CLRs).
CLRs (bp, which = 1, col = "black")
CLRs (bp, which = 1, col = "black")
bp |
an object of class |
which |
the column name or number for which the CLRs should be displayed, with default |
col |
the colours for the CLRs, with default |
The object of class biplot
will be appended with a list called CLP.aes
containing the following elements A list with the following components is available:
which |
the variable number for which the CLRs are displayed. |
col |
the colours of the CLRs. |
mtdf <- as.data.frame(mtcars) mtdf$cyl <- factor(mtdf$cyl) mtdf$vs <- factor(mtdf$vs) mtdf$am <- factor(mtdf$am) mtdf$gear <- factor(mtdf$gear) mtdf$carb <- factor(mtdf$carb) #biplot(mtdf[,-11], scaled = TRUE) |> PCO(group.aes = mtdf[,11]) |> #CLRs(which = 10, col = "coral") |> plot()
mtdf <- as.data.frame(mtcars) mtdf$cyl <- factor(mtdf$cyl) mtdf$vs <- factor(mtdf$vs) mtdf$am <- factor(mtdf$am) mtdf$gear <- factor(mtdf$gear) mtdf$carb <- factor(mtdf$carb) #biplot(mtdf[,-11], scaled = TRUE) |> PCO(group.aes = mtdf[,11]) |> #CLRs(which = 10, col = "coral") |> plot()
This function appends the biplot
object with elements resulting from performing CVA.
CVA(bp, classes=bp$classes, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), weightedCVA = "weighted", show.class.means = TRUE, low.dim = "sample.opt")
CVA(bp, classes=bp$classes, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), weightedCVA = "weighted", show.class.means = TRUE, low.dim = "sample.opt")
bp |
an object of class |
classes |
a vector of the same length as the number of rows in the data matrix with the class indicator for the samples. |
dim.biplot |
the dimension of the biplot. Only values |
e.vects |
the vector indicating which eigenvectors (canonical variates) should be plotted in the biplot, with default |
weightedCVA |
a character string indicating which type of CVA to perform. One of " |
show.class.means |
a logical value indicating whether to plot the class means on the biplot. |
low.dim |
a character string indicating which method to use to construct additional dimension(s) if the dimension of the canonical space is smaller than |
Object of class CVA with the following elements:
X |
the matrix of the centered and scaled numeric variables. |
Xcat |
the data frame of the categorical variables. |
raw.X |
the original data. |
classes |
the vector of category levels for the class variable. This is to be used for |
na.action |
the vector of observations that have been removed. |
center |
a logical value indicating whether |
scaled |
a logical value indicating whether |
means |
the vector of means for each numerical variable. |
sd |
the vector of standard deviations for each numerical variable. |
n |
the number of observations. |
p |
the number of variables. |
group.aes |
the vector of category levels for the grouping variable. This is to be used for |
g.names |
the descriptive names to be used for group labels. |
g |
the number of groups. |
Title |
the title of the biplot rendered. |
Lmat |
the matrix for transformation to the canonical space. |
Linv |
the inverse of |
eigenvalues |
the vector of eigenvalues of the two-sided eigenvalue problem. |
Z |
the matrix with each row containing the details of the points to be plotted (i.e. coordinates). |
ax.one.unit |
one unit in the positive direction of each biplot axis. |
Gmat |
the indicator matrix defining membership of the classes. |
Xmeans |
the matrix of the class means. |
Zmeans |
the matrix of the class mean coordinates that are plotted in the biplot. |
e.vects |
the vector indicating which canonical variates are plotted in the biplot. |
Cmat |
the centring matrix based on different choices of weighting described in arguments. |
Bmat |
the between class sums of squares and cross products matrix. |
Wmat |
the within class sums of squares and cross products matrix. |
Mrr |
the matrix used for prediction from the canonical space (the inverse of |
Mr |
the first r dimensions of the solution to be plotted. |
Nmat |
the matrix with the class sizes on the diagonal. |
lambda.mat |
the matrix with the eigenvalues of |
class.means |
a logical value indicating whether the class means should be plotted in the biplot. |
dim.biplot |
the dimension of the biplot. |
low.dim |
the method used to construct additional dimension(s). |
biplot(iris[,1:4]) |> CVA(classes=iris[,5]) # create a CVA biplot biplot(iris[,1:4]) |> CVA(classes=iris[,5]) |> plot()
biplot(iris[,1:4]) |> CVA(classes=iris[,5]) # create a CVA biplot biplot(iris[,1:4]) |> CVA(classes=iris[,5]) |> plot()
This function performs calculations for the construction of a CVA biplot.
## S3 method for class 'biplot' CVA( bp, classes = bp$classes, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), weightedCVA = "weighted", show.class.means = TRUE, low.dim = "sample.opt" )
## S3 method for class 'biplot' CVA( bp, classes = bp$classes, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), weightedCVA = "weighted", show.class.means = TRUE, low.dim = "sample.opt" )
bp |
an object of class |
classes |
a vector of the same length as the number of rows in the data matrix with the class indicator for the samples. |
dim.biplot |
the dimension of the biplot. Only values |
e.vects |
the vector indicating which eigenvectors (canonical variates) should be plotted in the biplot, with default |
weightedCVA |
a character string indicating which type of CVA to perform. One of " |
show.class.means |
a logical value indicating whether to plot the class means on the biplot. |
low.dim |
a character string indicating which method to use to construct additional dimension(s) if the dimension of the canonical space is smaller than |
an object of class CVA
, inherits from class biplot
.
biplot(iris[,1:4]) |> CVA(classes=iris[,5])
biplot(iris[,1:4]) |> CVA(classes=iris[,5])
This function is used to add dimensions to the CVA biplot when the dimension of the canonical space is smaller than the dimension of the biplot (
dim.biplot
). This function is already used in the CVA calculations, and will therefore not have to be used in isolation.
CVAlowdim(bp, G, W, Mmat, low.dim, K, e.vects)
CVAlowdim(bp, G, W, Mmat, low.dim, K, e.vects)
bp |
an object of class |
G |
the indicator matrix defining membership of the classes. |
W |
the within class sums of squares and cross products matrix. |
Mmat |
the eigenvector matrix from CVA. |
low.dim |
a character string indicating which method to use to construct additional dimension(s) if the dimension of the canonical space is smaller than |
K |
the dimension of the canonical space. |
e.vects |
the vector indicating which canonical variates are plotted in the biplot, with default |
A list with three components:
Mr |
the first r dimensions of the solution to be plotted. |
Mrr |
the matrix used for prediction from the canonical space. |
Lmat |
the matrix for transformation to the canonical space. |
Creates a kernel density in 1-dimension
density1D( bp, which = NULL, h = "nrd0", kernel = "gaussian", col = ez.col, lwd = 1.5, legend.mar = c(2, 5, 0, 5) )
density1D( bp, which = NULL, h = "nrd0", kernel = "gaussian", col = ez.col, lwd = 1.5, legend.mar = c(2, 5, 0, 5) )
bp |
object of class |
which |
which group. |
h |
bandwidth. |
kernel |
character string giving the smoothing kernel to be used. |
col |
colours to be used for each of the density curves. |
lwd |
linewidth of density curve. |
legend.mar |
The margin line of the legend. |
An object of class biplot
.
biplot (iris,classes=iris[,5]) |> CVA(dim=1) |> density1D() |> plot()
biplot (iris,classes=iris[,5]) |> CVA(dim=1) |> density1D() |> plot()
Create a density in 2-dimensions
density2D( bp, which = NULL, contours = F, h = NULL, n = 100, col = c("green", "yellow", "red"), contour.col = "black", cuts = 50, cex = 0.6, tcl = -0.2, mgp = c(0, -0.25, 0), layout.heights = c(100, 10), legend.mar = c(2, 5, 0, 5) )
density2D( bp, which = NULL, contours = F, h = NULL, n = 100, col = c("green", "yellow", "red"), contour.col = "black", cuts = 50, cex = 0.6, tcl = -0.2, mgp = c(0, -0.25, 0), layout.heights = c(100, 10), legend.mar = c(2, 5, 0, 5) )
bp |
object of class |
which |
which group to create a density; limited to only a single group at a time. If NULL, density drawn over all data points. |
contours |
logical indicating whether contours are added to the density plot |
h |
vector of bandwidths for x and y directions, see |
n |
number of grid points in each direction. Can be scalar or a length-2 integer vector. |
col |
vector of colours to use to form a 'continuous' sequence of colours. |
contour.col |
colour of the contours. |
cuts |
number of colours in |
cex |
character expansion. |
tcl |
The length of tick marks as a fraction of the height of a line of text. |
mgp |
The margin line. |
layout.heights |
A vector of values for the heights of rows. |
legend.mar |
The margin line of the legend. |
An object of class biplot
.
biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> density2D(which=3,col=c("white","purple","cyan","blue")) |> plot() biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> density2D(which=3,col=c("white","purple","cyan","blue"),contours = TRUE, contour.col = "grey") |> plot()
biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> density2D(which=3,col=c("white","purple","cyan","blue")) |> plot() biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> density2D(which=3,col=c("white","purple","cyan","blue"),contours = TRUE, contour.col = "grey") |> plot()
-ellipses)This function produces -ellipses, which is a useful geometrical description of the
data points about the sample mean.
ellipses(bp, df=2, kappa = NULL, which = NULL, alpha = 0.95, col = bp$sample$col[which], lty = 1, lwd = 1, opacity = 0.25, trace = TRUE)
ellipses(bp, df=2, kappa = NULL, which = NULL, alpha = 0.95, col = bp$sample$col[which], lty = 1, lwd = 1, opacity = 0.25, trace = TRUE)
bp |
an object of class |
df |
degrees of freedom, with default |
kappa |
value to construct |
which |
the selection of the group for ellipse construction. |
alpha |
size of |
col |
colour of ellipse. Multiple |
lty |
line type of ellipse. The same line type will be used per value of |
lwd |
line width of ellipse. The same line width will be used per value of |
opacity |
level of opacity, with default |
trace |
logical, indicating progress of computation. |
A list with the following components is available:
conc.ellipses |
list of coordinates for the |
col |
vector of colours for the |
lty |
vector of line types for the |
lwd |
vector of line widths for the |
alpha |
vector of |
Gower, J., Gardner-Lubbe, S. & Le Roux, N. (2011, ISBN: 978-0-470-01255-0) Understanding Biplots. Chichester, England: John Wiley & Sons Ltd.
biplot (iris[,1:4]) |> PCA(group.aes=iris[,5]) |> ellipses(kappa=2) |> plot()
biplot (iris[,1:4]) |> PCA(group.aes=iris[,5]) |> ellipses(kappa=2) |> plot()
Extended matching coefficient
extended.matching.coefficient(X)
extended.matching.coefficient(X)
X |
a data frame containing the categorical variables used for computing the EMC distance |
a dist object
mtdf <- as.data.frame(mtcars) mtdf$cyl <- factor(mtdf$cyl) mtdf$vs <- factor(mtdf$vs) mtdf$am <- factor(mtdf$am) mtdf$gear <- factor(mtdf$gear) mtdf$carb <- factor(mtdf$carb) extended.matching.coefficient(mtdf[,8:11])
mtdf <- as.data.frame(mtcars) mtdf$cyl <- factor(mtdf$cyl) mtdf$vs <- factor(mtdf$vs) mtdf$am <- factor(mtdf$am) mtdf$gear <- factor(mtdf$gear) mtdf$carb <- factor(mtdf$carb) extended.matching.coefficient(mtdf[,8:11])
This function computes the measures of fit for the biplot. The biplot object is augmented with additional items, which can differ depending on the type of biplot. The measures provide information on the overall quality of fit and the adequacy of representation of variables.
fit.measures(bp)
fit.measures(bp)
bp |
an object of class |
An object of class biplot
. The object is augmented with
additional items, depending on the type of biplot object.
quality |
the overall quality of fit. |
adequacy |
the adequacy of representation of variables. |
For an object of class PCA
:
axis.predictivity |
the fit measure of each individual axis. |
sample.predictivity |
the fit measure for each individual sample. |
For an object of class CVA
:
axis.predictivity |
the fit measure of each individual axis. |
class.predictivity |
the fit measure for each class mean. |
within.class.axis.predictivity |
the fit measure for each axis based on values expressed as deviations from their class means. |
within.class.sample.predictivity |
the fit measure for each sample expressed as deviation from its class mean. |
For an object of class CA
:
row.predictivity |
the fit measure for each row of the input matrix individual sample. |
col.predictivity |
the fit measure for each column of the input matrix individual sample. |
Xhat |
predicted matrix per row profile |
out <- biplot (iris[,1:4]) |> PCA() |> fit.measures() summary(out)
out <- biplot (iris[,1:4]) |> PCA() |> fit.measures() summary(out)
This function adds supplementary points and variables to the plot from a new data set.
interpolate(bp, newdata = NULL, newvariable = NULL)
interpolate(bp, newdata = NULL, newvariable = NULL)
bp |
an object of class |
newdata |
a new data set, similar in structure to the data set supplied to |
newvariable |
a new data set, similar in structure to the data set supplied to |
The object of class biplot
will be appended with the following elements:
Xnew.raw |
the new data. |
Xnew |
the matrix of the centered and scaled new numeric variables of new data. |
Xnew.cat |
the matrix of the categorical variables of new data. |
Znew |
the matrix of the coordinates of the new data in the biplot. |
For an object of class CA
the following additional elements will be appended:
newrowcoor |
the matrix of row coordinates of the new data in the biplot. |
newcolcoor |
the matrix of column coordinates of the new data in the biplot. |
biplot(data = iris[1:145,]) |> PCA() |> interpolate(newdata = iris[146:150,]) |> plot() biplot(HairEyeColor[,,2], center = FALSE) |> CA(variant = "Symmetric") |> interpolate(newdata = HairEyeColor[,,1]) |> plot()
biplot(data = iris[1:145,]) |> PCA() |> interpolate(newdata = iris[146:150,]) |> plot() biplot(HairEyeColor[,,2], center = FALSE) |> CA(variant = "Symmetric") |> interpolate(newdata = HairEyeColor[,,1]) |> plot()
This function enables the user to format the legend and make a required selection to display.
legend.type(bp, samples = FALSE, means = FALSE, bags = FALSE, ellipses=FALSE,regions=FALSE, new=FALSE, ...)
legend.type(bp, samples = FALSE, means = FALSE, bags = FALSE, ellipses=FALSE,regions=FALSE, new=FALSE, ...)
bp |
an object of class |
samples |
a logical value indicating whether a legend should be printed for samples, with default |
means |
a logical value indicating whether a legend should be printed for means, with default |
bags |
a logical value indicating whether a legend should be printed for bags, with default |
ellipses |
a logical value indicating whether a legend should be printed for concentration ellipses, with default |
regions |
a logical value indicating whether a legend should be printed for classification regions, with default |
new |
a logical value indicating whether the legend should appear in a new window, with default |
... |
additional arguments to be sent to |
A list with the following components is available:
samples |
a logical value indicating whether a legend for samples are provided. |
means |
a logical value indicating whether a legend for class means are provided. |
bags |
a logical value indicating whether a legend for |
ellipses |
a logical value indicating whether a legend for |
regions |
a logical value indicating whether a legend for classification regions are provided. |
new |
a logical value indicating whether the legend appears on new plot. |
biplot (iris[,1:4], Title="Test biplot") |> PCA(group.aes = iris[,5]) |> legend.type(samples=TRUE) |> plot()
biplot (iris[,1:4], Title="Test biplot") |> PCA(group.aes = iris[,5]) |> legend.type(samples=TRUE) |> plot()
This function allows the user to format the aesthetics for the class means or group means.
means (bp, which = NULL, col = NULL, pch = 15, cex = 1, label = FALSE, label.col = NULL,label.cex = 0.75, label.side = "bottom", label.offset = 0.5, opacity = 1, shade.darker = TRUE)
means (bp, which = NULL, col = NULL, pch = 15, cex = 1, label = FALSE, label.col = NULL,label.cex = 0.75, label.side = "bottom", label.offset = 0.5, opacity = 1, shade.darker = TRUE)
bp |
an object of class |
which |
a vector containing the groups or classes for which the means should be displayed, with default |
col |
the colour(s) for the means, with default as the colour of the samples. |
pch |
the plotting character(s) for the means, with default |
cex |
the character expansion(s) for the means, with default |
label |
a logical value indicating whether the means should be labelled, with default |
label.col |
a vector of the same length as |
label.cex |
a vector of the same length as |
label.side |
the side at which the label of the plotted mean point appears, with default |
label.offset |
the offset of the label from the plotted mean point. See |
opacity |
transparency of means. |
shade.darker |
a logical value indicating whether the colour of the mean points should be made a shade darker than the default or specified colour, with default |
The number of classes or groups (defined by group.aes) is indicated as g
. If an argument is not of length g
,
recycling is used.
The object of class biplot
will be appended with a list called means
containing the following elements:
which |
a vector containing the groups or classes for which the means are displayed. |
col |
the colour(s) of the means. |
pch |
the plotting character(s) of the means. |
cex |
the character expansion(s) of the plotting character(s) of the means. |
label |
a logical value indicating whether means are labelled. |
label.col |
the label colours of the means. |
label.cex |
the label text expansions of the samples. |
label.side |
the side at which the label of the plotted mean point appears. |
label.offset |
the offset of the label from the plotted mean point. |
opacity |
the opacity level of the plotted points. |
biplot(iris[,1:4]) |> PCA() |> means(col = "purple", pch = 15, cex = 2) |> plot()
biplot(iris[,1:4]) |> PCA() |> means(col = "purple", pch = 15, cex = 2) |> plot()
This function allows the user to format the aesthetics for the supplementary (new) biplot axes.
newaxes(bp, X.new.names=bp$var.names, which = 1:bp$num.vars, col = "orange", lwd = 1, lty = 1, label.dir = "Orthog", label.col = col, label.cex = 0.75, label.line = 0.1, ticks = 5, tick.col = col, tick.size = 1, tick.label = TRUE, tick.label.col = tick.col, tick.label.cex = 0.6, tick.label.side = "below", predict.col = col, predict.lwd = lwd, predict.lty = lty, ax.names = X.new.names, orthogx = 0, orthogy = 0)
newaxes(bp, X.new.names=bp$var.names, which = 1:bp$num.vars, col = "orange", lwd = 1, lty = 1, label.dir = "Orthog", label.col = col, label.cex = 0.75, label.line = 0.1, ticks = 5, tick.col = col, tick.size = 1, tick.label = TRUE, tick.label.col = tick.col, tick.label.cex = 0.6, tick.label.side = "below", predict.col = col, predict.lwd = lwd, predict.lty = lty, ax.names = X.new.names, orthogx = 0, orthogy = 0)
bp |
an object of class |
X.new.names |
a vector of the new column names of |
which |
a vector containing the new columns or variables for which the axes should be displayed, with default |
col |
the colour(s) for the axes, with default |
lwd |
the line width(s) for the axes, with default |
lty |
the line type(s) for the axes, with default |
label.dir |
a character string indicating the placement of the axis titles to the side of the figure. One of " |
label.col |
the colour(s) for the axis labels, with default, |
label.cex |
the label expansion for the axis labels, with default |
label.line |
the distance of the axis title from the side of the figure, with default |
ticks |
an integer-valued vector indicating the number of tickmarks for each axis, with default |
tick.col |
the colour(s) for the tick marks, with default |
tick.size |
a vector specifying the sizes of tick marks for each axis, with default |
tick.label |
a logical value indicating whether the axes should be labelled, with default |
tick.label.col |
the colour(s) for the tick mark labels, with default |
tick.label.cex |
the label expansion for the tick mark labels, with default |
tick.label.side |
a character string indicating the position of the tick label. One of " |
predict.col |
the colour(s) for the predicted samples, with default |
predict.lwd |
the line width(s) for the predicted samples, with default |
predict.lty |
the line type(s) for the predicted samples, with default |
ax.names |
a vector of size |
orthogx |
a numeric vector of size |
orthogy |
a numeric vector of size |
The object of class biplot
will be appended with a list called newaxes
containing elements similar to that of axes
.
biplot(data = iris[,1:2]) |> PCA() |> interpolate(newvariable = iris[3:4]) |> newaxes(col="gold") |> plot()
biplot(data = iris[,1:2]) |> PCA() |> interpolate(newvariable = iris[3:4]) |> newaxes(col="gold") |> plot()
This function allows formatting changes to new samples.
newsamples (bp, col = "darkorange1", pch = 1, cex = 1, label = FALSE, label.name = NULL, label.col = NULL,label.cex = 0.75, label.side = "bottom", label.offset = 0.5, connected = FALSE, connect.col = "black", connect.lty=1, connect.lwd=1)
newsamples (bp, col = "darkorange1", pch = 1, cex = 1, label = FALSE, label.name = NULL, label.col = NULL,label.cex = 0.75, label.side = "bottom", label.offset = 0.5, connected = FALSE, connect.col = "black", connect.lty=1, connect.lwd=1)
bp |
an object of class |
col |
the colour(s) for the new samples, with default |
pch |
the plotting character(s) for the new samples, with default |
cex |
the character expansion(s) for the new samples, with default |
label |
a logical value indicating whether new samples should be labelled or not, with default |
label.name |
the label names for the new samples. |
label.col |
a vector of the same length as the number of new samples containing the colour(s) for the labels of the new samples, with default the colour of the sample points. |
label.cex |
the label text expansion(s) for the new samples, with default |
label.side |
the side at which the label of the plotted point appears, with default |
label.offset |
the offset of the label from the plotted point. See |
connected |
a logical value indicating whether samples are connected in order of rows of the data matrix, with default |
connect.col |
the colour of the connecting line, with default |
connect.lty |
the line type of the connecting line, with default |
connect.lwd |
the line width of the connecting line, with default |
The object of class biplot
will be appended with a list called newsamples
containing the following elements:
col |
the colour(s) of the new samples. |
pch |
the plotting character(s) of the new samples. |
cex |
the character expansion(s) of the plotting character(s) of the new samples. |
label |
a logical value indicating whether new samples are labelled. |
label.col |
the label colours of the new samples. |
label.cex |
the label text expansions of the new samples. |
label.side |
the side at which the label of the plotted point appears. |
label.offset |
the offset of the label from the plotted point. |
connected |
a logical value indicating whether new samples are connected. |
connect.col |
the colour of the connecting line. |
connect.lty |
the line type of the connecting line. |
connect.lwd |
the line width of the connecting line. |
biplot(data = iris[1:145,]) |> PCA() |> samples(col = "grey") |> interpolate(newdata = iris[146:150,]) |> newsamples(col = rainbow(6), pch=15) |> plot()
biplot(data = iris[1:145,]) |> PCA() |> samples(col = "grey") |> interpolate(newdata = iris[146:150,]) |> newsamples(col = rainbow(6), pch=15) |> plot()
This function appends the biplot
object with elements resulting from performing PCA.
PCA(bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, show.class.means = FALSE, correlation.biplot = FALSE)
PCA(bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, show.class.means = FALSE, correlation.biplot = FALSE)
bp |
an object of class |
dim.biplot |
the dimension of the biplot. Only values |
e.vects |
the vector indicating which eigenvectors (principal components) should be plotted in the biplot, with default |
group.aes |
a vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.class.means |
a logical value indicating whether group means should be plotted in the biplot. |
correlation.biplot |
a logical value. If |
An object of class PCA with the following elements:
X |
the matrix of the centered and scaled numeric variables. |
Xcat |
the data frame of the categorical variables. |
raw.X |
the original data. |
classes |
the vector of category levels for the class variable. This is to be used for |
na.action |
the vector of observations that have been removed. |
center |
a logical value indicating whether |
scaled |
a logical value indicating whether |
means |
the vector of means for each numerical variable. |
sd |
the vector of standard deviations for each numerical variable. |
n |
the number of observations. |
p |
the number of variables. |
group.aes |
the vector of category levels for the grouping variable. This is to be used for |
g.names |
the descriptive names to be used for group labels. |
g |
the number of groups. |
Title |
the title of the biplot rendered. |
Z |
the matrix with each row containing the details of the points that are plotted (i.e. coordinates). |
Lmat |
the matrix for transformation to the principal components. |
Linv |
the inverse of |
eigenvalues |
the vector of eigenvalues of the covariance matrix of |
ax.one.unit |
one unit in the positive direction of each biplot axis. |
e.vects |
the vector indicating which principal components are plotted in the biplot. |
Vr |
the |
dim.biplot |
the dimension of the biplot. |
class.means |
a logical value indicating whether group means are plotted in the biplot. |
Zmeans |
the matrix of class mean coordinates that are plotted in the biplot. |
Gabriel, K.R. (1971) The biplot graphic display of matrices with application to principal component analysis. Biometrika. 58(3):453–467.
biplot(iris[,1:4]) |> PCA() # create a PCA biplot biplot(data = iris) |> PCA() |> plot()
biplot(iris[,1:4]) |> PCA() # create a PCA biplot biplot(data = iris) |> PCA() |> plot()
This function performs calculations for the construction of a PCA biplot.
## S3 method for class 'biplot' PCA( bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, show.class.means = FALSE, correlation.biplot = FALSE )
## S3 method for class 'biplot' PCA( bp, dim.biplot = c(2, 1, 3), e.vects = 1:ncol(bp$X), group.aes = NULL, show.class.means = FALSE, correlation.biplot = FALSE )
bp |
an object of class |
dim.biplot |
the dimension of the biplot. Only values |
e.vects |
the vector indicating which eigenvectors (principal components) should be plotted in the biplot, with default |
group.aes |
a vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.class.means |
a logical value indicating whether group means should be plotted in the biplot. |
correlation.biplot |
a logical value. If |
an object of class PCA
, inherits from class biplot
.
biplot(iris[,1:4]) |> PCA() # create a PCA biplot biplot(data = iris) |> PCA() |> plot()
biplot(iris[,1:4]) |> PCA() # create a PCA biplot biplot(data = iris) |> PCA() |> plot()
Principal Coordinate Analysis (PCO) biplot method
PCO(bp, Dmat=NULL, dist.func=NULL, dist.func.cat=NULL, dim.biplot = c(2,1,3), e.vects = NULL, group.aes=NULL, show.class.means = FALSE, axes = c("regression","splines"), ...)
PCO(bp, Dmat=NULL, dist.func=NULL, dist.func.cat=NULL, dim.biplot = c(2,1,3), e.vects = NULL, group.aes=NULL, show.class.means = FALSE, axes = c("regression","splines"), ...)
bp |
an object of class |
Dmat |
nxn matrix of Euclidean embeddable distances between samples |
dist.func |
function to compute Euclidean embeddable distances between samples. The default NULL computes Euclidean distance. |
dist.func.cat |
function to compute Euclidean embeddable distance between categorical variables for the samples. The default NULL computes the extended matching coefficient. |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
e.vects which eigenvectors (canonical variates) to extract, with default |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.class.means |
logical, indicating whether to plot the class means on the biplot. |
axes |
type of biplot axes, currently only regression axes are implemented |
... |
more arguments to |
Object of class biplot
biplot(iris[,1:4]) |> PCO(dist.func = sqrtManhattan) # create a CVA biplot biplot(iris[,1:4]) |> PCO(dist.func = sqrtManhattan) |> plot()
biplot(iris[,1:4]) |> PCO(dist.func = sqrtManhattan) # create a CVA biplot biplot(iris[,1:4]) |> PCO(dist.func = sqrtManhattan) |> plot()
Computes Principal Coordinate Analysis biplot
## S3 method for class 'biplot' PCO( bp, Dmat = NULL, dist.func = NULL, dist.func.cat = NULL, dim.biplot = c(2, 1, 3), e.vects = NULL, group.aes = NULL, show.class.means = FALSE, axes = c("regression", "splines"), ... )
## S3 method for class 'biplot' PCO( bp, Dmat = NULL, dist.func = NULL, dist.func.cat = NULL, dim.biplot = c(2, 1, 3), e.vects = NULL, group.aes = NULL, show.class.means = FALSE, axes = c("regression", "splines"), ... )
bp |
an object of class |
Dmat |
nxn matrix of Euclidean embeddable distances between samples |
dist.func |
function to compute Euclidean embeddable distances between samples. The default NULL computes Euclidean distance. |
dist.func.cat |
function to compute Euclidean embeddable distance between categorical variables for the samples. The default NULL computes the extended matching coefficient. |
dim.biplot |
dimension of the biplot. Only values 1, 2 and 3 are accepted, with default |
e.vects |
e.vects which eigenvectors (canonical variates) to extract, with default |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.class.means |
logical, indicating whether to plot the class means on the biplot. |
axes |
type of biplot axes, currently only regression axes are implemented |
... |
more arguments to |
an object of class biplot.
biplot(iris) |> PCO(dist.func=sqrtManhattan) |> plot()
biplot(iris) |> PCO(dist.func=sqrtManhattan) |> plot()
Generic Plotting function of objects of class biplot
## S3 method for class 'biplot' plot( x, exp.factor = 1.2, axis.predictivity = NULL, sample.predictivity = NULL, zoom = FALSE, xlim = NULL, ylim = NULL, ... )
## S3 method for class 'biplot' plot( x, exp.factor = 1.2, axis.predictivity = NULL, sample.predictivity = NULL, zoom = FALSE, xlim = NULL, ylim = NULL, ... )
x |
An object of class |
exp.factor |
a numeric value with default axes of the biplot. Larger values are specified for zooming out with respect to sample points in the biplot display and smaller values are specified for zooming in with respect to sample points in the biplot display. |
axis.predictivity |
either a logical or a numeric value between |
sample.predictivity |
either a logical or a numeric value between 0 and 1. If it is a numeric value, this value is used as threshold so that only samples with sample predictivity larger than the threshold is displayed. If |
zoom |
a logical value allowing the user to select an area to zoom into. |
xlim |
the horizontal limits of the plot. |
ylim |
the vertical limits of the plot. |
... |
additional arguments. |
An object of class biplot
.
biplot (iris[,1:4]) |> PCA() |> plot()
biplot (iris[,1:4]) |> PCA() |> plot()
This function makes predictions of sample points, variables and means and displays them on the biplot.
prediction(bp, predict.samples = NULL, predict.means = NULL, which = 1:bp$p)
prediction(bp, predict.samples = NULL, predict.means = NULL, which = 1:bp$p)
bp |
an object of class |
predict.samples |
a vector specifying which samples to predict. |
predict.means |
a vector specifying which group means to predict. |
which |
a vector specifying which variable to do the prediction. |
A list object called predict
appended to the object of class biplot
with the following elements:
samples |
a vector of indices of samples which are being predicted. |
predict.means |
a vector of group names of groups for which the means are being predicted. |
which |
the vector of indices variables which are being predicted. |
predict.mat |
the matrix of predicted samples. |
predict.means.mat |
the matrix of predicted group means. |
biplot(data = iris[,1:4]) |> PCA(group.aes=iris[,5], show.class.means = TRUE) |> prediction(141:145,1:3) |> plot()
biplot(data = iris[,1:4]) |> PCA(group.aes=iris[,5], show.class.means = TRUE) |> prediction(141:145,1:3) |> plot()
This function is used to print output when the biplot object is created.
## S3 method for class 'biplot' print(x, ...)
## S3 method for class 'biplot' print(x, ...)
x |
an object of class |
... |
additional arguments. |
This function will not produce a return value, it is called for side effects.
out <- biplot (iris[,1:4]) |> PCA() out
out <- biplot (iris[,1:4]) |> PCA() out
This function provides the user with an option to reflect the biplot horizontally, vertically or diagonally.
reflect(bp, reflect.axis = c("FALSE", "x", "y", "xy"))
reflect(bp, reflect.axis = c("FALSE", "x", "y", "xy"))
bp |
an object of class |
reflect.axis |
a character string indicating which axis about to reflect. One of |
An object of class biplot
biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> reflect("x") |> plot() biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> reflect("y") |> plot() biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> reflect("xy") |> plot()
biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> reflect("x") |> plot() biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> reflect("y") |> plot() biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> reflect("xy") |> plot()
Regression biplot method
regress(bp, Z, group.aes=NULL, show.group.means = TRUE, axes = c("regression", "splines"))
regress(bp, Z, group.aes=NULL, show.group.means = TRUE, axes = c("regression", "splines"))
bp |
an object of class |
Z |
the matrix of coordinates of the samples |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.group.means |
logical, indicating whether group means should be plotted in the biplot. |
axes |
the type of axes to be fitted to the biplot. Options are 'regression' for linear regression axes (default) and 'splines' for B-spline axes. |
Object of class biplot
biplot(iris[,1:4]) |> regress(Z=cmdscale(dist(iris[,1:4]))) |> plot()
biplot(iris[,1:4]) |> regress(Z=cmdscale(dist(iris[,1:4]))) |> plot()
Computes regression biplot axes
## S3 method for class 'biplot' regress( bp, Z, group.aes = NULL, show.group.means = TRUE, axes = c("regression", "splines") )
## S3 method for class 'biplot' regress( bp, Z, group.aes = NULL, show.group.means = TRUE, axes = c("regression", "splines") )
bp |
an object of class |
Z |
the matrix of coordinates of the samples |
group.aes |
vector of the same length as the number of rows in the data matrix for differentiated aesthetics for samples. |
show.group.means |
logical, indicating whether group means should be plotted in the biplot. |
axes |
the type of axes to be fitted to the biplot. Options are 'regression' for linear regression axes (default) and 'splines' for B-spline axes. |
an object of class biplot.
biplot(iris) |> regress(Z = cmdscale(dist(iris[,1:4]))) |> plot()
biplot(iris) |> regress(Z = cmdscale(dist(iris[,1:4]))) |> plot()
This function provides the user with an option to rotate the biplot anti-clockwise or clockwise.
rotate(bp, rotate.degrees = 0)
rotate(bp, rotate.degrees = 0)
bp |
an object of class |
rotate.degrees |
a value specifying the degrees the biplot should be rotated, with default |
An object of class biplot
.
biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> rotate(200) |> plot()
biplot(iris[,1:4],group.aes = iris[,5]) |> PCA() |> rotate(200) |> plot()
This function allows the user to format the aesthetics for the samples.
samples (bp, which = 1:bp$g, col = ez.col, pch = 16, cex = 1, label = FALSE, label.name = NULL, label.col=NULL, label.cex = 0.75, label.side = "bottom", label.offset = 0.5, connected=FALSE, connect.col = "black", connect.lty = 1, connect.lwd = 1, opacity = 1)
samples (bp, which = 1:bp$g, col = ez.col, pch = 16, cex = 1, label = FALSE, label.name = NULL, label.col=NULL, label.cex = 0.75, label.side = "bottom", label.offset = 0.5, connected=FALSE, connect.col = "black", connect.lty = 1, connect.lwd = 1, opacity = 1)
bp |
an object of class |
which |
a vector containing the groups or classes for which the samples should be displayed, with default |
col |
the colour(s) for the samples, with default |
pch |
the plotting character(s) for the samples, with default |
cex |
the character expansion(s) for the samples, with default |
label |
a logical value indicating whether the samples should be labelled, with default |
label.name |
a vector of the same length as |
label.col |
a vector of the same length as |
label.cex |
a vector of the same length as |
label.side |
the side at which the label of the plotted point appears, with default |
label.offset |
the offset of the label from the plotted point. See |
connected |
a logical value indicating whether samples are connected in order of rows of the data matrix, with default |
connect.col |
the colour of the connecting line, with default |
connect.lty |
the line type of the connecting line, with default |
connect.lwd |
the line width of the connecting line, with default |
opacity |
the opacity level of the plotted points, with default |
The arguments which
, col
, pch
and cex
are based on the specification of group.aes
or classes
. If no groups are specified, a single colour, plotting character and / or character expansion is expected. If groups are
specified, vectors of length
is expected, or values are recycled to length
.
The arguments label
, label.cex
, label.side
and label.offset
are based on the sample size . A single value
will be recycled
times or a vector of length
is expected.
The object of class biplot
will be appended with a list called samples
containing the following elements:
which |
a vector containing the groups or classes for which the samples (and means) are displayed. |
col |
the colour(s) of the samples. |
pch |
the plotting character(s) of the samples. |
cex |
the character expansion(s) of the plotting character(s) of the samples. |
label |
a logical value indicating whether samples are labelled. |
label.name |
the label names of the samples. |
label.col |
the label colours of the samples. |
label.cex |
the label text expansions of the samples. |
label.side |
the side at which the label of the plotted point appears.. |
label.offset |
the offset of the label from the plotted point. |
connected |
a logical value indicating whether samples are connected in order of the rows of the data matrix. |
connect.col |
the colour of the connecting line. |
connect.lty |
the line type of the connecting line. |
connect.lwd |
the line width of the connecting line. |
opacity |
the opacity level of the plotted points. |
biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=15, opacity=0.5) |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=NA, opacity=0.5, label = TRUE) |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=NA, opacity=0.5, label = TRUE, label.name = paste("s:",1:150, sep="")) |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=NA, opacity=0.5, label = "ggrepel") |> plot()
biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=15, opacity=0.5) |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=NA, opacity=0.5, label = TRUE) |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=NA, opacity=0.5, label = TRUE, label.name = paste("s:",1:150, sep="")) |> plot() biplot(iris[,1:4]) |> PCA() |> samples(col="purple",pch=NA, opacity=0.5, label = "ggrepel") |> plot()
Computes the square root of the Manhattan distance An example of a Euclidean embeddable distance metric
sqrtManhattan(X)
sqrtManhattan(X)
X |
matrix of samples x variables for computation of samples x samples distance matrix |
a dist object
sqrtManhattan(iris[,1:4])
sqrtManhattan(iris[,1:4])
This function is used to print summary output of the biplot. These summary outputs are related to measures of fit.
## S3 method for class 'biplot' summary( object, adequacy = TRUE, axis.predictivity = TRUE, sample.predictivity = TRUE, class.predictivity = TRUE, within.class.axis.predictivity = TRUE, within.class.sample.predictivity = TRUE, ... )
## S3 method for class 'biplot' summary( object, adequacy = TRUE, axis.predictivity = TRUE, sample.predictivity = TRUE, class.predictivity = TRUE, within.class.axis.predictivity = TRUE, within.class.sample.predictivity = TRUE, ... )
object |
an object of class |
adequacy |
a logical value indicating whether variable adequacies should be reported, with default |
axis.predictivity |
a logical value indicating whether axis predictivities should be reported, with default |
sample.predictivity |
a logical value indicating whether sample predictivities should be reported, with default |
class.predictivity |
a logical value indicating whether class predictivities should be reported, with default |
within.class.axis.predictivity |
a logical value indicating whether within class axis predictivity
should be reported, with default |
within.class.sample.predictivity |
a logical value indicating whether within class sample predictivity
should be reported, with default |
... |
additional arguments. |
This function will not produce a return value, it is called for side effects.
out <- biplot (iris[,1:4]) |> PCA() |> fit.measures() summary(out)
out <- biplot (iris[,1:4]) |> PCA() |> fit.measures() summary(out)
Automatically or manually translate the axes away from the center of the plot
translate_axes(bp, delta = 0, swop = FALSE, distances = NULL)
translate_axes(bp, delta = 0, swop = FALSE, distances = NULL)
bp |
An object of class |
delta |
numeric value indicating distance between axes |
swop |
logical. Change the direction in which axes are translated |
distances |
numeric vector of distances. Used to manually parallel translate the axes. |
This function uses the same algorithm implemented in TDAbiplot
in the bipl5
package. It translates the axes out of the center of the plot.
Correlated axes generally gets translated in the same direction.
This function calculates the orthogx
and orthogy
paramaters in axes()
An object of class biplot
with the translated distances appended under bp$axes
#Translate the axes out of the plot center bp <- biplot(state.x77,scaled = TRUE)|> CVA(state.region) |> translate_axes(swop=TRUE,delta =0.2)|> plot(exp.factor=3) #adjust the distance of an axis dist <- bp$axes$translate_distance dist[7] <- 0.4 bp |> translate_axes(delta = 0.2, distances=dist) |> plot()
#Translate the axes out of the plot center bp <- biplot(state.x77,scaled = TRUE)|> CVA(state.region) |> translate_axes(swop=TRUE,delta =0.2)|> plot(exp.factor=3) #adjust the distance of an axis dist <- bp$axes$translate_distance dist[7] <- 0.4 bp |> translate_axes(delta = 0.2, distances=dist) |> plot()