choice.component.MB: choice.component

View source: R/choice.component.MB.R

choice.component.MBR Documentation

choice.component

Description

Helps the user to choose the appropriate number of MBPCAOS component to optimize

Usage

choice.component.MB(
  data,
  level.scale,
  blocks,
  blocks.name,
  nb.comp.to.investigate = 5,
  block.scaling = "inertia",
  supp.var = NULL
)

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

nb.comp.to.investigate

Number of components to investigate (default=ncol(data))

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

supp.var

a vector indicating the indexes of the supplementary variables

Value

Data frame with global Loss value and percentage of the quantified variables inertia explained, for different model dimensionality (H). The last column provides the variation in percentage between to two successive size of dimensionality.

Author(s)

Examples


data('antibiotic')
antb.uses <- antibiotic[,c('Atb.conso','Atb.Sys')]
health <- antibiotic[,c('Age','Loss')]
vet.practices <- antibiotic[,c(6:15)]
antibiotic.MB <- data.frame(antb.uses,health,vet.practices)

# Defining the blocks
blocks.name =  c("antibiotic.uses","Health.of.turkeys","Veterinary.practices")
blocks <- c(2,2,10)

# Level of scaling
level.scale.MB <- rep(NA,ncol(antibiotic.MB))
res.nature <- nature.variables(antibiotic.MB)
level.scale.MB [res.nature$p.numeric] <- "num"
level.scale.MB [res.nature$p.quali] <- "nom"
#Warning; the ordinal nature of variables can not be detected automaticaly.
level.scale.MB[c(1,14)] <- "ord"

# Choice of number of components
help(choice.component.MB)
res.choice.MB <- choice.component.MB(antibiotic.MB,
                                     level.scale.MB,
                                     blocks,
                                     blocks.name,
                                     block.scaling = 'inertia')
res.choice.MB


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