MBPCAOS: MultiBlock Principal Components Analysis with Optimal Scaling...

View source: R/MBPCAOS.R

MBPCAOSR Documentation

MultiBlock Principal Components Analysis with Optimal Scaling features

Description

Perform MBPCAOS

Usage

MBPCAOS(
  data,
  level.scale = rep("num", ncol(data)),
  blocks,
  blocks.name = paste("Bloc", 1:length(blocks)),
  block.scaling = "inertia",
  nb.comp = 2,
  maxiter = 100,
  threshold = 1e-06,
  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"

blocks

vector(length k) with number of variables in each bloc

blocks.name

vector(length k) with names of each bloc

block.scaling

scaling applied to each block. Possible value are :

  • "inertia"(default): each quantified block is divided by its total inertia (sum of square).

  • "lambda1" : each quantified block is divided by its the first singular value.

  • "null" : no scaling is applied

nb.comp

number of components of the model (by default 2)

maxiter

maximum number of iterations.

threshold

the threshold for assessing convergence

supp.var

a vector indicating the indexes of the supplementary variables

print

boolean (TRUE by default), if TRUE ther order of the categories of ordinal variables are print

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

Blocks results

  • block.components : components associated with each block

  • block.weight : weights associated with each block

  • blocks : number of variable in each block

  • blocks.name : name of each block

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)

Examples


data('antibiotic')
antb.uses <- antibiotic[,c('Atb.conso','Atb.Sys')]
health <- antibiotic[,c('Age','Loss')]
vet.practices <- antibiotic[,c(6:15)]
antibiotic <- data.frame(antb.uses,health,vet.practices)
# Defining blocks
blocks.name =  c("antibiotic.uses","Health.of.turkeys","Veterinary.practices")
blocks <- c(2,2,10)

# Level of scaling
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,14)] <- "ord"

# MBPCAOS
res.MBPCAOS <- MBPCAOS(data = antibiotic,
                     level.scale = level.scale,
                      blocks = blocks,
                      blocks.name = blocks.name,
                      nb.comp = 3)

# Blocks graphs
plot.MBPCAOS(x = res.MBPCAOS,choice = 'blocks')




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