archetypesBoundary: Archetypal analysis in multivariate accommodation problem

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/archetypesBoundary.R

Description

This function allows us to reproduce the results shown in section 2.2.2 and section 3.1 of Epifanio et al. (2013). In addition, from the results provided by this function, the other results shown in section 3.2 and section 3.3 of the same paper can be also reproduced (see section examples below).

Usage

1
archetypesBoundary(data,numArch,verbose,numRep)

Arguments

data

USAF 1967 database (see USAFSurvey). Each row corresponds to an observation, and each column corresponds to a variable. All variables are numeric.

numArch

Number of archetypes (archetypal observations).

verbose

Logical value. If TRUE, some details of the execution progress are shown (this is the same argument as that of the stepArchetypes function of the archetypes R package (Eugster (2009))).

numRep

For each archetype run archetypes numRep times (this is the same argument as the nrep argument of the stepArchetypes function of archetypes).

Details

Before using this function, the more extreme (100 - percAcomm*100)% observations must be removed by means of the preprocessing function. To that end, it is recommended that you use the Mahalanobis distance. In this case, the depth procedure has the disadvantage that the desired percentage of accommodation is not under control of the analyst and it may not exactly coincide with that one indicated.

Value

A list with numArch elements. Each element is a list of class attribute stepArchetypes with numRep elements.

Note

We would like to note that, some time after publishing the paper Epifanio et al. (2013), we found out that the stepArchetypes function standardizes the data by default (even when the data are already standardized) and this option is not always desired. In order to avoid this way of proceeding, we have created the stepArchetypesRawData function, which is used within archetypesBoundary instead of using stepArchetypes. Therefore, the results provided by archetypesBoundary allows us to reproduce the results of Epifanio et al. (2013) but they are now slightly different.

Author(s)

Irene Epifanio and Guillermo Vinue

References

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.

Eugster, M. J., and Leisch, F., (2009). From Spider-Man to Hero - Archetypal Analysis in R, Journal of Statistical Software 30, 1–23, doi: 10.18637/jss.v030.i08.

Zehner, G. F., Meindl, R. S., and Hudson, J. A., (1993). A multivariate anthropometric method for crew station design: abridged. Tech. rep. Ohio: Human Engineering Division, Armstrong Laboratory, Wright-Patterson Air Force Base.

See Also

archetypes, stepArchetypes, stepArchetypesRawData, USAFSurvey, nearestToArchetypes, preprocessing

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#The following R code allows us to reproduce the results of the paper Epifanio et al. (2013).
#As a toy example, only the first 25 individuals are used.
#First,the USAF 1967 database is read and preprocessed (Zehner et al. (1993)).
#Variable selection:
variabl_sel <- c(48, 40, 39, 33, 34, 36)
#Changing to inches: 
USAFSurvey_inch <- USAFSurvey[1:25, variabl_sel] / (10 * 2.54)

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

#Procedure and results shown in section 2.2.2 and section 3.1:
#For reproducing results, seed for randomness:
#suppressWarnings(RNGversion("3.5.0"))
#set.seed(2010)
res <- archetypesBoundary(USAFSurvey_preproc$data, 15, FALSE, 3)
#To understand the warning messages, see the vignette of the
#archetypes package.

#Results shown in section 3.2 (figure 3):
screeplot(res) 

#3 archetypes:
a3 <- archetypes::bestModel(res[[3]])
archetypes::parameters(a3)
#7 archetypes:
a7 <- archetypes::bestModel(res[[7]])
archetypes::parameters(a7) 
#Plotting the percentiles of each archetype:
#Figure 2 (b):
barplot(a3,USAFSurvey_preproc$data, percentiles = TRUE, which = "beside") 
#Figure 2 (f):
barplot(a7,USAFSurvey_preproc$data, percentiles = TRUE, which = "beside")

#Results shown in section 3.3 related with PCA.
pznueva <- prcomp(USAFSurvey_preproc$data, scale = TRUE, retx = TRUE) 
#Table 3:
summary(pznueva)
pznueva
#PCA scores for 3 archetypes:
p3 <- predict(pznueva,archetypes::parameters(a3)) 
#PCA scores for 7 archetypes:
p7 <- predict(pznueva,archetypes::parameters(a7))
#Representing the scores:
#Figure 4 (a):
xyplotPCArchetypes(p3[,1:2], pznueva$x[,1:2], data.col = gray(0.7), atypes.col = 1, 
                   atypes.pch = 15)
