| Title: | Multivariate Exploratory Data Analysis |
|---|---|
| Description: | Exploratory data analysis methods to summarize, visualize and describe datasets. The main principal component methods are available, those with the largest potential in terms of applications: principal component analysis (PCA) when variables are quantitative, correspondence analysis (CA) when variables are categorical, Multiple Factor Analysis (MFA) when variables are structured in groups. |
| Authors: | Alex Yahiaoui Martinez [aut, cre] (ORCID: <https://orcid.org/0000-0002-5315-675X>) |
| Maintainer: | Alex Yahiaoui Martinez <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-06-01 07:40:41 UTC |
| Source: | https://github.com/alexym1/booklet |
Return col contributions for each correspondence component
ca_col_contrib(col_coords, X, eigs)ca_col_contrib(col_coords, X, eigs)
col_coords |
col coordinates |
X |
standardized matrix |
eigs |
eigs computed by |
A dataframe of col contributions.
library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() eigs <- X_scaled |> ca_weighted_eigen() eigs |> ca_col_coords() |> ca_col_contrib(X_scaled, eigs) |> head()library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() eigs <- X_scaled |> ca_weighted_eigen() eigs |> ca_col_coords() |> ca_col_contrib(X_scaled, eigs) |> head()
Return Correspondence component for columns
ca_col_coords(eigs) ca_col_sup_coords(X_sup, eigs)ca_col_coords(eigs) ca_col_sup_coords(X_sup, eigs)
eigs |
eigs computed by |
X_sup |
Supplementary dataset |
A dataframe of col coordinates.
library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_weighted_eigen() |> ca_col_coords() |> head()library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_weighted_eigen() |> ca_col_coords() |> head()
Return col squared cosines for each correspondence component
ca_col_cos2(col_coords, X) ca_col_sup_cos2(col_coords, X_sup, X)ca_col_cos2(col_coords, X) ca_col_sup_cos2(col_coords, X_sup, X)
col_coords |
col coordinates |
X |
active dataset |
X_sup |
supplementary dataset |
A dataframe of col squared cosines.
library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() X_scaled |> ca_weighted_eigen() |> ca_col_coords() |> ca_col_cos2(X_scaled) |> head()library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() X_scaled |> ca_weighted_eigen() |> ca_col_coords() |> ca_col_cos2(X_scaled) |> head()
Return col inertia for each correspondence component
ca_col_inertia(X)ca_col_inertia(X)
X |
standardized matrix |
A dataframe of col inertia.
library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_col_inertia()library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_col_inertia()
Return row contributions for each correspondence component
ca_row_contrib(row_coords, X, eigs)ca_row_contrib(row_coords, X, eigs)
row_coords |
row coordinates |
X |
standardized matrix |
eigs |
eigs computed by |
A dataframe of row contributions.
library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() eigs <- X_scaled |> ca_weighted_eigen() eigs |> ca_row_coords() |> ca_row_contrib(X_scaled, eigs) |> head()library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() eigs <- X_scaled |> ca_weighted_eigen() eigs |> ca_row_coords() |> ca_row_contrib(X_scaled, eigs) |> head()
Return Correspondence component for individuals
ca_row_coords(eigs) ca_row_sup_coords(X_sup, eigs)ca_row_coords(eigs) ca_row_sup_coords(X_sup, eigs)
eigs |
eigs computed by |
X_sup |
Supplementary dataset |
A dataframe of row coordinates.
library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_weighted_eigen() |> ca_row_coords() |> head()library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_weighted_eigen() |> ca_row_coords() |> head()
Return row squared cosines for each correspondence component
ca_row_cos2(row_coords, X) ca_row_sup_cos2(row_coords, X_sup, X)ca_row_cos2(row_coords, X) ca_row_sup_cos2(row_coords, X_sup, X)
row_coords |
row coordinates |
X |
Active standardized matrix |
X_sup |
Supplementary standardized matrix |
A dataframe of row squared cosines.
library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() X_scaled |> ca_weighted_eigen() |> ca_row_coords() |> ca_row_cos2(X_scaled) |> head()library(booklet) X_scaled <- mtcars[, c(2, 8:11)] |> ca_standardize() X_scaled |> ca_weighted_eigen() |> ca_row_coords() |> ca_row_cos2(X_scaled) |> head()
Return row inertia for each correspondence component
ca_row_inertia(X)ca_row_inertia(X)
X |
standardized matrix |
A dataframe of row inertia.
library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_row_inertia()library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_row_inertia()
Perform data standardization for multivariate exploratory data analysis.
ca_standardize(X, weighted_row = rep(1, nrow(X))) ca_standardize_sup(X, type = c("row", "col"), weighted_row = rep(1, nrow(X)))ca_standardize(X, weighted_row = rep(1, nrow(X))) ca_standardize_sup(X, type = c("row", "col"), weighted_row = rep(1, nrow(X)))
X |
Active or supplementary datasets |
weighted_row |
row weights |
type |
standardization for supplementary rows or cols |
A dataframe of the same size as X.
library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> head()library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> head()
Return eigenvalues and eigenvectors of a matrix
ca_weighted_eigen(X)ca_weighted_eigen(X)
X |
X_active |
A list containing results of Single Value Decomposition (SVD).
library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_weighted_eigen() |> head()library(booklet) mtcars[, c(2, 8:11)] |> ca_standardize() |> ca_weighted_eigen() |> head()
Return CA results with FactoMineR's style
facto_ca(X, ncp = 5, row_sup = NULL, col_sup = NULL, weighted_row = NULL)facto_ca(X, ncp = 5, row_sup = NULL, col_sup = NULL, weighted_row = NULL)
X |
a data frame with n rows (individuals) and p columns (numeric variables) |
ncp |
an integer, the number of components to keep (value set by default) |
row_sup |
a vector indicating the indexes of the supplementary rows |
col_sup |
a vector indicating the indexes of the supplementary cols |
weighted_row |
row weights |
A list containing results of FactoMineR's correspondence analysis (CA).
library(booklet) res <- facto_ca(X = mtcars[, c(2, 8:11)], ncp = 2)library(booklet) res <- facto_ca(X = mtcars[, c(2, 8:11)], ncp = 2)
Return MFA results with FactoMineR's style
facto_mfa(X, groups, ncp = 2)facto_mfa(X, groups, ncp = 2)
X |
a data frame with n rows (individuals) and p columns (numeric variables) |
groups |
a vector indicating the group of each variable |
ncp |
an integer, the number of components to keep (value set by default) |
A list containing results of FactoMineR's multiple factor analysis (MFA).
library(booklet) res <- facto_mfa(X = iris[, -c(5)], groups = c(2, 2), ncp = 2)library(booklet) res <- facto_mfa(X = iris[, -c(5)], groups = c(2, 2), ncp = 2)
Return PCA results with FactoMineR's style
facto_pca( X, ncp = 5, scale.unit = TRUE, ind_sup = NULL, quanti_sup = NULL, weighted_col = NULL )facto_pca( X, ncp = 5, scale.unit = TRUE, ind_sup = NULL, quanti_sup = NULL, weighted_col = NULL )
X |
a data frame with n rows (individuals) and p columns (numeric variables) |
ncp |
an integer, the number of components to keep (value set by default) |
scale.unit |
a boolean, if TRUE (value set by default) then data are scaled to unit variance |
ind_sup |
a vector indicating the indexes of the supplementary individuals |
quanti_sup |
a vector indicating the indexes of the quantitative supplementary variables |
weighted_col |
column weights |
A list containing results of FactoMineR's principal components analysis (PCA).
library(booklet) res <- facto_pca(iris[, -5], ncp = 2, ind_sup = 1, quanti_sup = 1)library(booklet) res <- facto_pca(iris[, -5], ncp = 2, ind_sup = 1, quanti_sup = 1)
Return eigenvalues and eigenvectors of a matrix
pca_eigen(X) pca_weighted_eigen( X, weighted_row = rep(1, nrow(X))/nrow(X), weighted_col = rep(1, ncol(X)) )pca_eigen(X) pca_weighted_eigen( X, weighted_row = rep(1, nrow(X))/nrow(X), weighted_col = rep(1, ncol(X)) )
X |
X_active |
weighted_row |
row weights |
weighted_col |
column weights |
Standardization depends on what you need to perform factor analysis. We implemented two types:
pca_weighted_eigen: This is the default method in FactoMineR to compute
eigvalues, eigvectors and U matrix.
pca_eigen: This is the standard method to compute eigenvalues, eigenvectors.
A list containing results of Single Value Decomposition (SVD).
library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_eigen()library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_eigen()
Return individual contributions for each principal component
pca_ind_contrib( ind_coords, eigs, weighted_row = rep(1, nrow(ind_coords))/nrow(ind_coords) )pca_ind_contrib( ind_coords, eigs, weighted_row = rep(1, nrow(ind_coords))/nrow(ind_coords) )
ind_coords |
individual coordinates |
eigs |
eigs computed by |
weighted_row |
row weights |
If you want to compute the contributions of the individuals to the principal components, you have to change the weighted_col argument to rep(1, nrow(ind_cos2)).
A dataframe of individual contributions.
library(booklet) eigs <- iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() eigs |> pca_ind_coords() |> pca_ind_contrib(eigs) |> head()library(booklet) eigs <- iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() eigs |> pca_ind_coords() |> pca_ind_contrib(eigs) |> head()
Return principal component for individuals
pca_ind_coords(eigs)pca_ind_coords(eigs)
eigs |
eigs computed by |
A dataframe of individual coordinates.
library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_ind_coords() |> head()library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_ind_coords() |> head()
Return individual squared cosines for each principal component
pca_ind_cos2(ind_coords, weighted_col = rep(1, ncol(ind_coords)))pca_ind_cos2(ind_coords, weighted_col = rep(1, ncol(ind_coords)))
ind_coords |
individual coordinates |
weighted_col |
column weights |
A dataframe of individual squared cosines.
library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_ind_coords() |> pca_ind_cos2() |> head()library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_ind_coords() |> pca_ind_cos2() |> head()
Perform data standardization for multivariate exploratory data analysis.
pca_standardize_norm(X, center = TRUE, scale = TRUE) pca_standardize(X, scale = TRUE, weighted_row = rep(1, nrow(X))/nrow(X))pca_standardize_norm(X, center = TRUE, scale = TRUE) pca_standardize(X, scale = TRUE, weighted_row = rep(1, nrow(X))/nrow(X))
X |
matrix |
center |
centering by the mean |
scale |
scaling by the standard deviation |
weighted_row |
row weights |
Standardization depends on what you need to perform factor analysis. Two methods are implemented:
standardize: standardization is performed by centering the
data matrix and dividing by the square root of the sum of squares of the
weights. This is the same method used in FactoMineR::PCA().
standardize_norm: standardization is performed by centering and scaling
the data matrix. (X - µ) / S, where µ is the mean and S is the standard deviation.
A dataframe of the same size as X.
library(booklet) iris[, -5] |> pca_standardize_norm() |> head()library(booklet) iris[, -5] |> pca_standardize_norm() |> head()
Return variable contributions
pca_var_contrib(var_cos2, eigs, weighted_col = rep(1, ncol(var_cos2)))pca_var_contrib(var_cos2, eigs, weighted_col = rep(1, ncol(var_cos2)))
var_cos2 |
variable coordinates |
eigs |
eigs computed by |
weighted_col |
column weights |
A dataframe of variable contributions.
library(booklet) eigs <- iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() eigs |> pca_var_coords() |> pca_var_cos2() |> pca_var_contrib(eigs) |> head()library(booklet) eigs <- iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() eigs |> pca_var_coords() |> pca_var_cos2() |> pca_var_contrib(eigs) |> head()
Return variable coordinates
pca_var_coords(eigs)pca_var_coords(eigs)
eigs |
eigs computed by |
A dataframe of variable coordinates.
library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_var_coords() |> head()library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_var_coords() |> head()
Return variable correlation
pca_var_cor(eigs)pca_var_cor(eigs)
eigs |
eigs computed by |
A dataframe of variable correlation.
library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_var_cor() |> head()library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_var_cor() |> head()
Return variable squared cosines
pca_var_cos2(var_coords)pca_var_cos2(var_coords)
var_coords |
variable coordinates |
A dataframe of variable squared consines.
library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_var_coords() |> pca_var_cos2() |> head()library(booklet) iris[, -5] |> pca_standardize_norm() |> pca_weighted_eigen() |> pca_var_coords() |> pca_var_cos2() |> head()