pca_mix {gspcr}R Documentation

PCA of a mixture of numerical and categorical data

Description

Wrapper for the PCAmixdata::PCAmix() function to be used in the main cross-validation procedure.

Usage

pca_mix(X_tr, X_va, npcs = 1)

Arguments

X_tr

data.frame of training data

X_va

data.frame of validation data

npcs

number of principal components to keep

Value

a list of training and validation PC scores

Author(s)

Edoardo Costantini, 2023

References

Chavent M, Kuentz V, Labenne A, Liquet B, Saracco J (2017). PCAmixdata: Multivariate Analysis of Mixed Data. R package version 3.1, https://CRAN.R-project.org/package=PCAmixdata.

Examples

# Example inputs
data(wine, package = "FactoMineR")
X <- wine[, c(1, 2, 16, 22)]
X$Label <- factor(X$Label)
X$Soil <- factor(X$Soil)
X_tr <- X[1:15, ]
X_va <- X[16:21, ]
npcs <- 2

# Example use
pca_mix(
    X_tr = X[1:15, ],
    X_va = X[16:21, ],
    npcs = 2
)

[Package gspcr version 0.9.5 Index]