#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[,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 of Epifanio et al. (2013):
res <- archetypesBoundary(USAFSurvey_preproc$data,15,FALSE,3)
numArch <- 3
a3 <- archetypes::bestModel(res[[numArch]])
ras <- rbind(archetypes::parameters(a3),USAFSurvey_preproc$data)
dras <- dist(ras,method="euclidean",diag=F,upper=T,p=2)
mdras <- as.matrix(dras)
diag(mdras) <- 1e+11
sapply(seq(length=numArch),nearestToArchetypes,numArch,mdras)
Run the code above in your browser using DataLab