#Figure 4 (b):
xyplotPCArchetypes(p7[,1:2], pznueva$x[,1:2], data.col = gray(0.7), atypes.col = 1, 
                   atypes.pch = 15)

#Percentiles for 7 archetypes (table 5):
Fn <- ecdf(USAFSurvey_preproc$data)
round(Fn(archetypes::parameters(a7)) * 100)

#Which are the nearest individuals to archetypes?:
#Example for three archetypes:
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
numArch <- 3
sapply(seq(length=numArch),nearestToArchetypes,numArch,mdras) 

#In addition, we can turn the standardized values to the original variables.
p <- archetypes::parameters(a7)
m <- sapply(USAFSurvey_inch,mean)
s <- sapply(USAFSurvey_inch,sd)
d <- p
for(i in 1 : 6){
 d[,i] = p[,i] * s[i] + m[i]
}
#Table 7:
t(d)

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
[1] "The percentage of accommodation is exactly 100%"
There were 26 warnings (use warnings() to see them)
            V48         V40        V39        V33        V34        V36
[1,] -1.4363395 -1.40778394 -1.3204591 -1.2779977 -1.4025220 -1.2544001
[2,]  2.6482783  2.12918943  2.3947243  0.9773739  0.8492986  0.9559742
[3,]  0.3934417  0.02528345  0.7856189  2.1226503  2.0602675  1.6234480
            V48        V40        V39        V33         V34        V36
[1,] -0.3670004 -0.6356036  0.1765005  0.3758268 -0.05578109  0.2642210
[2,]  0.8550735  0.6295640  1.5543479  3.0167577  2.70666966  1.9336612
[3,]  0.6347926  0.6749835  0.3294277  0.9082770  0.99337699  1.0318839
[4,] -0.1517469  0.4967432  0.5545965 -0.1613396 -0.02819062 -1.3532884
[5,] -1.2917604 -0.3939498 -0.3968969 -1.4141384 -1.30679575 -1.1773837
[6,] -1.3326809 -2.2393805 -1.9905469 -1.1323588 -1.50009729 -1.1885574
[7,]  2.6416808  2.0969209  2.3439604  0.9624772  0.83393968  0.9450274
Importance of components:
                          PC1    PC2     PC3     PC4     PC5     PC6
Standard deviation     2.0920 0.9724 0.60041 0.38492 0.36177 0.19582
Proportion of Variance 0.7294 0.1576 0.06008 0.02469 0.02181 0.00639
Cumulative Proportion  0.7294 0.8870 0.94710 0.97180 0.99361 1.00000
Standard deviations (1, .., p=6):
[1] 2.0920385 0.9723677 0.6004109 0.3849174 0.3617681 0.1958195

Rotation (n x k) = (6 x 6):
           PC1        PC2        PC3        PC4         PC5         PC6
V48 -0.3944472 -0.3205130 -0.7352829  0.2591028 -0.35919722  0.06989300
V40 -0.3866531 -0.5302035  0.1720589  0.2290238  0.67984717 -0.15854106
V39 -0.4064501 -0.3931392  0.4120171 -0.5569641 -0.41585880  0.16533074
V33 -0.4328513  0.3464121  0.2647274  0.2898743 -0.29714285 -0.67099683
V34 -0.4261090  0.3992454  0.2177968  0.3542715  0.05660779  0.69490001
V36 -0.4009738  0.4268477 -0.3774661 -0.6005576  0.37993201 -0.09758419
 [1] 33 84 77 45 10  9 98 25 76 78 70 33  1 97 60 94 66 71 32  1 97 68 99 86 43
[26]  8 12 87 49 99 88 51  9  6 83 65 95 88  9 11 11 86
[1] 21 16  6
        [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
V48 31.88714 34.24517 33.82013 32.30247 30.10278 30.02382 37.69249
V40 23.29925 24.79754 24.85133 24.64024 23.58543 21.39995 26.53528
V39 17.22985 18.65538 17.38807 17.62103 16.63661 14.98782 19.47232
V33 37.53783 41.25073 38.28640 36.78262 35.02130 35.41746 38.36260
V34 32.09491 35.42758 33.36063 32.12820 30.58566 30.35246 33.16828
V36 24.56923 26.45441 25.43610 22.74270 22.94133 22.92872 25.33802

Anthropometry documentation built on Dec. 11, 2021, 9:08 a.m.