PCAOS: Principal Component Analysis with Optimal Scaling

View source: R/PCAOS.R

PCAOSR Documentation

Principal Component Analysis with Optimal Scaling

Description

Perform PCAOS

Usage

PCAOS(
  data,
  level.scale = rep("num", ncol(data)),
  nb.comp = 2,
  maxiter = 100,
  threshold = 1e-06,
  D = 1,
  supp.var = NULL,
  print = TRUE,
  init = "rdm"
)

Arguments

data

a data frame with n rows (individuals) and p columns (numeric, nominal and/or ordinal variables)

level.scale

vector(length p) giving the nature of each variable. Possible values: "nom", "ord", "num". The order of categories for an ordinal variable is indicated by it's level.

nb.comp

number of components of the model (by default 2)

maxiter

maximum number of iterations

threshold

threshold for assessing convergence

D

degree of the relation between quantified variables and components (only for numeric variables, default = 1)

supp.var

a vector indicating the indexes of the supplementary variables

print

boolean (TRUE by default), if TRUE convergence information and order of the categories of ordinal variables are printed.

init

Intitialization strategy, possible values are :

  • "rdm" (default) : random initialisation

  • "svd": components are initialized with the singular value decomposition of the concatenated and pretreated variables (numeric variables are standardized and categorical variables are coded as pseudo disjunctive and weighted by the frequencies of the categories)

Value

Dimension reduction

  • weigths : list of weights of the variables (loadings and weights are the same in PCA-like model)

  • components : data.frame with individuals scores for each dimension

  • inertia : percentage and cumulative percentage of variance of the quantified variables explained

Quantifications

  • quantified.data : optimally quantified variables

  • quantification.categories.nom : list of optimally quantified categories (nominal variables)

  • quantification.categories.ord : list of optimally quantified categories (ordinal variables)

  • level.scale : nature of scaling choosen for each variable

  • data : orginal dataset

Algorithm

  • summary : summary of the number of variables according to their nature

  • loss.tot : global loss for all variables

  • stockiter : evolution of the criterion for each ieration

Supplementary variables

  • var.supp : original supplementary variables

  • level.scale.supp : level of scaling of supplementary variables

  • coord.supp.num : coordinates of supplementary numeric variables (correlation with components)

  • coord.supp.quali : coordinates of qualitatve variables (barycenters)

Author(s)

References

Paries, Bougeard, Vigneau (2022), Multivariate analysis of Just-About-Right data with optimal scaling approach. Food Quality and Preference (submit)

Examples


data (antibiotic)
# Level of scaling of each variable
# Manually
level.scale <- rep(NA,ncol(antibiotic)) #Setting level.scale argument
level.scale[c(3,4)] <- "num"
level.scale[c(6:14)] <- "nom"
level.scale[c(1,15)] <- "ord"
# Or using nature.variables()
level.scale <- rep(NA,ncol(antibiotic))
res.nature <- nature.variables(antibiotic)
level.scale [res.nature$p.numeric] <- "num"
level.scale [res.nature$p.quali] <- "nom"
#Warning; the ordinal nature of variables can not be detected automaticaly.
level.scale[c(1,15)] <- "ord"

# PCAOS
res.PCAOS <- PCAOS(
data = antibiotic,
level.scale = level.scale,
nb.comp = 2)

# Plot (individuals)
plot.PCAOS(
 x = res.PCAOS,
 choice = "ind",
 coloring.indiv = antibiotic$Atb.conso,
 size.legend = 12,
 size.label = 4
)


martinparies/PCAOS documentation built on March 15, 2023, 7:19 a.m.