Title: | Multivariate Data Analysis |
---|---|
Description: | Simple Principal Components Analysis (PCA) and (Multiple) Correspondence Analysis (CA) based on the Singular Value Decomposition (SVD). This package provides S4 classes and methods to compute, extract, summarize and visualize results of multivariate data analysis. It also includes methods for partial bootstrap validation described in Greenacre (1984, ISBN: 978-0-12-299050-2) and Lebart et al. (2006, ISBN: 978-2-10-049616-7). |
Authors: | Nicolas Frerebeau [aut, cre] , Jean-Baptiste Fourvel [ctb] , Brice Lebrun [ctb] (<https://orcid.org/0000-0001-7503-8685>, Logo designer), Université Bordeaux Montaigne [fnd], CNRS [fnd] |
Maintainer: | Nicolas Frerebeau <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.10.0 |
Built: | 2024-11-08 10:14:53 UTC |
Source: | https://github.com/tesselle/dimensio |
Abundances of Marine Species in Sea-Bed Samples
benthos
benthos
A data.frame
with 13 columns (sites) and 92 rows (species).
http://www.carme-n.org/?sec=data7
Other datasets:
colours
,
countries
Biplot
## S4 method for signature 'CA' biplot( x, ..., axes = c(1, 2), type = c("symetric", "rows", "columns", "contributions"), active = TRUE, sup = TRUE, labels = NULL, col.rows = c("#E69F00", "#009E73"), col.columns = c("#56B4E9", "#F0E442"), cex.rows = graphics::par("cex"), cex.columns = graphics::par("cex"), pch.rows = 16, pch.columns = 17, xlim = NULL, ylim = NULL, main = NULL, sub = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'PCA' biplot( x, ..., axes = c(1, 2), type = c("form", "covariance"), active = TRUE, sup = TRUE, labels = "variables", col.rows = c("#E69F00", "#009E73"), col.columns = c("#56B4E9", "#F0E442"), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, legend = list(x = "topleft") )
## S4 method for signature 'CA' biplot( x, ..., axes = c(1, 2), type = c("symetric", "rows", "columns", "contributions"), active = TRUE, sup = TRUE, labels = NULL, col.rows = c("#E69F00", "#009E73"), col.columns = c("#56B4E9", "#F0E442"), cex.rows = graphics::par("cex"), cex.columns = graphics::par("cex"), pch.rows = 16, pch.columns = 17, xlim = NULL, ylim = NULL, main = NULL, sub = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'PCA' biplot( x, ..., axes = c(1, 2), type = c("form", "covariance"), active = TRUE, sup = TRUE, labels = "variables", col.rows = c("#E69F00", "#009E73"), col.columns = c("#56B4E9", "#F0E442"), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, legend = list(x = "topleft") )
x |
|
... |
Currently not used. |
axes |
A length-two |
type |
A |
active |
A |
sup |
A |
labels |
A |
col.rows |
A length-two |
col.columns |
A length-two |
xlim |
A length-two |
ylim |
A length-two |
main |
A |
sub |
A |
legend |
A |
pch , pch.rows , pch.columns
|
A symbol specification. |
cex , cex.rows , cex.columns
|
A |
A biplot is the simultaneous representation of rows and columns of a rectangular dataset. It is the generalization of a scatterplot to the case of mutlivariate data: it allows to visualize as much information as possible in a single graph (Greenacre 2010).
Biplots have the drawbacks of their advantages: they can quickly become difficult to read as they display a lot of information at once. It may then be preferable to visualize the results for individuals and variables separately.
biplot()
is called for its side-effects: it results in a graphic being
displayed. Invisibly returns x
.
form
(row-metric-preserving)The form biplot favors the representation of the individuals: the distance between the individuals approximates the Euclidean distance between rows. In the form biplot the length of a vector approximates the quality of the representation of the variable.
covariance
(column-metric-preserving)The covariance biplot favors the representation of the variables: the length of a vector approximates the standard deviation of the variable and the cosine of the angle formed by two vectors approximates the correlation between the two variables. In the covariance biplot the distance between the individuals approximates the Mahalanobis distance between rows.
symetric
(symetric biplot)Represents the row and column profiles simultaneously in a common space: rows and columns are in standard coordinates. Note that the the inter-distance between any row and column items is not meaningful.
rows
(asymetric biplot)Row principal biplot (row-metric-preserving) with rows in principal coordinates and columns in standard coordinates.
columns
(asymetric biplot)Column principal biplot (column-metric-preserving) with rows in standard coordinates and columns in principal coordinates.
contribution
(asymetric biplot)Contribution biplot with rows in principal coordinates and columns in standard coordinates multiplied by the square roots of their masses.
N. Frerebeau
Aitchison, J. and Greenacre, M. J. (2002). Biplots of Compositional Data. Journal of the Royal Statistical Society: Series C (Applied Statistics), 51(4): 375-92. doi:10.1111/1467-9876.00275.
Greenacre, M. J. (2010). Biplots in Practice. Bilbao: Fundación BBVA.
Other plot methods:
plot()
,
screeplot()
,
viz_contributions()
,
viz_individuals()
,
viz_variables()
,
viz_wrap
,
wrap
## Replicate examples from Greenacre 2007, p. 59-68 data("countries") ## Compute principal components analysis ## All rows and all columns obtain the same weight row_w <- rep(1 / nrow(countries), nrow(countries)) # 1/13 col_w <- rep(1 / ncol(countries), ncol(countries)) # 1/6 Y <- pca(countries, scale = FALSE, weight_row = row_w, weight_col = col_w) ## Row-metric-preserving biplot (form biplot) biplot(Y, type = "form") ## Column-metric-preserving biplot (covariance biplot) biplot(Y, type = "covariance", legend = list(x = "bottomright")) ## Replicate examples from Greenacre 2007, p. 79-88 data("benthos") ## Compute correspondence analysis X <- ca(benthos) ## Symetric CA biplot biplot(X, labels = "columns", legend = list(x = "bottomright")) ## Row principal CA biplot biplot(X, type = "row", labels = "columns", legend = list(x = "bottomright")) ## Column principal CA biplot biplot(X, type = "column", labels = "columns", legend = list(x = "bottomright")) ## Contribution CA biplot biplot(X, type = "contrib", labels = NULL, legend = list(x = "bottomright"))
## Replicate examples from Greenacre 2007, p. 59-68 data("countries") ## Compute principal components analysis ## All rows and all columns obtain the same weight row_w <- rep(1 / nrow(countries), nrow(countries)) # 1/13 col_w <- rep(1 / ncol(countries), ncol(countries)) # 1/6 Y <- pca(countries, scale = FALSE, weight_row = row_w, weight_col = col_w) ## Row-metric-preserving biplot (form biplot) biplot(Y, type = "form") ## Column-metric-preserving biplot (covariance biplot) biplot(Y, type = "covariance", legend = list(x = "bottomright")) ## Replicate examples from Greenacre 2007, p. 79-88 data("benthos") ## Compute correspondence analysis X <- ca(benthos) ## Symetric CA biplot biplot(X, labels = "columns", legend = list(x = "bottomright")) ## Row principal CA biplot biplot(X, type = "row", labels = "columns", legend = list(x = "bottomright")) ## Column principal CA biplot biplot(X, type = "column", labels = "columns", legend = list(x = "bottomright")) ## Contribution CA biplot biplot(X, type = "contrib", labels = NULL, legend = list(x = "bottomright"))
Checks analysis with partial bootstrap resampling.
## S4 method for signature 'CA' bootstrap(object, n = 30) ## S4 method for signature 'PCA' bootstrap(object, n = 30)
## S4 method for signature 'CA' bootstrap(object, n = 30) ## S4 method for signature 'PCA' bootstrap(object, n = 30)
object |
|
n |
A non-negative |
Returns a BootstrapCA
or a BootstrapPCA
object.
N. Frerebeau
Greenacre, Michael J. Theory and Applications of Correspondence Analysis. London: Academic Press, 1984.
Lebart, L., Piron, M. and Morineau, A. Statistique exploratoire multidimensionnelle: visualisation et inférence en fouille de données. Paris: Dunod, 2006.
Lockyear, K. (2013). Applying Bootstrapped Correspondence Analysis to Archaeological Data. Journal of Archaeological Science, 40(12): 4744-4753. doi:10.1016/j.jas.2012.08.035.
Ringrose, T. J. (1992). Bootstrapping and Correspondence Analysis in Archaeology. Journal of Archaeological Science, 19(6): 615-629. doi:10.1016/0305-4403(92)90032-X.
## Bootstrap on CA ## Data from Lebart et al. 2006, p. 170-172 data("colours") ## Compute correspondence analysis X <- ca(colours) ## Bootstrap (30 replicates) Y <- bootstrap(X, n = 30) ## Not run: ## Get replicated coordinates get_replications(Y, margin = 1) get_replications(Y, margin = 2) ## End(Not run) ## Plot with ellipses viz_rows(Y) viz_tolerance(Y, margin = 1, level = c(0.68, 0.95)) viz_columns(Y) viz_tolerance(Y, margin = 2, level = c(0.68, 0.95)) ## Plot with convex hulls viz_columns(Y) viz_hull(Y, margin = 2) ## Bootstrap on PCA ## Compute principal components analysis data("iris") X <- pca(iris) ## Bootstrap (30 replicates) Y <- bootstrap(X, n = 30) ## Plot with ellipses viz_variables(Y) viz_tolerance(Y, margin = 2, level = c(0.68, 0.95))
## Bootstrap on CA ## Data from Lebart et al. 2006, p. 170-172 data("colours") ## Compute correspondence analysis X <- ca(colours) ## Bootstrap (30 replicates) Y <- bootstrap(X, n = 30) ## Not run: ## Get replicated coordinates get_replications(Y, margin = 1) get_replications(Y, margin = 2) ## End(Not run) ## Plot with ellipses viz_rows(Y) viz_tolerance(Y, margin = 1, level = c(0.68, 0.95)) viz_columns(Y) viz_tolerance(Y, margin = 2, level = c(0.68, 0.95)) ## Plot with convex hulls viz_columns(Y) viz_hull(Y, margin = 2) ## Bootstrap on PCA ## Compute principal components analysis data("iris") X <- pca(iris) ## Bootstrap (30 replicates) Y <- bootstrap(X, n = 30) ## Plot with ellipses viz_variables(Y) viz_tolerance(Y, margin = 2, level = c(0.68, 0.95))
Computes the burt table of a factor table.
burt(object, ...) ## S4 method for signature 'data.frame' burt(object, exclude = NULL, abbrev = TRUE)
burt(object, ...) ## S4 method for signature 'data.frame' burt(object, exclude = NULL, abbrev = TRUE)
object |
A |
... |
Currently not used. |
exclude |
A |
abbrev |
A |
A symetric matrix
.
N. Frerebeau
Other tools:
cdt()
## Create a factor table x <- data.frame( A = c("a", "b", "a"), B = c("x", "y", "z") ) ## Complete disjunctive table cdt(x) ## Burt table burt(x)
## Create a factor table x <- data.frame( A = c("a", "b", "a"), B = c("x", "y", "z") ) ## Complete disjunctive table cdt(x) ## Burt table burt(x)
Computes a simple correspondence analysis based on the singular value decomposition.
ca(object, ...) ## S4 method for signature 'data.frame' ca(object, rank = NULL, sup_row = NULL, sup_col = NULL) ## S4 method for signature 'matrix' ca(object, rank = NULL, sup_row = NULL, sup_col = NULL)
ca(object, ...) ## S4 method for signature 'data.frame' ca(object, rank = NULL, sup_row = NULL, sup_col = NULL) ## S4 method for signature 'matrix' ca(object, rank = NULL, sup_row = NULL, sup_col = NULL)
object |
A |
... |
Currently not used. |
rank |
An |
sup_row |
A |
sup_col |
A |
A CA
object.
N. Frerebeau
Greenacre, M. J. Theory and Applications of Correspondence Analysis. London: Academic Press, 1984.
Greenacre, M. J. Correspondence Analysis in Practice. Seconde edition. Interdisciplinary Statistics Series. Boca Raton: Chapman & Hall/CRC, 2007.
Lebart, L., Piron, M. and Morineau, A. Statistique exploratoire multidimensionnelle: visualisation et inférence en fouille de données. Paris: Dunod, 2006.
Other multivariate analysis:
mca()
,
pca()
,
pcoa()
,
predict()
## Data from Lebart et al. 2006, p. 170-172 data("colours") ## The chi square of independence between the two variables stats::chisq.test(colours) ## Compute correspondence analysis X <- ca(colours) ## Plot rows viz_rows(X, labels = TRUE) ## Plot columns viz_columns(X, labels = TRUE) ## Get row coordinates get_coordinates(X, margin = 1) ## Get column coordinates get_coordinates(X, margin = 2) ## Get total inertia sum(get_inertia(X)) ## Get row contributions get_contributions(X, margin = 1)
## Data from Lebart et al. 2006, p. 170-172 data("colours") ## The chi square of independence between the two variables stats::chisq.test(colours) ## Compute correspondence analysis X <- ca(colours) ## Plot rows viz_rows(X, labels = TRUE) ## Plot columns viz_columns(X, labels = TRUE) ## Get row coordinates get_coordinates(X, margin = 1) ## Get column coordinates get_coordinates(X, margin = 2) ## Get total inertia sum(get_inertia(X)) ## Get row contributions get_contributions(X, margin = 1)
Computes the complete disjunctive table of a factor table.
cdt(object, ...) ## S4 method for signature 'matrix' cdt(object, exclude = NULL, abbrev = TRUE) ## S4 method for signature 'data.frame' cdt(object, exclude = NULL, abbrev = TRUE)
cdt(object, ...) ## S4 method for signature 'matrix' cdt(object, exclude = NULL, abbrev = TRUE) ## S4 method for signature 'data.frame' cdt(object, exclude = NULL, abbrev = TRUE)
object |
A |
... |
Currently not used. |
exclude |
A |
abbrev |
A |
A data.frame
.
N. Frerebeau
Other tools:
burt()
## Create a factor table x <- data.frame( A = c("a", "b", "a"), B = c("x", "y", "z") ) ## Complete disjunctive table cdt(x) ## Burt table burt(x)
## Create a factor table x <- data.frame( A = c("a", "b", "a"), B = c("x", "y", "z") ) ## Complete disjunctive table cdt(x) ## Burt table burt(x)
Contingency table of eye and hair colours of different individuals.
colours
colours
A data.frame
with 4 columns (hair colours) and 4 rows (eye
colours).
Lebart, L., Piron, M. and Morineau, A. Statistique exploratoire multidimensionnelle: visualisation et inférence en fouille de données. Paris: Dunod, 2006, p. 170-172
Other datasets:
benthos
,
countries
Student ratings of 13 countries on six attributes.
countries
countries
A data.frame
with 6 columns (attributes) and 13 rows (countries).
Greenacre, M. J. Biplots in Practice. Bilbao: Fundación BBVA, 2010.
Other datasets:
benthos
,
colours
Retrieve or set the dimnames of an object.
## S4 method for signature 'MultivariateAnalysis' dim(x) ## S4 method for signature 'MultivariateAnalysis' rownames(x, do.NULL = TRUE, prefix = "row") ## S4 method for signature 'MultivariateAnalysis' colnames(x, do.NULL = TRUE, prefix = "col") ## S4 method for signature 'MultivariateAnalysis' dimnames(x)
## S4 method for signature 'MultivariateAnalysis' dim(x) ## S4 method for signature 'MultivariateAnalysis' rownames(x, do.NULL = TRUE, prefix = "row") ## S4 method for signature 'MultivariateAnalysis' colnames(x, do.NULL = TRUE, prefix = "col") ## S4 method for signature 'MultivariateAnalysis' dimnames(x)
x |
An object from which to retrieve the row or column names
(a |
do.NULL |
A |
prefix |
A |
N. Frerebeau
Other mutators:
loadings()
,
subset()
Creates a Zip archive of all results in CSV format.
export(object, ...) ## S4 method for signature 'MultivariateAnalysis' export(object, file, flags = "-r9Xj", ...)
export(object, ...) ## S4 method for signature 'MultivariateAnalysis' export(object, file, flags = "-r9Xj", ...)
object |
|
... |
Currently not used. |
file |
A |
flags |
A |
N. Frerebeau
utils::write.csv()
, utils::zip()
Other getters:
get_contributions()
,
get_coordinates()
,
get_data()
,
get_eigenvalues()
## Not run: ## Load data data("iris") ## Compute principal components analysis X <- pca(iris) ## Export results export(X, file = "results.zip") ## End(Not run)
## Not run: ## Load data data("iris") ## Compute principal components analysis X <- pca(iris) ## Export results export(X, file = "results.zip") ## End(Not run)
Get Contributions
get_contributions(x, ...) get_correlations(x, ...) get_cos2(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_contributions(x, margin = 1) ## S4 method for signature 'PCA' get_correlations(x, sup_name = ".sup") ## S4 method for signature 'MultivariateAnalysis' get_cos2(x, margin = 1, sup_name = ".sup")
get_contributions(x, ...) get_correlations(x, ...) get_cos2(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_contributions(x, margin = 1) ## S4 method for signature 'PCA' get_correlations(x, sup_name = ".sup") ## S4 method for signature 'MultivariateAnalysis' get_cos2(x, margin = 1, sup_name = ".sup")
x |
An object from which to get element(s) (a |
... |
Currently not used. |
margin |
A length-one |
sup_name |
A |
get_contributions()
returns a data.frame
of contributions to the
definition of the principal dimensions.
get_correlations()
returns a data.frame
of correlations between
variables and dimensions. An extra column (named after sup_name
)
is added specifying whether an observation is a supplementary point or
not.
get_cos2()
returns a data.frame
of values (i.e.
quality of the representation of the points on the factor map). An extra
column (named after
sup_name
) is added specifying whether an observation
is a supplementary point or not.
N. Frerebeau
Other getters:
export()
,
get_coordinates()
,
get_data()
,
get_eigenvalues()
Get Coordinates
get_coordinates(x, ...) get_replications(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_coordinates(x, margin = 1, principal = TRUE, sup_name = ".sup") ## S4 method for signature 'PCOA' get_coordinates(x) ## S4 method for signature 'MultivariateBootstrap' get_replications(x, margin = 1) ## S4 method for signature 'BootstrapPCA' get_replications(x)
get_coordinates(x, ...) get_replications(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_coordinates(x, margin = 1, principal = TRUE, sup_name = ".sup") ## S4 method for signature 'PCOA' get_coordinates(x) ## S4 method for signature 'MultivariateBootstrap' get_replications(x, margin = 1) ## S4 method for signature 'BootstrapPCA' get_replications(x)
x |
An object from which to get element(s) (a |
... |
Currently not used. |
margin |
A length-one |
principal |
A |
sup_name |
A |
get_coordinates()
returns a data.frame
of coordinates. An extra
column (named after sup_name
) is added specifying whether an observation
is a supplementary point or not.
get_replications()
returns an array
of coordinates.
N. Frerebeau
Other getters:
export()
,
get_contributions()
,
get_data()
,
get_eigenvalues()
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_row = 5:10) ## Get row principal coordinates head(get_coordinates(X, margin = 1, principal = TRUE)) ## Get row standard coordinates head(get_coordinates(X, margin = 1, principal = FALSE)) ## Tidy principal coordinates head(tidy(X, margin = 1)) head(tidy(X, margin = 2)) head(augment(X, margin = 1, axes = c(1, 2))) head(augment(X, margin = 2, axes = c(1, 2)))
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_row = 5:10) ## Get row principal coordinates head(get_coordinates(X, margin = 1, principal = TRUE)) ## Get row standard coordinates head(get_coordinates(X, margin = 1, principal = FALSE)) ## Tidy principal coordinates head(tidy(X, margin = 1)) head(tidy(X, margin = 2)) head(augment(X, margin = 1, axes = c(1, 2))) head(augment(X, margin = 2, axes = c(1, 2)))
Get Original Data
get_data(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_data(x)
get_data(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_data(x)
x |
An object from which to get element(s) (a |
... |
Currently not used. |
Returns a data.frame
of original data.
N. Frerebeau
Other getters:
export()
,
get_contributions()
,
get_coordinates()
,
get_eigenvalues()
Get Eigenvalues
get_eigenvalues(x) get_variance(x, ...) get_distances(x, ...) get_inertia(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_distances(x, margin = 1) ## S4 method for signature 'MultivariateAnalysis' get_eigenvalues(x) ## S4 method for signature 'PCOA' get_eigenvalues(x) ## S4 method for signature 'MultivariateAnalysis' get_inertia(x, margin = 1) ## S4 method for signature 'MultivariateAnalysis' get_variance(x, digits = 2)
get_eigenvalues(x) get_variance(x, ...) get_distances(x, ...) get_inertia(x, ...) ## S4 method for signature 'MultivariateAnalysis' get_distances(x, margin = 1) ## S4 method for signature 'MultivariateAnalysis' get_eigenvalues(x) ## S4 method for signature 'PCOA' get_eigenvalues(x) ## S4 method for signature 'MultivariateAnalysis' get_inertia(x, margin = 1) ## S4 method for signature 'MultivariateAnalysis' get_variance(x, digits = 2)
x |
An object from which to get element(s) (a |
... |
Currently not used. |
margin |
A length-one |
digits |
An |
get_eigenvalues()
returns a data.frame
with the following columns:
eigenvalues
, variance
(percentage of variance) and cumulative
(cumulative percentage of variance).
get_variance()
returns a numeric
vector giving the amount of
variance explained by each (principal) component.
get_distance()
returns a numeric
vector of squared distance to the
centroid.
get_inertia()
returns a numeric
vector giving the inertia (weighted
squared distance to the centroid).
N. Frerebeau
Other getters:
export()
,
get_contributions()
,
get_coordinates()
,
get_data()
Extract loadingsin principal components analysis.
## S4 method for signature 'PCA' loadings(x, ...)
## S4 method for signature 'PCA' loadings(x, ...)
x |
A |
... |
Currently not used. |
Returns variable loadings (i.e. the coefficients of the linear combination of the original variables).
loadings()
is only implemented for consistency with stats::loadings()
.
N. Frerebeau
Other mutators:
dimnames()
,
subset()
Computes a multiple correspondence analysis.
mca(object, ...) ## S4 method for signature 'data.frame' mca(object, rank = NULL, sup_row = NULL, sup_col = NULL, sup_quanti = NULL) ## S4 method for signature 'matrix' mca(object, rank = NULL, sup_row = NULL, sup_col = NULL)
mca(object, ...) ## S4 method for signature 'data.frame' mca(object, rank = NULL, sup_row = NULL, sup_col = NULL, sup_quanti = NULL) ## S4 method for signature 'matrix' mca(object, rank = NULL, sup_row = NULL, sup_col = NULL)
object |
A |
... |
Currently not used. |
rank |
An |
sup_row |
A |
sup_col |
A |
sup_quanti |
A |
A MCA
object.
N. Frerebeau
Lebart, L., Piron, M. and Morineau, A. Statistique exploratoire multidimensionnelle: visualisation et inférence en fouille de données. Paris: Dunod, 2006.
Other multivariate analysis:
ca()
,
pca()
,
pcoa()
,
predict()
Computes a principal components analysis based on the singular value decomposition.
pca(object, ...) ## S4 method for signature 'data.frame' pca( object, center = TRUE, scale = TRUE, rank = NULL, sup_row = NULL, sup_col = NULL, sup_quali = NULL, weight_row = NULL, weight_col = NULL ) ## S4 method for signature 'matrix' pca( object, center = TRUE, scale = TRUE, rank = NULL, sup_row = NULL, sup_col = NULL, weight_row = NULL, weight_col = NULL )
pca(object, ...) ## S4 method for signature 'data.frame' pca( object, center = TRUE, scale = TRUE, rank = NULL, sup_row = NULL, sup_col = NULL, sup_quali = NULL, weight_row = NULL, weight_col = NULL ) ## S4 method for signature 'matrix' pca( object, center = TRUE, scale = TRUE, rank = NULL, sup_row = NULL, sup_col = NULL, weight_row = NULL, weight_col = NULL )
object |
A |
... |
Currently not used. |
center |
A |
scale |
A |
rank |
An |
sup_row |
A |
sup_col |
A |
sup_quali |
A |
weight_row |
A |
weight_col |
A |
A PCA
object.
N. Frerebeau
Lebart, L., Piron, M. and Morineau, A. Statistique exploratoire multidimensionnelle: visualisation et inférence en fouille de données. Paris: Dunod, 2006.
Other multivariate analysis:
ca()
,
mca()
,
pcoa()
,
predict()
## Load data data("iris") ## Compute principal components analysis X <- pca(iris) ## Get eigenvalues get_eigenvalues(X) ## Get individual cos2 head(get_cos2(X, margin = 1)) ## Get variable contributions get_contributions(X, margin = 2) ## Get correlations between variables and dimensions get_correlations(X)
## Load data data("iris") ## Compute principal components analysis X <- pca(iris) ## Get eigenvalues get_eigenvalues(X) ## Get individual cos2 head(get_cos2(X, margin = 1)) ## Get variable contributions get_contributions(X, margin = 2) ## Get correlations between variables and dimensions get_correlations(X)
Computes classical (metric) multidimensional scaling.
pcoa(object, ...) ## S4 method for signature 'dist' pcoa(object, rank = 2)
pcoa(object, ...) ## S4 method for signature 'dist' pcoa(object, rank = 2)
object |
|
... |
Currently not used. |
rank |
An |
A PCOA
object.
N. Frerebeau
Gower, J. C. (1966). Some Distance Properties of Latent Root and Vector Methods Used in Multivariate Analysis. Biometrika, 53(3‑4): 325-338. doi:10.1093/biomet/53.3-4.325.
Other multivariate analysis:
ca()
,
mca()
,
pca()
,
predict()
## Load data data("iris") ## Compute euclidean distances d <- dist(iris[, 1:4], method = "euclidean") ## Compute principal coordinates analysis X <- pcoa(d) ## Screeplot screeplot(X) ## Plot results plot(X, extra_quali = iris$Species)
## Load data data("iris") ## Compute euclidean distances d <- dist(iris[, 1:4], method = "euclidean") ## Compute principal coordinates analysis X <- pcoa(d) ## Screeplot screeplot(X) ## Plot results plot(X, extra_quali = iris$Species)
Plot Coordinates
## S4 method for signature 'PCOA,missing' plot( x, ..., axes = c(1, 2), labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, ann = graphics::par("ann"), frame.plot = TRUE, panel.first = NULL, panel.last = NULL )
## S4 method for signature 'PCOA,missing' plot( x, ..., axes = c(1, 2), labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, ann = graphics::par("ann"), frame.plot = TRUE, panel.first = NULL, panel.last = NULL )
x |
An R object. |
... |
Further graphical parameters. |
axes |
A length-two |
labels |
A |
extra_quali |
An optional vector of qualitative data for aesthetics mapping. |
extra_quanti |
An optional vector of quantitative data for aesthetics
mapping. If a single |
color |
The colors for lines and points (will be mapped to
|
fill |
The background colors for points (will be mapped to
|
symbol |
A vector of plotting characters or symbols (will be mapped to
|
size |
A length-two |
xlim |
A length-two |
ylim |
A length-two |
main |
A |
sub |
A |
ann |
A |
frame.plot |
A |
panel.first |
An |
panel.last |
An |
N. Frerebeau
Other plot methods:
biplot()
,
screeplot()
,
viz_contributions()
,
viz_individuals()
,
viz_variables()
,
viz_wrap
,
wrap
Predict the projection of new individuals/rows or variables/columns.
## S4 method for signature 'CA' predict(object, newdata, margin = 1) ## S4 method for signature 'MCA' predict(object, newdata, margin = 1) ## S4 method for signature 'PCA' predict(object, newdata, margin = 1)
## S4 method for signature 'CA' predict(object, newdata, margin = 1) ## S4 method for signature 'MCA' predict(object, newdata, margin = 1) ## S4 method for signature 'PCA' predict(object, newdata, margin = 1)
object |
|
newdata |
An object of supplementary points coercible to a
|
margin |
A length-one |
A data.frame
of coordinates.
N. Frerebeau
Other multivariate analysis:
ca()
,
mca()
,
pca()
,
pcoa()
## Create a matrix A <- matrix(data = sample(1:10, 100, TRUE), nrow = 10, ncol = 10) ## Compute correspondence analysis X <- ca(A, sup_row = 8:10, sup_col = 7:10) ## Predict new row coordinates Y <- matrix(data = sample(1:10, 120, TRUE), nrow = 20, ncol = 6) predict(X, Y, margin = 1) ## Predict new column coordinates Z <- matrix(data = sample(1:10, 140, TRUE), nrow = 7, ncol = 20) predict(X, Z, margin = 2)
## Create a matrix A <- matrix(data = sample(1:10, 100, TRUE), nrow = 10, ncol = 10) ## Compute correspondence analysis X <- ca(A, sup_row = 8:10, sup_col = 7:10) ## Predict new row coordinates Y <- matrix(data = sample(1:10, 120, TRUE), nrow = 20, ncol = 6) predict(X, Y, margin = 1) ## Predict new column coordinates Z <- matrix(data = sample(1:10, 140, TRUE), nrow = 7, ncol = 20) predict(X, Z, margin = 2)
Plot eigenvalues (scree plot) or variances histogram.
## S4 method for signature 'MultivariateAnalysis' screeplot( x, ..., eigenvalues = FALSE, cumulative = FALSE, labels = TRUE, limit = 10, col = "grey90", border = "grey10", col.cumulative = "red", lty.cumulative = "solid", lwd.cumulative = 2 ) ## S4 method for signature 'PCOA' screeplot( x, ..., labels = FALSE, limit = NULL, col = "grey90", border = "grey10" )
## S4 method for signature 'MultivariateAnalysis' screeplot( x, ..., eigenvalues = FALSE, cumulative = FALSE, labels = TRUE, limit = 10, col = "grey90", border = "grey10", col.cumulative = "red", lty.cumulative = "solid", lwd.cumulative = 2 ) ## S4 method for signature 'PCOA' screeplot( x, ..., labels = FALSE, limit = NULL, col = "grey90", border = "grey10" )
x |
|
... |
Extra parameters to be passed to |
eigenvalues |
A |
cumulative |
A |
labels |
A |
limit |
An |
col , border
|
A |
col.cumulative |
A specification for the line color. |
lty.cumulative |
A specification for the line type. |
lwd.cumulative |
A specification for the line width. |
screeplot()
is called for its side-effects: it results in a graphic
being displayed. Invisibly returns x
.
N. Frerebeau
Other plot methods:
biplot()
,
plot()
,
viz_contributions()
,
viz_individuals()
,
viz_variables()
,
viz_wrap
,
wrap
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Screeplot screeplot(X) screeplot(X, cumulative = TRUE)
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Screeplot screeplot(X) screeplot(X, cumulative = TRUE)
Operators acting on objects to extract parts.
## S4 method for signature 'CA,ANY,missing' x[[i]] ## S4 method for signature 'PCA,ANY,missing' x[[i]]
## S4 method for signature 'CA,ANY,missing' x[[i]] ## S4 method for signature 'PCA,ANY,missing' x[[i]]
x |
An object from which to extract element(s) or in which to replace element(s). |
i |
A |
If i
is "data
", returns a list with the following elements:
data
A numeric
matrix of raw data.
mean
A numeric
vector giving the variables means (PCA
).
sd
A numeric
vector giving the variables standard deviations
(PCA
).
If i
is "rows
", returns a list with the following elements:
coord
A numeric
matrix of rows/individuals coordinates.
cos2
A numeric
matrix of rows/individuals squared cosine.
masses
A numeric
vector giving the rows masses/individual
weights.
sup
A logical
vector specifying whether a point is a
supplementary observation or not.
If i
is "columns
", returns a list with the following elements:
coord
A numeric
matrix of columns/variables coordinates.
cor
A numeric
matrix of correlation between variables and
the dimensions (PCA
).
cos2
A numeric
matrix of columns/variables squared cosine.
masses
A numeric
vector giving the columns masses/variable
weights.
sup
A logical
vector specifying whether a point is a
supplementary observation or not.
If i
is "eigenvalues
", returns a numeric
vector of eigenvalues.
A list
.
N. Frerebeau
Other mutators:
dimnames()
,
loadings()
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_row = 8:10, sup_col = 1) ## Get results for the individuals X[["rows"]]
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_row = 8:10, sup_col = 1) ## Get results for the individuals X[["rows"]]
Provides a summary of the results of a multivariate data analysis.
## S4 method for signature 'CA' summary(object, ..., margin = 1, active = TRUE, sup = TRUE, rank = 3) ## S4 method for signature 'PCA' summary(object, ..., margin = 1, active = TRUE, sup = TRUE, rank = 3)
## S4 method for signature 'CA' summary(object, ..., margin = 1, active = TRUE, sup = TRUE, rank = 3) ## S4 method for signature 'PCA' summary(object, ..., margin = 1, active = TRUE, sup = TRUE, rank = 3)
object |
|
... |
Currently not used. |
margin |
A length-one |
active |
A |
sup |
A |
rank |
An |
N. Frerebeau
Other summary:
tidy()
## Data from Lebart et al. 2006, p. 170-172 data("colours") ## Compute correspondence analysis X <- ca(colours) ## Rows summary summary(X, margin = 1) ## Columns summary summary(X, margin = 2)
## Data from Lebart et al. 2006, p. 170-172 data("colours") ## Compute correspondence analysis X <- ca(colours) ## Rows summary summary(X, margin = 1) ## Columns summary summary(X, margin = 2)
Tidy Coordinates
tidy(x, ...) augment(x, ...) ## S4 method for signature 'MultivariateAnalysis' augment(x, ..., margin = 1, axes = c(1, 2), principal = TRUE) ## S4 method for signature 'MultivariateAnalysis' tidy(x, ..., margin = 1, principal = TRUE)
tidy(x, ...) augment(x, ...) ## S4 method for signature 'MultivariateAnalysis' augment(x, ..., margin = 1, axes = c(1, 2), principal = TRUE) ## S4 method for signature 'MultivariateAnalysis' tidy(x, ..., margin = 1, principal = TRUE)
x |
|
... |
Currently not used. |
margin |
A length-one |
axes |
A length-two |
principal |
A |
tidy()
returns a long data.frame
with the following columns:
label
Row/column names of the original data.
component
Component.
supplementary
Whether an observation is active or supplementary.
coordinate
Coordinates.
contribution
Contributions to the definition of the components.
cos2
.
augment()
returns a wide data.frame
of the row/column coordinates
along axes
and the following columns:
label
Row/column names of the original data.
supplementary
Whether an observation is active or supplementary.
mass
Weight/mass of each observation.
sum
Sum of squared coordinates along axes
.
contribution
Joint contributions to the definition of axes
.
cos2
Joint along
axes
.
N. Frerebeau
Other summary:
summary()
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_row = 5:10) ## Get row principal coordinates head(get_coordinates(X, margin = 1, principal = TRUE)) ## Get row standard coordinates head(get_coordinates(X, margin = 1, principal = FALSE)) ## Tidy principal coordinates head(tidy(X, margin = 1)) head(tidy(X, margin = 2)) head(augment(X, margin = 1, axes = c(1, 2))) head(augment(X, margin = 2, axes = c(1, 2)))
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_row = 5:10) ## Get row principal coordinates head(get_coordinates(X, margin = 1, principal = TRUE)) ## Get row standard coordinates head(get_coordinates(X, margin = 1, principal = FALSE)) ## Tidy principal coordinates head(tidy(X, margin = 1)) head(tidy(X, margin = 2)) head(augment(X, margin = 1, axes = c(1, 2))) head(augment(X, margin = 2, axes = c(1, 2)))
Plots contributions histogram and scatterplot.
viz_contributions(x, ...) viz_cos2(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_contributions( x, ..., margin = 2, axes = 1, sort = TRUE, decreasing = TRUE, limit = 10, horiz = FALSE, col = "grey90", border = "grey10" ) ## S4 method for signature 'MultivariateAnalysis' viz_cos2( x, ..., margin = 2, axes = c(1, 2), active = TRUE, sup = TRUE, sort = TRUE, decreasing = TRUE, limit = 10, horiz = FALSE, col = "grey90", border = "grey10" )
viz_contributions(x, ...) viz_cos2(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_contributions( x, ..., margin = 2, axes = 1, sort = TRUE, decreasing = TRUE, limit = 10, horiz = FALSE, col = "grey90", border = "grey10" ) ## S4 method for signature 'MultivariateAnalysis' viz_cos2( x, ..., margin = 2, axes = c(1, 2), active = TRUE, sup = TRUE, sort = TRUE, decreasing = TRUE, limit = 10, horiz = FALSE, col = "grey90", border = "grey10" )
x |
|
... |
Extra parameters to be passed to |
margin |
A length-one |
axes |
A |
sort |
A |
decreasing |
A |
limit |
An |
horiz |
A |
col , border
|
A |
active |
A |
sup |
A |
The red dashed line indicates the expected average contribution (variables with a contribution larger than this cutoff can be considered as important in contributing to the component).
viz_contributions()
and viz_cos2()
are called for their side-effects:
they result in a graphic being displayed. Invisibly return x
.
N. Frerebeau
Other plot methods:
biplot()
,
plot()
,
screeplot()
,
viz_individuals()
,
viz_variables()
,
viz_wrap
,
wrap
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Get row contributions head(get_contributions(X, margin = 1)) ## Plot contributions viz_contributions(X, axes = 1) ## Plot cos2 viz_cos2(X)
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Get row contributions head(get_contributions(X, margin = 1)) ## Plot contributions viz_contributions(X, axes = 1) ## Plot cos2 viz_cos2(X)
Plots row/individual principal coordinates.
viz_individuals(x, ...) viz_rows(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_rows( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'BootstrapCA' viz_rows(x, ..., axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE) ## S4 method for signature 'PCA' viz_individuals( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") )
viz_individuals(x, ...) viz_rows(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_rows( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'BootstrapCA' viz_rows(x, ..., axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE) ## S4 method for signature 'PCA' viz_individuals( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") )
x |
|
... |
Further graphical parameters. |
axes |
A length-two |
active |
A |
sup |
A |
labels |
A |
extra_quali |
An optional vector of qualitative data for aesthetics mapping. |
extra_quanti |
An optional vector of quantitative data for aesthetics
mapping. If a single |
color |
The colors for lines and points (will be mapped to
|
fill |
The background colors for points (will be mapped to
|
symbol |
A vector of plotting characters or symbols (will be mapped to
|
size |
A length-two |
xlim |
A length-two |
ylim |
A length-two |
main |
A |
sub |
A |
panel.first |
An |
panel.last |
An |
legend |
A |
viz_*()
is called for its side-effects: it results in a graphic
being displayed. Invisibly returns x
.
N. Frerebeau
Other plot methods:
biplot()
,
plot()
,
screeplot()
,
viz_contributions()
,
viz_variables()
,
viz_wrap
,
wrap
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Plot individuals viz_individuals(X, panel.last = graphics::grid()) ## Labels of the 10 individuals with highest cos2 viz_individuals(X, labels = list(how = "cos2", n = 10)) ## Plot variables viz_variables(X, panel.last = graphics::grid()) ## Graphical parameters ## Continuous values viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2)) viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2), color = grDevices::hcl.colors(12, "RdPu")) viz_variables(X, extra_quanti = "contribution", color = grDevices::hcl.colors(12, "BluGrn", rev = TRUE), size = c(0, 1)) ## Discrete values viz_individuals(X, extra_quali = iris$Species, symbol = 21:23) viz_individuals(X, extra_quali = iris$Species, symbol = 21:23, fill = c("#004488", "#DDAA33", "#BB5566"), color = "black") viz_variables(X, extra_quali = c("Petal", "Petal", "Sepal", "Sepal"), color = c("#EE7733", "#0077BB"), symbol = c(1, 3))
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Plot individuals viz_individuals(X, panel.last = graphics::grid()) ## Labels of the 10 individuals with highest cos2 viz_individuals(X, labels = list(how = "cos2", n = 10)) ## Plot variables viz_variables(X, panel.last = graphics::grid()) ## Graphical parameters ## Continuous values viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2)) viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2), color = grDevices::hcl.colors(12, "RdPu")) viz_variables(X, extra_quanti = "contribution", color = grDevices::hcl.colors(12, "BluGrn", rev = TRUE), size = c(0, 1)) ## Discrete values viz_individuals(X, extra_quali = iris$Species, symbol = 21:23) viz_individuals(X, extra_quali = iris$Species, symbol = 21:23, fill = c("#004488", "#DDAA33", "#BB5566"), color = "black") viz_variables(X, extra_quali = c("Petal", "Petal", "Sepal", "Sepal"), color = c("#EE7733", "#0077BB"), symbol = c(1, 3))
Plots column/variable principal coordinates.
viz_variables(x, ...) viz_columns(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_columns( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'MultivariateBootstrap' viz_columns( x, ..., axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'PCA' viz_variables( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = list(filter = "contribution", n = 10), extra_quali = NULL, extra_quanti = NULL, color = NULL, symbol = NULL, size = 1, xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'CA' viz_variables( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'BootstrapPCA' viz_variables( x, ..., axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE )
viz_variables(x, ...) viz_columns(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_columns( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'MultivariateBootstrap' viz_columns( x, ..., axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'PCA' viz_variables( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = list(filter = "contribution", n = 10), extra_quali = NULL, extra_quanti = NULL, color = NULL, symbol = NULL, size = 1, xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'CA' viz_variables( x, ..., axes = c(1, 2), active = TRUE, sup = TRUE, labels = FALSE, extra_quali = NULL, extra_quanti = NULL, color = NULL, fill = FALSE, symbol = FALSE, size = c(1, 6), xlim = NULL, ylim = NULL, main = NULL, sub = NULL, panel.first = NULL, panel.last = NULL, legend = list(x = "topleft") ) ## S4 method for signature 'BootstrapPCA' viz_variables( x, ..., axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE )
x |
|
... |
Further graphical parameters. |
axes |
A length-two |
active |
A |
sup |
A |
labels |
A |
extra_quali |
An optional vector of qualitative data for aesthetics mapping. |
extra_quanti |
An optional vector of quantitative data for aesthetics
mapping. If a single |
color |
The colors for lines and points (will be mapped to
|
fill |
The background colors for points (will be mapped to
|
symbol |
A vector of plotting characters or symbols (will be mapped to
|
size |
A length-two |
xlim |
A length-two |
ylim |
A length-two |
main |
A |
sub |
A |
panel.first |
An |
panel.last |
An |
legend |
A |
viz_*()
is called for its side-effects: it results in a graphic
being displayed. Invisibly returns x
.
N. Frerebeau
Other plot methods:
biplot()
,
plot()
,
screeplot()
,
viz_contributions()
,
viz_individuals()
,
viz_wrap
,
wrap
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Plot individuals viz_individuals(X, panel.last = graphics::grid()) ## Labels of the 10 individuals with highest cos2 viz_individuals(X, labels = list(how = "cos2", n = 10)) ## Plot variables viz_variables(X, panel.last = graphics::grid()) ## Graphical parameters ## Continuous values viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2)) viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2), color = grDevices::hcl.colors(12, "RdPu")) viz_variables(X, extra_quanti = "contribution", color = grDevices::hcl.colors(12, "BluGrn", rev = TRUE), size = c(0, 1)) ## Discrete values viz_individuals(X, extra_quali = iris$Species, symbol = 21:23) viz_individuals(X, extra_quali = iris$Species, symbol = 21:23, fill = c("#004488", "#DDAA33", "#BB5566"), color = "black") viz_variables(X, extra_quali = c("Petal", "Petal", "Sepal", "Sepal"), color = c("#EE7733", "#0077BB"), symbol = c(1, 3))
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) ## Plot individuals viz_individuals(X, panel.last = graphics::grid()) ## Labels of the 10 individuals with highest cos2 viz_individuals(X, labels = list(how = "cos2", n = 10)) ## Plot variables viz_variables(X, panel.last = graphics::grid()) ## Graphical parameters ## Continuous values viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2)) viz_individuals(X, extra_quanti = iris$Petal.Length, symbol = 16, size = c(1, 2), color = grDevices::hcl.colors(12, "RdPu")) viz_variables(X, extra_quanti = "contribution", color = grDevices::hcl.colors(12, "BluGrn", rev = TRUE), size = c(0, 1)) ## Discrete values viz_individuals(X, extra_quali = iris$Species, symbol = 21:23) viz_individuals(X, extra_quali = iris$Species, symbol = 21:23, fill = c("#004488", "#DDAA33", "#BB5566"), color = "black") viz_variables(X, extra_quali = c("Petal", "Petal", "Sepal", "Sepal"), color = c("#EE7733", "#0077BB"), symbol = c(1, 3))
Plot Envelopes
viz_hull(x, ...) viz_confidence(x, ...) viz_tolerance(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_tolerance( x, ..., margin = 1, axes = c(1, 2), group = NULL, level = 0.95, color = NULL, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'BootstrapCA' viz_tolerance( x, ..., margin = 1, axes = c(1, 2), level = 0.95, color = FALSE, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'MultivariateAnalysis' viz_confidence( x, ..., margin = 1, axes = c(1, 2), group = NULL, level = 0.95, color = NULL, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'BootstrapCA' viz_confidence( x, ..., margin = 1, axes = c(1, 2), level = 0.95, color = FALSE, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'MultivariateAnalysis' viz_hull( x, ..., margin = 1, axes = c(1, 2), group = NULL, color = NULL, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'BootstrapCA' viz_hull( x, ..., margin = 1, axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE )
viz_hull(x, ...) viz_confidence(x, ...) viz_tolerance(x, ...) ## S4 method for signature 'MultivariateAnalysis' viz_tolerance( x, ..., margin = 1, axes = c(1, 2), group = NULL, level = 0.95, color = NULL, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'BootstrapCA' viz_tolerance( x, ..., margin = 1, axes = c(1, 2), level = 0.95, color = FALSE, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'MultivariateAnalysis' viz_confidence( x, ..., margin = 1, axes = c(1, 2), group = NULL, level = 0.95, color = NULL, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'BootstrapCA' viz_confidence( x, ..., margin = 1, axes = c(1, 2), level = 0.95, color = FALSE, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'MultivariateAnalysis' viz_hull( x, ..., margin = 1, axes = c(1, 2), group = NULL, color = NULL, fill = FALSE, symbol = FALSE ) ## S4 method for signature 'BootstrapCA' viz_hull( x, ..., margin = 1, axes = c(1, 2), color = FALSE, fill = FALSE, symbol = FALSE )
x |
An object from which to wrap observations (a |
... |
Further graphical parameters to be passed to
|
margin |
A length-one |
axes |
A length-two |
group |
A vector specifying the group an observation belongs to. |
level |
A |
color |
The colors for borders (will be mapped to |
fill |
The background colors (will be mapped to |
symbol |
A vector of symbols (will be mapped to |
viz_*()
is called for its side-effects: it results in a graphic being
displayed. Invisibly returns x
.
N. Frerebeau
Other plot methods:
biplot()
,
plot()
,
screeplot()
,
viz_contributions()
,
viz_individuals()
,
viz_variables()
,
wrap
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_quali = "Species") ## Plot with convex hulls col <- c("#004488", "#DDAA33", "#BB5566") viz_rows(X, extra_quali = iris$Species, color = col) viz_hull(X, group = iris$Species, color = col) ## Plot with tolerance ellipses col <- c("#004488", "#DDAA33", "#BB5566") viz_rows(X, extra_quali = iris$Species, color = col) viz_tolerance(X, group = iris$Species, color = col)
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_quali = "Species") ## Plot with convex hulls col <- c("#004488", "#DDAA33", "#BB5566") viz_rows(X, extra_quali = iris$Species, color = col) viz_hull(X, group = iris$Species, color = col) ## Plot with tolerance ellipses col <- c("#004488", "#DDAA33", "#BB5566") viz_rows(X, extra_quali = iris$Species, color = col) viz_tolerance(X, group = iris$Species, color = col)
wrap_hull()
computes convex hull of a set of observations.
wrap_confidence()
computes a confidence ellipse.
wrap_tolerance()
computes a tolerance ellipse.
wrap_hull(x, ...) wrap_confidence(x, ...) wrap_tolerance(x, ...) ## S4 method for signature 'MultivariateAnalysis' wrap_confidence(x, margin = 1, axes = c(1, 2), group = NULL, level = 0.95) ## S4 method for signature 'MultivariateAnalysis' wrap_tolerance(x, margin = 1, axes = c(1, 2), group = NULL, level = 0.95) ## S4 method for signature 'MultivariateAnalysis' wrap_hull(x, margin = 1, axes = c(1, 2), group = NULL)
wrap_hull(x, ...) wrap_confidence(x, ...) wrap_tolerance(x, ...) ## S4 method for signature 'MultivariateAnalysis' wrap_confidence(x, margin = 1, axes = c(1, 2), group = NULL, level = 0.95) ## S4 method for signature 'MultivariateAnalysis' wrap_tolerance(x, margin = 1, axes = c(1, 2), group = NULL, level = 0.95) ## S4 method for signature 'MultivariateAnalysis' wrap_hull(x, margin = 1, axes = c(1, 2), group = NULL)
x |
An object from which to wrap observations (a |
... |
Currently not used. |
margin |
A length-one |
axes |
A length-two |
group |
A vector specifying the group an observation belongs to. |
level |
A |
wrap_*()
returns a data.frame
of envelope x
and y
coordinates.
An extra column named group
is added specifying the group an observation
belongs to.
N. Frerebeau
Other plot methods:
biplot()
,
plot()
,
screeplot()
,
viz_contributions()
,
viz_individuals()
,
viz_variables()
,
viz_wrap
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_quali = "Species") ## Confidence ellipse coordinates conf <- wrap_confidence(X, margin = 1, group = "Species", level = c(0.68, 0.95)) ## Tolerance ellipse coordinates conf <- wrap_confidence(X, margin = 1, group = "Species", level = 0.95) ## Convex hull coordinates hulls <- wrap_hull(X, margin = 1, group = "Species")
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE, sup_quali = "Species") ## Confidence ellipse coordinates conf <- wrap_confidence(X, margin = 1, group = "Species", level = c(0.68, 0.95)) ## Tolerance ellipse coordinates conf <- wrap_confidence(X, margin = 1, group = "Species", level = 0.95) ## Convex hull coordinates hulls <- wrap_hull(X, margin = 1, group = "Species")