nearestToArchetypes: Nearest individuals to archetypes

View source: R/nearestToArchetypes.R

nearestToArchetypesR Documentation

Nearest individuals to archetypes

Description

The nearest individual to each archetype can be obtained by simply computing the distance between the archetypes and the individuals and choosing the nearest. This is the procedure to obtain what is called the cand_ns vector, see Vinue et al. (2015). It is used within archetypoids and stepArchetypoids.

Usage

nearestToArchetypes(indivs,numArch,mdras)

Arguments

indivs

Vector from 1 to numArch of individuals nearest to archetypes.

numArch

Number of archetypes computed.

mdras

Distance matrix between the archetypes and the individuals.

Value

A vector with the nearest individuals to archetypes.

Author(s)

Irene Epifanio

References

Vinue, G., Epifanio, I., and Alemany, S., (2015). Archetypoids: a new approach to define representative archetypal data, Computational Statistics and Data Analysis 87, 102–115.

Epifanio, I., Vinue, G., and Alemany, S., (2013). Archetypal analysis: contributions for estimating boundary cases in multivariate accommodation problem, Computers & Industrial Engineering 64, 757–765.

See Also

archetypoids, stepArchetypoids, archetypesBoundary

Examples

#COCKPIT DESIGN PROBLEM:
#As a toy example, only the first 25 individuals are used.
USAFSurvey_First25 <- USAFSurvey[1:25, ]
#Variable selection:
variabl_sel <- c(48, 40, 39, 33, 34, 36)
#Changing to inches: 
USAFSurvey_First25_inch <- USAFSurvey_First25[,variabl_sel] / (10 * 2.54)

#Data preprocessing:
USAFSurvey_preproc <- preprocessing(USAFSurvey_First25_inch, TRUE, 0.95, TRUE)

res <- archetypesBoundary(USAFSurvey_preproc$data, 5, FALSE, 3)
#To understand the warning messages, see the vignette of the
#archetypes package.  

numArch <- 3
a3 <- archetypes::bestModel(res[[numArch]])
ras <- rbind(archetypes::parameters(a3), USAFSurvey_preproc$data)
dras <- dist(ras, method = "euclidean", diag = FALSE, upper = TRUE, p = 2)
mdras <- as.matrix(dras)
diag(mdras) <- 1e+11
sapply(seq(length=numArch), nearestToArchetypes, numArch, mdras) 

Anthropometry documentation built on March 7, 2023, 6:58 p.m.